fix incorrect contact point calculation

This commit is contained in:
jacob 2024-10-29 13:59:12 -05:00
parent d0089329e2
commit c966924760
2 changed files with 11 additions and 11 deletions

View File

@ -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 */
{

View File

@ -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"