From c966924760a83b925cab25e88b4f5ec992cf68a7 Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 29 Oct 2024 13:59:12 -0500 Subject: [PATCH] fix incorrect contact point calculation --- src/game.c | 6 +++--- src/user.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/game.c b/src/game.c index 660beea9..0a3e7145 100644 --- a/src/game.c +++ b/src/game.c @@ -154,7 +154,7 @@ INTERNAL void spawn_test_entities(f32 offset) e->sprite = sprite_tag_from_path(STR("res/graphics/tim.ase")); } else { e->sprite = sprite_tag_from_path(STR("res/graphics/box.ase")); - size = V2(0.5, 0.5); + //size = V2(0.5, 0.5); } //e->sprite = sprite_tag_from_path(STR("res/graphics/box_rounded.ase")); @@ -593,8 +593,8 @@ INTERNAL void prepare_contacts(void) for (u32 i = 0; i < num_points; ++i) { struct contact_point *contact = &constraint->points[i]; - struct v2 vcp0 = v2_sub(xform_basis_mul_v2(e0_xf, contact->point_local_e0), e0_xf.og); - struct v2 vcp1 = v2_sub(xform_basis_mul_v2(e1_xf, contact->point_local_e1), e1_xf.og); + struct v2 vcp0 = v2_sub(xform_mul_v2(e0_xf, contact->point_local_e0), e0_xf.og); + struct v2 vcp1 = v2_sub(xform_mul_v2(e1_xf, contact->point_local_e1), e1_xf.og); /* Normal mass */ { diff --git a/src/user.c b/src/user.c index 21bf8eec..d15b38d5 100644 --- a/src/user.c +++ b/src/user.c @@ -1225,18 +1225,18 @@ INTERNAL void user_update(void) "num contacts: %F" ); struct string text = string_format(temp.arena, fmt, - FMT_SINT(ent->res.path), + FMT_SINT(data->res.path), FMT_UINT(e0->handle.idx), FMT_UINT(e1->handle.idx), - FMT_HEX(contact.id), - FMT_FLOAT_P(contact.normal_impulse, 3), - FMT_FLOAT_P(contact.tangent_impulse, 3), - FMT_FLOAT_P(contact.starting_separation, 6), - FMT_FLOAT_P(ent->manifold_normal.x, 6), FMT_FLOAT_P(ent->manifold_normal.y, 6), - FMT_UINT(ent->num_contacts)); + FMT_HEX(point.id), + FMT_FLOAT_P(point.normal_impulse, 3), + FMT_FLOAT_P(point.tangent_impulse, 3), + FMT_FLOAT_P(point.starting_separation, 6), + FMT_FLOAT_P(data->normal.x, 6), FMT_FLOAT_P(data->normal.y, 6), + FMT_UINT(data->num_points)); - draw_text(G.viewport_canvas, disp_font, v2_add(v2_round(xform_mul_v2(G.world_view, point)), V2(0, offset_px)), text); + draw_text(G.viewport_canvas, disp_font, v2_add(v2_round(xform_mul_v2(G.world_view, dbg_pt)), V2(0, offset_px)), text); #else struct string fmt = STR( "e0 index: %F\n"