Closed yuiwong closed 2 years ago
try the following case:
c2Poly poly; poly.verts[0] = c2V(2.0f, 39.0f); poly.verts[1] = c2V(2.0f, 40.0f); poly.verts[2] = c2V(1.0f, 40.0f); poly.verts[3] = c2V(1.0f, 39.0f); poly.count = 4; c2MakePoly(&poly); c2Circle circle; circle.p = c2V(2.34812546f,40.4136238f); circle.r = 0.5f; c2v v0 = c2V(0.0f, -0.106166691f); c2v v1 = c2V(0.0f, 0.0f); c2Manifold m0; c2Collide(&circle, 0, C2_TYPE_CIRCLE, &poly, 0, C2_TYPE_POLY, &m0); i32 iter; f32 t = c2TOI(&circle, C2_TYPE_CIRCLE, 0, v0, &poly, C2_TYPE_POLY, 0, v1, true, &iter); // advance circle circle.p = c2V(circle.p.x + v0.x * t, circle.p.y + v0.y * t); c2Manifold m1; c2Collide(&circle, 0, C2_TYPE_CIRCLE, &poly, 0, C2_TYPE_POLY, &m1); printf("before %d\n", m0.count); // output 0 printf("t:%f, iteration:%d\n", t, iter); // output t=1.0, iter=(a value that not make sense). printf("after %d\n", m1.count); // output 1
I debug the code and find that c2TOI() return while comparing (velocity_bound), so the 'iteration' is not filled.. Did I do something stupid?
Hi there! I haven't forgotten about this or anything -- Will have some time this week to take a good look.
Took me a while but I put out an updated version of c2TOI. Let me know if you have any problems!
try the following case:
I debug the code and find that c2TOI() return while comparing (velocity_bound), so the 'iteration' is not filled.. Did I do something stupid?