• Advertisement

Archived

This topic is now archived and is closed to further replies.

Oriented 4 point convex shape collision response

This topic is 5149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Two dimensional oriented 4 point convex shape versus another collision response - I don''t use sweep tests, I check for collision every frame and act on that. My detection is fine, then I slapped on there elastic collision which works but it''s kind of buggy. What I imagine is happening (kind of hard to tell, but I''m pretty sure) is that the two ships collide, then their velocities are changed according to the elastic collision (no energy loss) equations, then in the next frame they start moving backwards but not quite ENOUGH, which means that they''re still inside each other, and then their velocities are changed AGAIN, at which point it goes crazy. The solution of course is to introduce offseting, so that the bodies are never actually inside each other when I apply elastic collision response. That way it''ll work perfectly, and that''s what I did with my planet (circle) to ships collision, which was fairly difficult but very doable. It works really cool when I remove the elastic collision (the ship just slides on the circle''s outer surface, very smooth). But how possible is it to introduce offseting when one oriented 4-point convex shaped collides with another one? For example:
----------------------
|                    |
|                    |
|            ________|________
----------------------       |
             |               |
             |               |
             _________________
That is pretty much the simplest case possible, because the shapes are axis aligned in this case AND they''re even regular quads (could be a trapeez, etc). But even in that case, how do I move each shape, in what direction, how much, and which one of them? Only one? Both? I guess it depends on a few more paramters. How possible is this? I had a different idea other than offseting where in the current frame I''d check if the shapes would collide in the next frame according to their current velocities and positions, and then simply not move them if the collision detection returned true. Only move the shapes if in the next frame they do NOT collide. But I''m not sure how well this idea would work, as sometimes it would be very visible... For example when I slap on elastic collision onto that system, then sometimes the bodies would start hurling backwards from each other when they still haven''t collided in the viewer''s eyes, see what I mean? So basically I''m trying to find out how possible is it to use offseting here?

Share this post


Link to post
Share on other sites
Advertisement
I know I prolly shouldn't bump, but I'm interested in what people have to say about this subject.

[edited by - Enokh on January 15, 2004 1:11:08 PM]

Share this post


Link to post
Share on other sites
ha, I misunderstood. you want oriented shapes. the way I test collisions is using separating axes. In case of a collision, this gives me an axis with the minimum overlap, then I can push the objects apart using that axis and depth of penetration. The normal also gives me a plane to bounce the objects against each other (reflect velocity).

on the other hand, if you know the objects collided, there is a good chance a point on one of the shapes if inside the other shape. In that case, get the segment on the other shape closest to the point and use it as your collision plane. If you have several points, use the point that provides the biggest collision depth.

If you don''t have a point inside the other shape, it means that the collision depth is very deep, and in that case, it would probably be better to refine the collision test (so you get at least one point), or just ignore it. You should really try to refine the collision reports, if the depth is too big anyway. Then you get a clean point.

B refining, I mean, backtrack the objects until the depth of intersection is not too big.

Share this post


Link to post
Share on other sites

  • Advertisement