We all know that Spring's current collision detection has issues. It's especially noticeable if you drag out a line of turrets right next to each other. The main problems as I see it
1. the "side buldges" you get with collisions spheres - especially bad for tall/thin units
2. for short units, the fact that the bounding sphere is way taller than the unit itself - especially bad for short + wide units.
On this thread: http://taspring.clan-sy.com/phpbb/viewt ... c&start=20
Firecrack suggested using cylinders. I think this is an excellent idea that would solve most of the problems with spheres without being hard to implement or processor intensive. Here's the meat of the idea:
The way I guess Spring does spherical collision detection is simply by asking "how close is projectile P from the position of unit U"? Each unit has a fixed size R. If the projectile is closer than R then it has hit that unit, if it is further than R then it hasn't. So the psuedo-code is:
Code: Select all
collision_detected = sqrt((x1 - x2)^2 + (y1 -y2)^2 + (z1 - z2)^2) < unit_size
Code: Select all
collision_detected = (sqrt((x1 - x2)^2 + (y1 - y2)^2) < unit_width)
AND (abs(z1 - z2) < unit_height);
One obvious issue with this is that it works well for buildings which are always upright, but what about mobile units which may be going up a hill etc.? It's true that the bounding cylinder is not perfect if the unit isn't on flat ground (or flying straight and level), but unless it's very steep ground it will still match the unit's actually shape better than a bounding sphere does. The problem with the sphere is, it makes no assumptions at all about which way the unit is facing -it caters for all possible orientations, including those which rarely or never happen, such as a unit lying on its side - this is true even for buildings! Assuming the unit is close to a "flat" orientation covers most cases, and even when the unit isn't flat, the mismatch is still fairly small.
I hope this helps. What do the devs think?
Munch
PS Caveat: I haven't looked at the current collision detection code, so I'm making some assumptions here!