From 0ef72e1b238ee3267672e5ee73eec6956c9fdccf Mon Sep 17 00:00:00 2001 From: jacob Date: Sat, 11 Jan 2025 15:49:57 -0600 Subject: [PATCH] disable all warnings for profiling build --- build.c | 3 +++ src/collider.c | 21 +++++++++++++-------- src/game.c | 14 +++++++++----- src/phys.c | 30 ++++++++++++++++++++++-------- src/user.c | 9 +++++++-- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/build.c b/build.c index b7d21f54..dd49a1ab 100644 --- a/build.c +++ b/build.c @@ -373,6 +373,7 @@ void OnBuild(StringList cli_args) "-Wno-c11-extensions -Wno-gnu-anonymous-struct -Wno-nested-anon-types " "" "-Wno-double-promotion"); + /* -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter */ StringListAppend(&perm, &compile_warnings, warnings); @@ -475,6 +476,8 @@ void OnBuild(StringList cli_args) /* Disable compile_warnings when compiling tracy client */ compile_warnings = (StringList) { 0 }; link_warnings = (StringList) { 0 }; + StringListAppend(&perm, &compile_warnings, Lit("-Wno-everything")); + StringListAppend(&perm, &link_warnings, Lit("-Wno-everything")); } if (!arg_msvc) { diff --git a/src/collider.c b/src/collider.c index eddb7d78..8cc19f8b 100644 --- a/src/collider.c +++ b/src/collider.c @@ -458,22 +458,24 @@ struct collider_collision_points_result collider_collision_points(struct collide u32 dbg_step = 0; #endif + struct gjk_result gjk_res = ZI; + struct epa_result epa_res = ZI; /* Run GJK */ #if COLLIDER_DEBUG - struct gjk_result gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq, dbg_step); + gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq, dbg_step); dbg_step = gjk_res.dbg_step; #else - struct gjk_result gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq); + gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq); #endif DBGSTEP; /* Run EPA */ #if COLLIDER_DEBUG - struct epa_result epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations, dbg_step); + epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations, dbg_step); dbg_step = epa_res.dbg_step; #else - struct epa_result epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations); + epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations); #endif normal = epa_res.normal; DBGSTEP; @@ -789,21 +791,24 @@ struct collider_closest_points_result collider_closest_points(struct collider_sh u32 dbg_step = 0; #endif + struct gjk_result gjk_res = ZI; + struct epa_result epa_res = ZI; + /* Run GJK */ #if COLLIDER_DEBUG - struct gjk_result gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq, dbg_step); + gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq, dbg_step); dbg_step = gjk_res.dbg_step; #else - struct gjk_result gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq); + gjk_res = gjk_get_simplex(shape0, shape1, xf0, xf1, min_unique_pt_dist_sq); #endif DBGSTEP; /* Run EPA */ #if COLLIDER_DEBUG - struct epa_result epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations, dbg_step); + epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations, dbg_step); dbg_step = epa_res.dbg_step; #else - struct epa_result epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations); + epa_res = epa_get_normal_from_gjk(shape0, shape1, xf0, xf1, gjk_res, min_unique_pt_dist_sq, max_epa_iterations); #endif DBGSTEP; diff --git a/src/game.c b/src/game.c index b5f0df2b..8391158b 100644 --- a/src/game.c +++ b/src/game.c @@ -128,7 +128,9 @@ INTERNAL void reset_world(void) /* Release world */ world_release(&G.tick); /* Release bookkeeping */ +#if COLLIDER_DEBUG entity_lookup_release(&G.collision_debug_lookup); +#endif entity_lookup_release(&G.contact_lookup); } @@ -527,10 +529,10 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) ent->local_collider.count = 1; ent->local_collider.radius = 0.5; #elif 1 - ent->local_collider.points[0] = v2_with_len(V2(0.08, 0.17), 0.15); - ent->local_collider.points[1] = v2_with_len(V2(-0.07, -0.2), 0.15); + ent->local_collider.points[0] = v2_with_len(V2(0.08f, 0.17f), 0.15f); + ent->local_collider.points[1] = v2_with_len(V2(-0.07f, -0.2f), 0.15f); ent->local_collider.count = 2; - ent->local_collider.radius = 0.075; + ent->local_collider.radius = 0.075f; #elif 1 #if 0 /* "Bad" winding order */ @@ -823,7 +825,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) struct phys_motor_joint_def def = ZI; def.e0 = joint_ent->handle; /* Re-using joint entity as e0 */ def.e1 = ent->handle; - def.correction_rate = 0.1; + def.correction_rate = 0.1f; def.max_force = 0; def.max_torque = ent->control_torque; joint_ent->motor_joint_data = motor_joint_from_def(def); @@ -874,7 +876,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) f32 new_vel = 0; if (!F32_IS_NAN(new_angle)) { - const f32 angle_error_allowed = 0.001; + const f32 angle_error_allowed = 0.001f; struct xform joint_xf = entity_get_xform(joint_ent); f32 diff = math_unwind_angle(new_angle - xform_get_rotation(joint_xf)); if (math_fabs(diff) > angle_error_allowed) { @@ -923,7 +925,9 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) ctx.tick_id = G.tick.tick_id; ctx.store = store; ctx.contact_lookup = &G.contact_lookup; +#if COLLIDER_DEBUG ctx.debug_lookup = &G.collision_debug_lookup; +#endif /* Mouse drag */ ctx.dbg_cursor_pos = G.user_cursor; diff --git a/src/phys.c b/src/phys.c index 20d75bd3..cc367f67 100644 --- a/src/phys.c +++ b/src/phys.c @@ -22,8 +22,8 @@ struct phys_startup_receipt phys_startup(void) const f32 contact_damping_ratio = 10; G.contact_softness = math_spring(contact_frequency, contact_damping_ratio, substep_dt); - const f32 mouse_joint_linear_frequency = 5.0; - const f32 mouse_joint_linear_damping_ratio = 0.7; + const f32 mouse_joint_linear_frequency = 5.0f; + const f32 mouse_joint_linear_damping_ratio = 0.7f; const f32 mouse_joint_angular_frequency = 0.5f; const f32 mouse_joint_angular_damping_ratio = 0.1f; G.mouse_joint_max_force = 1000; @@ -39,6 +39,7 @@ struct phys_startup_receipt phys_startup(void) void phys_create_contacts(struct phys_ctx *ctx, f32 elapsed_dt) { + __prof; u64 tick_id = ctx->tick_id; struct entity_lookup *contact_lookup = ctx->contact_lookup; struct entity_lookup *debug_lookup = ctx->debug_lookup; @@ -246,11 +247,9 @@ void phys_create_contacts(struct phys_ctx *ctx, f32 elapsed_dt) ++e0->colliding; ++e1->colliding; } - } else { - if (collider_res.num_points == 0) { - --e0->colliding; - --e1->colliding; - } + } else if (collider_res.num_points == 0) { + --e0->colliding; + --e1->colliding; } dbg->e0 = e0->handle; dbg->e1 = e1->handle; @@ -280,6 +279,7 @@ void phys_create_contacts(struct phys_ctx *ctx, f32 elapsed_dt) void phys_prepare_contacts(struct phys_ctx *ctx) { + __prof; struct entity_lookup *contact_lookup = ctx->contact_lookup; struct entity_lookup *debug_lookup = ctx->debug_lookup; struct entity_store *store = ctx->store; @@ -413,6 +413,7 @@ void phys_prepare_contacts(struct phys_ctx *ctx) void phys_warm_start_contacts(struct phys_ctx *ctx) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *constraint_ent = &store->entities[entity_index]; @@ -467,6 +468,7 @@ void phys_warm_start_contacts(struct phys_ctx *ctx) void phys_solve_contacts(struct phys_ctx *ctx, f32 dt, b32 apply_bias) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *constraint_ent = &store->entities[entity_index]; @@ -597,6 +599,7 @@ struct phys_motor_joint motor_joint_from_def(struct phys_motor_joint_def def) void phys_prepare_motor_joints(struct phys_ctx *ctx) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *joint_ent = &store->entities[entity_index]; @@ -660,6 +663,7 @@ void phys_prepare_motor_joints(struct phys_ctx *ctx) void phys_warm_start_motor_joints(struct phys_ctx *ctx) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *joint_ent = &store->entities[entity_index]; @@ -691,6 +695,7 @@ void phys_warm_start_motor_joints(struct phys_ctx *ctx) void phys_solve_motor_joints(struct phys_ctx *ctx, f32 dt) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *joint_ent = &store->entities[entity_index]; @@ -770,6 +775,7 @@ void phys_solve_motor_joints(struct phys_ctx *ctx, f32 dt) void phys_create_mouse_joints(struct phys_ctx *ctx) { + __prof; struct entity_store *store = ctx->store; struct v2 cursor = ctx->dbg_cursor_pos; b32 start_dragging = ctx->dbg_start_dragging; @@ -837,6 +843,7 @@ void phys_create_mouse_joints(struct phys_ctx *ctx) void phys_prepare_mouse_joints(struct phys_ctx *ctx) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *joint_ent = &store->entities[entity_index]; @@ -883,6 +890,7 @@ void phys_prepare_mouse_joints(struct phys_ctx *ctx) void phys_warm_start_mouse_joints(struct phys_ctx *ctx) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *joint_ent = &store->entities[entity_index]; @@ -904,6 +912,7 @@ void phys_warm_start_mouse_joints(struct phys_ctx *ctx) void phys_solve_mouse_joints(struct phys_ctx *ctx, f32 dt) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *joint_ent = &store->entities[entity_index]; @@ -988,8 +997,8 @@ void phys_solve_mouse_joints(struct phys_ctx *ctx, f32 dt) f32 phys_determine_earliest_toi_for_bullets(struct phys_ctx *ctx, f32 step_dt, f32 tolerance, u32 max_iterations) { - struct entity_store *store = ctx->store; __prof; + struct entity_store *store = ctx->store; f32 smallest_t = 1; for (u64 e0_index = 0; e0_index < store->reserved; ++e0_index) { @@ -1055,6 +1064,7 @@ f32 phys_determine_earliest_toi_for_bullets(struct phys_ctx *ctx, f32 step_dt, f void phys_integrate_forces(struct phys_ctx *ctx, f32 dt) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *ent = &store->entities[entity_index]; @@ -1082,6 +1092,7 @@ void phys_integrate_forces(struct phys_ctx *ctx, f32 dt) void phys_integrate_velocities(struct phys_ctx *ctx, f32 dt) { + __prof; struct entity_store *store = ctx->store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *ent = &store->entities[entity_index]; @@ -1108,10 +1119,12 @@ void phys_integrate_velocities(struct phys_ctx *ctx, f32 dt) void phys_step(struct phys_ctx *ctx, f32 timestep) { + __prof; phys_integrate_forces(ctx, timestep); f32 remaining_dt = timestep; while (remaining_dt > 0) { + __profscope(step); /* TOI */ f32 step_dt = remaining_dt; { @@ -1137,6 +1150,7 @@ void phys_step(struct phys_ctx *ctx, f32 timestep) f32 substep_dt = step_dt / GAME_PHYSICS_SUBSTEPS; for (u32 i = 0; i < GAME_PHYSICS_SUBSTEPS; ++i) { + __profscope(substep); #if GAME_PHYSICS_ENABLE_WARM_STARTING phys_warm_start_contacts(ctx); phys_warm_start_motor_joints(ctx); diff --git a/src/user.c b/src/user.c index 8041dcab..98ffdafa 100644 --- a/src/user.c +++ b/src/user.c @@ -1036,7 +1036,12 @@ INTERNAL void user_update(void) /* Draw collider */ if (entity_has_prop(ent, ENTITY_PROP_PHYSICAL_DYNAMIC)) { struct collider_shape collider = ent->local_collider; - u32 color = ent->colliding > 0 ? RGBA_32_F(1, 1, 1, 0.5) : RGBA_32_F(1, 1, 0, 0.25); + u32 color = RGBA_32_F(1, 1, 0, 0.25); +#if COLLIDER_DEBUG + if (ent->colliding > 0) { + color = RGBA_32_F(1, 1, 1, 0.5); + } +#endif f32 thickness = 2; { /* Draw collider using support points */ @@ -1070,7 +1075,7 @@ INTERNAL void user_update(void) } /* Draw constraint */ -#if 1 +#if COLLIDER_DEBUG if (entity_has_prop(ent, ENTITY_PROP_COLLISION_DEBUG)) { struct phys_collision_debug *data = &ent->collision_debug_data; struct collider_collision_points_result collider_res = data->res;