From 1eac05e8f1dd9fab6483e364b0cbb1d0a9c14f4c Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 9 Oct 2024 17:17:57 -0500 Subject: [PATCH] re-enable collisions --- src/game.c | 67 +++++++----------------------------------------------- 1 file changed, 8 insertions(+), 59 deletions(-) diff --git a/src/game.c b/src/game.c index 0cf520f3..eadd5f92 100644 --- a/src/game.c +++ b/src/game.c @@ -166,61 +166,6 @@ INTERNAL void spawn_test_entities(f32 offset) entity_enable_prop(e, ENTITY_PROP_PLAYER_CONTROLLED); //e->control_force = 4500; - e->control_force = 1200; - //e->control_force = 250; - e->control_torque = 10; - e->control.focus = V2(0, -1); - - entity_enable_prop(e, ENTITY_PROP_PHYSICAL); - e->mass_unscaled = 100; - //e->inertia_unscaled = F32_INFINITY; - e->inertia_unscaled = 25; - e->linear_ground_friction = 1000; - e->angular_ground_friction = 100; - - //entity_enable_prop(e, ENTITY_PROP_TEST); - - player_ent = e; - } - - { - //struct v2 pos = V2(0.25, -10); - //struct v2 pos = V2(0.25, -7); - //struct v2 pos = V2(0.25, -5.27); - //struct v2 pos = V2(0.85, -2); - struct v2 pos = V2(0.25, -2); - //struct v2 pos = V2(1.1230469346046448864129274625156, -1); /* Touching right side of box */ - //struct v2 pos = V2(1.1230469346046448864129274625156 - 0.0001, -1); /* Touching right side of box */ - //struct v2 pos = V2(0.374142020941, -0.246118023992); /* Touching glitch spot */ - - pos = v2_add(pos, V2(0, offset)); - pos = v2_add(pos, V2(0, offset_all)); - - //struct v2 size = V2(1, 1); - struct v2 size = V2(0.5, 0.5); - //f32 r = PI; - //f32 r = PI / 4; - //f32 r = PI / 3; - //f32 r = 0.05; - //f32 r = PI / 2; - f32 r = 0; - //f32 skew = PI / 4; - f32 skew = 0; - - struct entity *e = entity_alloc(root); - - struct xform xf = XFORM_TRS(.t = pos, .r = r, .s = size); - xf = xform_skewed_to(xf, skew); - entity_set_xform(e, xf); - - //e->sprite = sprite_tag_from_path(STR("res/graphics/tim.ase")); - e->sprite = sprite_tag_from_path(STR("res/graphics/box.ase")); - //e->sprite_span_name = STR("idle.unarmed"); - //e->sprite_span_name = STR("idle.one_handed"); - e->sprite_span_name = STR("idle.two_handed"); - - //entity_enable_prop(e, ENTITY_PROP_PLAYER_CONTROLLED); - //e->control_force = 4500; //e->control_force = 1200; e->control_force = 250; e->control_torque = 10; @@ -234,6 +179,8 @@ INTERNAL void spawn_test_entities(f32 offset) e->angular_ground_friction = 100; //entity_enable_prop(e, ENTITY_PROP_TEST); + + player_ent = e; } /* Weapon */ @@ -259,7 +206,7 @@ INTERNAL void spawn_test_entities(f32 offset) } /* Box */ -#if 0 +#if 1 if (!G.first_spawn) { struct v2 pos = V2(0.5, -1); //struct v2 pos = V2(0.5, 29); @@ -628,7 +575,7 @@ INTERNAL struct soft_result make_soft(f32 hertz, f32 zeta, f32 h) INTERNAL void solve_collisions(f32 dt, b32 apply_bias) { -#if 0 +#if 1 struct entity_store *store = G.tick.entity_store; for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *manifold = &store->entities[entity_index]; @@ -1010,6 +957,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) struct sprite_sheet_slice slice = sprite_sheet_get_slice(sheet, STR("shape"), ent->animation_frame); ent->local_collider = collider_from_quad(xform_mul_quad(ent->sprite_local_xform, quad_from_rect(slice.rect))); +#if 0 //if (entity_has_prop(ent, ENTITY_PROP_PLAYER_CONTROLLED)) { if ((true)) { #if 0 @@ -1031,6 +979,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) ent->local_collider.radius = 0.25; #endif } +#endif } } @@ -1420,7 +1369,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) * Create ground friction force (gravity) * ========================== */ -#if 1 +#if 0 /* TODO: Do this globally rather than creating entities for constant forces */ for (u64 entity_index = 0; entity_index < store->reserved; ++entity_index) { struct entity *ent = &store->entities[entity_index]; @@ -1496,7 +1445,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) #endif solve_collisions(substep_dt, true); integrate_positions_from_velocities(substep_dt); - //solve_collisions(substep_dt, false); /* Relaxation */ + solve_collisions(substep_dt, false); /* Relaxation */ } } #else