diff --git a/engine/tests/geometry/samples/collision_sample2.c b/engine/tests/geometry/samples/collision_sample2.c index 196b2f7..dd41a37 100644 --- a/engine/tests/geometry/samples/collision_sample2.c +++ b/engine/tests/geometry/samples/collision_sample2.c @@ -91,7 +91,7 @@ void check_collision_and_move(struct Shape* shape, const struct TOIInfo* toi) { Vector2DotProduct( normal, Vector2Scale(shape->vel, 1.0-toi->toi) - ) - 0.2) + ) - 0.01) ); shape->vel = Vector2Add( shape->vel, nV @@ -149,6 +149,26 @@ int main(void) .colour = RED, }; + Shape E = { + .pos = {427,219}, + .center = {349,217.666}, + .type = C2_TYPE_POLY, + .shape.poly = { + .count = 3, + .verts = { + {0,0}, + {100, -50}, + {100,0}, + }, + }, + .colour = RED, + }; + c2MakePoly(&E.shape.poly); + for (int i = 0; i < E.shape.poly.count; ++i) { + E.shape.poly.verts[i].x += E.pos.x; + E.shape.poly.verts[i].y += E.pos.y; + } + while (!WindowShouldClose()) { float frame_time = 1.0/60; @@ -187,6 +207,13 @@ int main(void) // Actually need to order via TOI and resolve // For each resolve, recheck TOI + struct TOIInfo toi4 = {0}; + toi4.toi = AABBToPolyTOI( + Abox, (c2v){A.vel.x *frame_time, A.vel.y * frame_time}, + &E.shape.poly, NULL, (c2v){0,0}, + &toi4.normal, &toi4.contact + ); + check_collision_and_move(&A, &toi4); struct TOIInfo toi1 = {0}; toi1.toi = AABBToPolyTOI( Abox, (c2v){A.vel.x *frame_time, A.vel.y * frame_time}, @@ -201,7 +228,7 @@ int main(void) Dbox, (c2v){0,0}, &toi2.normal, &toi2.contact ); - check_collision_and_move(&A, &toi2); + //check_collision_and_move(&A, &toi2); struct TOIInfo toi0 = {0}; toi0.toi = AABBToAABBTOI( @@ -223,7 +250,8 @@ int main(void) ClearBackground(RAYWHITE); DrawShape(&B); DrawShape(&C); - DrawShape(&D); + //DrawShape(&D); + DrawShape(&E); draw_toi_info(&toi0); draw_toi_info(&toi1); draw_toi_info(&toi2);