by mlepage » Feb 24, 2004 @ 7:45pm
You have certainly hit upon exactly the problem you just described. Congratulations.
Personally, I'd look into augmenting your data structures with some additional info telling it the angles at places. For example, a polygon mesh.
What you are thinking of, is trying to figure out this extra data at runtime, when you have collided.
Instead, figure it out when you make your level, so it's just there when you collide.
Additionally, everyone seems obsessed about "pixel perfect" collisions. I wouldn't worry too much over it. What's the point of calculating the exact pixel, the exact angle of rebound, if you aren't also calculating the moment of inertia and rotational acceleration at the same time?
The point is, where does it end? Presumably the idea of being pixel perfect is to be more realistic. But it's not realistic to go flying off at another angle just because a pixel collided in a certain way, without spinning and friction and compression and doing other physics things. So if you can't be realistic anyways, don't worry about that extra pixel.
Just get something within a few pixels and you'll be fine. For example, say you have a ship that is mostly round. You can approximate it mathematically by a circle. Easy to calculate rebounds. It might be off by a pixel or two in some places, but it will be close enough and you will save a lot by not storing or calculating something more complicated.
Last edited by
mlepage on Feb 24, 2004 @ 7:50pm, edited 1 time in total.