Test consecutive slope movement
parent
b148a0458e
commit
5a0aa9e906
|
@ -91,7 +91,7 @@ void check_collision_and_move(struct Shape* shape, const struct TOIInfo* toi) {
|
||||||
Vector2DotProduct(
|
Vector2DotProduct(
|
||||||
normal,
|
normal,
|
||||||
Vector2Scale(shape->vel, 1.0-toi->toi)
|
Vector2Scale(shape->vel, 1.0-toi->toi)
|
||||||
) - 0.2)
|
) - 0.01)
|
||||||
);
|
);
|
||||||
shape->vel = Vector2Add(
|
shape->vel = Vector2Add(
|
||||||
shape->vel, nV
|
shape->vel, nV
|
||||||
|
@ -149,6 +149,26 @@ int main(void)
|
||||||
.colour = RED,
|
.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())
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
float frame_time = 1.0/60;
|
float frame_time = 1.0/60;
|
||||||
|
@ -187,6 +207,13 @@ int main(void)
|
||||||
|
|
||||||
// Actually need to order via TOI and resolve
|
// Actually need to order via TOI and resolve
|
||||||
// For each resolve, recheck TOI
|
// 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};
|
struct TOIInfo toi1 = {0};
|
||||||
toi1.toi = AABBToPolyTOI(
|
toi1.toi = AABBToPolyTOI(
|
||||||
Abox, (c2v){A.vel.x *frame_time, A.vel.y * frame_time},
|
Abox, (c2v){A.vel.x *frame_time, A.vel.y * frame_time},
|
||||||
|
@ -201,7 +228,7 @@ int main(void)
|
||||||
Dbox, (c2v){0,0},
|
Dbox, (c2v){0,0},
|
||||||
&toi2.normal, &toi2.contact
|
&toi2.normal, &toi2.contact
|
||||||
);
|
);
|
||||||
check_collision_and_move(&A, &toi2);
|
//check_collision_and_move(&A, &toi2);
|
||||||
|
|
||||||
struct TOIInfo toi0 = {0};
|
struct TOIInfo toi0 = {0};
|
||||||
toi0.toi = AABBToAABBTOI(
|
toi0.toi = AABBToAABBTOI(
|
||||||
|
@ -223,7 +250,8 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
DrawShape(&B);
|
DrawShape(&B);
|
||||||
DrawShape(&C);
|
DrawShape(&C);
|
||||||
DrawShape(&D);
|
//DrawShape(&D);
|
||||||
|
DrawShape(&E);
|
||||||
draw_toi_info(&toi0);
|
draw_toi_info(&toi0);
|
||||||
draw_toi_info(&toi1);
|
draw_toi_info(&toi1);
|
||||||
draw_toi_info(&toi2);
|
draw_toi_info(&toi2);
|
||||||
|
|
Loading…
Reference in New Issue