some pausing fixes
This commit is contained in:
parent
5e81b78ac1
commit
12e5cbe7cc
BIN
res/graphics/gun.ase
(Stored with Git LFS)
BIN
res/graphics/gun.ase
(Stored with Git LFS)
Binary file not shown.
@ -945,7 +945,7 @@ void sim_step(struct sim_step_ctx *ctx)
|
|||||||
bullet->bullet_src_pos = rel_pos;
|
bullet->bullet_src_pos = rel_pos;
|
||||||
bullet->bullet_src_dir = rel_dir;
|
bullet->bullet_src_dir = rel_dir;
|
||||||
//bullet->bullet_impulse = 0.75f;
|
//bullet->bullet_impulse = 0.75f;
|
||||||
bullet->bullet_impulse = 2.0f;
|
bullet->bullet_impulse = 0.75;
|
||||||
bullet->bullet_knockback = 10;
|
bullet->bullet_knockback = 10;
|
||||||
bullet->mass_unscaled = 0.04f;
|
bullet->mass_unscaled = 0.04f;
|
||||||
bullet->inertia_unscaled = 0.00001f;
|
bullet->inertia_unscaled = 0.00001f;
|
||||||
@ -954,6 +954,7 @@ void sim_step(struct sim_step_ctx *ctx)
|
|||||||
/* Point collider */
|
/* Point collider */
|
||||||
bullet->local_collider.points[0] = V2(0, 0);
|
bullet->local_collider.points[0] = V2(0, 0);
|
||||||
bullet->local_collider.count = 1;
|
bullet->local_collider.count = 1;
|
||||||
|
bullet->local_collider.radius = 0.05;
|
||||||
|
|
||||||
sim_ent_enable_prop(bullet, SEPROP_BULLET);
|
sim_ent_enable_prop(bullet, SEPROP_BULLET);
|
||||||
sim_ent_enable_prop(bullet, SEPROP_SENSOR);
|
sim_ent_enable_prop(bullet, SEPROP_SENSOR);
|
||||||
|
|||||||
@ -122,7 +122,7 @@ struct sprite_scope_cache_ref {
|
|||||||
struct load_cmd {
|
struct load_cmd {
|
||||||
struct load_cmd *next_free;
|
struct load_cmd *next_free;
|
||||||
struct sprite_scope *scope;
|
struct sprite_scope *scope;
|
||||||
struct sprite_scope_cache_ref *scope_ref;
|
struct cache_ref ref;
|
||||||
struct sprite_tag tag;
|
struct sprite_tag tag;
|
||||||
u8 tag_path_buff[512];
|
u8 tag_path_buff[512];
|
||||||
};
|
};
|
||||||
@ -329,7 +329,7 @@ INTERNAL void push_load_task(struct cache_ref ref, struct sprite_tag tag)
|
|||||||
|
|
||||||
/* Initialize cmd */
|
/* Initialize cmd */
|
||||||
cmd->scope = sprite_scope_begin();
|
cmd->scope = sprite_scope_begin();
|
||||||
cmd->scope_ref = scope_ensure_ref_from_ref(cmd->scope, ref);
|
cmd->ref = scope_ensure_ref_from_ref(cmd->scope, ref)->ref;
|
||||||
cmd->tag = tag;
|
cmd->tag = tag;
|
||||||
{
|
{
|
||||||
u64 copy_len = min_u64(tag.path.len, ARRAY_COUNT(cmd->tag_path_buff));
|
u64 copy_len = min_u64(tag.path.len, ARRAY_COUNT(cmd->tag_path_buff));
|
||||||
@ -1114,7 +1114,7 @@ INTERNAL WORK_TASK_FUNC_DEF(sprite_load_task, arg)
|
|||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
struct load_cmd *cmd = (struct load_cmd *)arg;
|
struct load_cmd *cmd = (struct load_cmd *)arg;
|
||||||
struct cache_ref ref = cmd->scope_ref->ref;
|
struct cache_ref ref = cmd->ref;
|
||||||
|
|
||||||
switch (ref.e->kind) {
|
switch (ref.e->kind) {
|
||||||
case CACHE_ENTRY_KIND_TEXTURE: {
|
case CACHE_ENTRY_KIND_TEXTURE: {
|
||||||
|
|||||||
34
src/user.c
34
src/user.c
@ -123,6 +123,7 @@ GLOBAL struct {
|
|||||||
struct v2 ui_center;
|
struct v2 ui_center;
|
||||||
struct v2 ui_cursor;
|
struct v2 ui_cursor;
|
||||||
struct v2 world_cursor;
|
struct v2 world_cursor;
|
||||||
|
struct v2 world_cursor_send;
|
||||||
} G = ZI, DEBUG_ALIAS(G, G_user);
|
} G = ZI, DEBUG_ALIAS(G, G_user);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
@ -512,7 +513,11 @@ INTERNAL void user_update(void)
|
|||||||
struct sim_snapshot *newest_snapshot = sim_snapshot_from_tick(G.user_unblended_client, G.user_unblended_client->last_tick);
|
struct sim_snapshot *newest_snapshot = sim_snapshot_from_tick(G.user_unblended_client, G.user_unblended_client->last_tick);
|
||||||
G.local_sim_last_known_time_ns = newest_snapshot->sim_time_ns;
|
G.local_sim_last_known_time_ns = newest_snapshot->sim_time_ns;
|
||||||
G.local_sim_last_known_tick = newest_snapshot->tick;
|
G.local_sim_last_known_tick = newest_snapshot->tick;
|
||||||
G.local_sim_predicted_time_ns = newest_snapshot->sim_time_ns + (newest_snapshot->sim_dt_ns * tick_progress);
|
if (atomic_i32_eval(&G.user_paused)) {
|
||||||
|
G.local_sim_predicted_time_ns = G.local_sim_last_known_tick;
|
||||||
|
} else {
|
||||||
|
G.local_sim_predicted_time_ns = newest_snapshot->sim_time_ns + (newest_snapshot->sim_dt_ns * tick_progress);
|
||||||
|
}
|
||||||
|
|
||||||
if (USER_INTERP_ENABLED && !atomic_i32_eval(&G.user_paused)) {
|
if (USER_INTERP_ENABLED && !atomic_i32_eval(&G.user_paused)) {
|
||||||
/* Determine render time */
|
/* Determine render time */
|
||||||
@ -556,7 +561,7 @@ INTERNAL void user_update(void)
|
|||||||
G.ss_blended = sim_snapshot_alloc(G.user_blended_client, right_snapshot, right_snapshot->tick);
|
G.ss_blended = sim_snapshot_alloc(G.user_blended_client, right_snapshot, right_snapshot->tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release unneeded unblended sim snapshots */
|
/* Release unneeded unblended snapshots */
|
||||||
if (left_snapshot->tick > 0) {
|
if (left_snapshot->tick > 0) {
|
||||||
sim_snapshot_release_ticks_in_range(G.user_unblended_client, 0, left_snapshot->tick - 1);
|
sim_snapshot_release_ticks_in_range(G.user_unblended_client, 0, left_snapshot->tick - 1);
|
||||||
}
|
}
|
||||||
@ -564,11 +569,11 @@ INTERNAL void user_update(void)
|
|||||||
/* Interp disabled, just copy latest snapshot */
|
/* Interp disabled, just copy latest snapshot */
|
||||||
G.render_time_target_ns = newest_snapshot->sim_time_ns;
|
G.render_time_target_ns = newest_snapshot->sim_time_ns;
|
||||||
G.render_time_ns = newest_snapshot->sim_time_ns;
|
G.render_time_ns = newest_snapshot->sim_time_ns;
|
||||||
if (G.ss_blended->tick != newest_snapshot->tick) {
|
G.ss_blended = sim_snapshot_alloc(G.user_blended_client, newest_snapshot, newest_snapshot->tick);
|
||||||
if (G.ss_blended->valid) {
|
|
||||||
sim_snapshot_release(G.ss_blended);
|
/* Release unneeded unblended snapshots */
|
||||||
}
|
if (newest_snapshot->tick > 0) {
|
||||||
G.ss_blended = sim_snapshot_alloc(G.user_blended_client, newest_snapshot, newest_snapshot->tick);
|
sim_snapshot_release_ticks_in_range(G.user_unblended_client, 0, newest_snapshot->tick - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,10 +1142,6 @@ INTERNAL void user_update(void)
|
|||||||
u32 point_color = RGBA_32_F(1, 0, 0, 1);
|
u32 point_color = RGBA_32_F(1, 0, 0, 1);
|
||||||
u32 ray_color = RGBA_32_F(1, 0, 0.5, 1);
|
u32 ray_color = RGBA_32_F(1, 0, 0.5, 1);
|
||||||
|
|
||||||
if (colliding) {
|
|
||||||
quad_color = RGBA_32_F(1, 1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (u64 i = 0; i < sheet->slice_groups_count; ++i) {
|
for (u64 i = 0; i < sheet->slice_groups_count; ++i) {
|
||||||
struct sprite_sheet_slice_group *group = &sheet->slice_groups[i];
|
struct sprite_sheet_slice_group *group = &sheet->slice_groups[i];
|
||||||
if (string_ends_with(group->name, LIT(".ray"))) continue;
|
if (string_ends_with(group->name, LIT(".ray"))) continue;
|
||||||
@ -1172,7 +1173,7 @@ INTERNAL void user_update(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Draw collider */
|
/* Draw collider */
|
||||||
if (sim_ent_has_prop(ent, SEPROP_PHYSICAL_DYNAMIC)) {
|
if (ent->local_collider.count > 0) {
|
||||||
struct collider_shape collider = ent->local_collider;
|
struct collider_shape collider = ent->local_collider;
|
||||||
u32 color = RGBA_32_F(1, 1, 0, 0.5);
|
u32 color = RGBA_32_F(1, 1, 0, 0.5);
|
||||||
f32 thickness = 2;
|
f32 thickness = 2;
|
||||||
@ -1575,7 +1576,9 @@ INTERNAL void user_update(void)
|
|||||||
input_move_dir = xform_basis_invert_mul_v2(G.world_to_ui_xf, input_move_dir); /* Make move dir relative to world view */
|
input_move_dir = xform_basis_invert_mul_v2(G.world_to_ui_xf, input_move_dir); /* Make move dir relative to world view */
|
||||||
input_move_dir = v2_mul(v2_norm(input_move_dir), move_speed);
|
input_move_dir = v2_mul(v2_norm(input_move_dir), move_speed);
|
||||||
}
|
}
|
||||||
struct v2 input_aim_dir = v2_sub(G.world_cursor, sim_ent_get_xform(local_control).og);
|
|
||||||
|
G.world_cursor_send = G.world_cursor;
|
||||||
|
struct v2 input_aim_dir = v2_sub(G.world_cursor_send, sim_ent_get_xform(local_control).og);
|
||||||
|
|
||||||
/* Queue player control cmd */
|
/* Queue player control cmd */
|
||||||
{
|
{
|
||||||
@ -2249,10 +2252,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b32 should_step = true;
|
b32 should_step = !atomic_i32_eval(&G.user_paused);
|
||||||
if (atomic_i32_eval(&G.user_paused)) {
|
|
||||||
should_step = false;
|
|
||||||
}
|
|
||||||
if (atomic_i32_eval(&G.user_paused_steps) > 0) {
|
if (atomic_i32_eval(&G.user_paused_steps) > 0) {
|
||||||
should_step = true;
|
should_step = true;
|
||||||
atomic_i32_eval_add(&G.user_paused_steps, -1);
|
atomic_i32_eval_add(&G.user_paused_steps, -1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user