• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

What do you think is the best collision detection method?

Status
Not open for further replies.
Phoenix fire, let me view your thoughts on what you think though guys.

I said phoenix fire because it already has its own buff/easy to detect combined with a damage detection system as well you don't have to enumerate through loops and groups and all that fun annoying stuff. You can just get right straight to the projectile impact/collision.

For every new projectile-like thing all you need is an extra ability and like 2-3 lines in the trigger editor. That is why I think phoenix fire is the supreme method out of all the collision methods found so far. It'd be nice to see a new physics fun map with this method too, like a remake of SEE then maybe we could see this in a RTS genre map.

Just my opinion though, I know everyone loves their loop through every specific unit to know exactly what's going on as well their unit group pickings. :thumbs_up:
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
That wouldn't support 3D collisions, now would it?
The fact that you, the user, only need very little effort, doesn't actually mean it's faster than code that takes many lines. It doesn't magically happen, the WC3 engine just calculates all the collisions for you (with loops, and group picking...)
While that would generally mean it should be faster, since the engine doesn't run on the slowpoke Jass, we all know how great WC3 code is...benchmarking is the only thing that would prove anything.

You don't have to loop over every unit in the world, you can partition the world, or use buckets, or use endless other methods that are used by every physics engine and every computer game in existence.

There isn't any "best" way to do anything, there are always tradeoffs, and what you'll choose depends on what your needs and constraints are.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Why phoenix fire when there is immolation?

Edit: I remember why object editor abilities wasn't being used, they can't detect locust units because locust units are invulnerable also.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Stack problem also occurs with phoenix fire right?With both spells you need to remove buff from damaged unit.Difference is phoenix uses missile whereas immolation instant.

About delay, shouldn't a low interval fix it?

I am not convinced about locust.
 
Level 6
Joined
Sep 18, 2013
Messages
79
I'm experimenting with my projectile system now. Immolation is sufficient for collision detection if there is no need in different projectile collision size and its speed isn't too high. I've set immolation radius to 30-40 and period to 0.05 and gave it to each "collide-able" unit. Immolation kills only "projectile" units, catch "projectile death" event and do custom damage to killing unit or to the units in the area. Disadvantage: no collisions with doodads.
 
Level 6
Joined
Sep 18, 2013
Messages
79
If you don't plan intensive usage of projectiles(< 10-15 per second) then use system which detects collision of every projectile enumerating units\doodads in collision radius. Such system is most accurate and flexible (still can "skip" collision on high speed ,it depends on interval of the processing timer)
 
Level 23
Joined
Jan 1, 2009
Messages
1,610
Well if you would look in the lab you can see I actually did y small snippet of this with phoenix fire.
By generating the abilities it is very easy to have dynamic range.
Also different timeouts.

http://www.hiveworkshop.com/forums/lab-715/collision-detection-using-phoenix-fire-253535/

This only doesn't work with locust units, but that's also the same with group enumerations.
But yea, since destructables have no onDamage event you can't really do it for that.

e:
The problem about both immolation and phoenix fire is that they can miss the target if both units cross each other too fast.

And it's exactly the same for any other method except the pre-calculation.
But when will you have a situation in a normal map where you got 2 or more missiles that go at constant or linear speed (i doubt you would find the intersection with a bezier curve) which are supposed to collide with each other?
Most use cases want collision with non-constant moving objects.
 
If you don't plan intensive usage of projectiles(< 10-15 per second) then use system which detects collision of every projectile enumerating units\doodads in collision radius. Such system is most accurate and flexible (still can "skip" collision on high speed ,it depends on interval of the processing timer)

Trying to go past this common usual method, thanks though.
 
Real World Example

In real-world game programming I use a system to separate the (infinite) game world into a grid, with each square in the grid being a cell where objects are added and removed from based on their location. This reduces the number of collision checks by a ton. Also another way to speed up calculation as well as increase accuracy to use SAT (separating axis theorem) on a unit's three shape collision geometry. This three-shape design is two circles which is the unit's collision radius, and a one quadrilateral between the unit's current and future (or past and current) location. This disallows 'flying through stuff', though more checks would have to be made to figure out the 'first' collision should multiple happen (though you might want to allow multiple collisions this way, for example; a ray representing a piercing bullet). If you are having issues with collisions at the edges of the cells then you'll have to figure out if a unit is in multiple cells and add them to them. Don't forget to remove them from the cells as well. You'll then have to toss out multiple collisions between the same two objects in the same frame.Getting this set up in JASS isn't easy, but using unit-entered and unit-left events makes it fairly easier. Objects that don't move (velocity of zero) would only have one shape in the collision geometry (a circle probably, though rectangles can be used as well, making good use as walls for terrain.) making calculations against destructables easier. It can easily be extended to fit your situation in a map by map basis. No uploadable system here will work as well (like no particle/projectile system works here), you'll have to make it fit your map.
 
Well if you would look in the lab you can see I actually did y small snippet of this with phoenix fire.
By generating the abilities it is very easy to have dynamic range.
Also different timeouts.

http://www.hiveworkshop.com/forums/lab-715/collision-detection-using-phoenix-fire-253535/

This only doesn't work with locust units, but that's also the same with group enumerations.
But yea, since destructables have no onDamage event you can't really do it for that.
I'm not even convinced that immolation or let alone phoenix fire are faster then periodic enumerations. They seem like pretty CPU intense abilities to me - and remember that abilities also create additional unwanted overhead (firing several events, if you run a damage detection engine then even more overhead is added). Plus buffs and debuffs are always delayed.
Before we praise phoenix fire as the holy grail of collision detection, someone HAS to run a benchmark first.

And it's exactly the same for any other method except the pre-calculation.
But when will you have a situation in a normal map where you got 2 or more missiles that go at constant or linear speed (i doubt you would find the intersection with a bezier curve) which are supposed to collide with each other?
Most use cases want collision with non-constant moving objects.
Depends on the map, really. But even at non-constant move rates it can be pre-calculated when doing the maths.
Doing the maths is imho the go-to approach for all non-homing missiles. The advantages are clear:
1) You run collision detection at O(n) complexity just once per missile, not periodically. Plus, it can be highly optimized by shortcut conditions.
2) The collision radius can be completely dynamic
3) The collision point is precise and deterministic and not just approximated with a precision depending on the period of enumerations/ability ticks
4) Collision detection performs flawlessly even for small, fast moving projectiles.

Btw, point 3) is a neccessity if you want to support reflective bullets. Any method approximating the intersection point will completely mess up reflection angles.


All in all, I think that periodic approaches (except for homing missiles) are just pure lazyness. Do the maths, it's totally worth it, both for performance reasons and for accuracy.
 
Level 23
Joined
Jan 1, 2009
Messages
1,610
In real-world game programming I use a system to separate the (infinite) game world into a grid, with each square in the grid being a cell where objects are added and removed from based on their location.
This is not applicable in wc3 because Jass is too slow (crigges and me did heavy benchmarking). Group enums are way faster in almost all cases.

Im not even convinced that immolation or let alone phoenix fire are faster then periodic enumerations. They seem like pretty CPU intense abilities to me - and remember that abilities also create additional unwanted overhead (firing several events, if you run a damage detection engine then even more overhead is added). Plus buffs and debuffs are always delayed.
Before we praise phoenix fire as the holy grail of collision detection, someone HAS to run a benchmark first.
With no art, zero missile speed (which means instant) i dont think there is too much overhead, but of course we have to test it.
I just said from a functionality standpoint it makes no problems and kari didnt tell me about fps drops.

How is buff/debuffing delayed and how does it matter?
The buff is instantly applied and removed again, you dont notice it ingame and i doubt removing an ability is much overheard.
You need damage detection for the collisions sherlock, but this is the point ofthe buff. It tells you if the last current damage event was triggered by phoenix fire or smth else.
Yes you have to add an if to that in your damageDetection, again not rly a problem.

e:
Depends on the map, really. But even at non-constant move rates it can be pre-calculated when doing the maths.
Doing the maths is imho the go-to approach for all non-homing missiles. The advantages are clear:
1) You run collision detection at O(n) complexity just once per missile, not periodically. Plus, it can be highly optimized by shortcut conditions.
2) The collision radius can be completely dynamic
3) The collision point is precise and deterministic and not just approximated with a precision depending on the period of enumerations/ability ticks
4) Collision detection performs flawlessly even for small, fast moving projectiles.

Btw, point 3) is a neccessity if you want to support reflective bullets. Any method approximating the intersection point will completely mess up reflection angles.

I said linear too, let's just keep it an static, since the missile is taking a static route. Of course it is possible for more to some degree, but except for very fast bullets, pointless.
Even in Warlock where missile-missile collision is used and many projectiles move at constant/linear speeds it's all destroyed by any gravity spell.
It's just not common and boring to have static missiles.
As I said, in any real map that is not a minigame, you need dynamic collision detection.
Missiles can be affected by other spells, terrain deformations, other forces like dynamic wind, values of the missiles can change during the travel, and then you would have to recalculate intersection point at every change, which is surely slower when having a bunch of missiles/collideable objects.
Then again you always have user interaction, which almost always involves moving a unit or something. and that unit usually should collide with the missiles.

to 3) the collision point would only be precise if you start another timer with the exact timeout, else it is obstructed by the animation period you are using.

4) small fast moving projectiles should be handled differently anyways, that's why popular physics engines have bullet modes or presets that use continuous collision detection.
That could also be done by simply interpolating the distance the bullet misses to check. This would pretty much be the only time where the pre calculation really is useful.

All in all, I think that periodic approaches (except for homing missiles) are just pure lazyness. Do the maths, it's totally worth it, both for performance reasons and for accuracy.

I highly doubt it, as stated before. Almost any map has units in them that move dynamically. Almost no map has missile-missile collision, and if it has (warlock, stygian, aim and evade) the missiles react to other dynamic forces, removing the purpose of pre calculation.
Even bullet deflection often has to be dynamic, e.g. if you can place shields/barricades during the flight of the missile. It is just not done with 1 calculation at start.
 
Last edited:
If you treat any possible interactions with a missile the same as a missile (by calculating possible intersections) you CAN have dynamic interactions with pre-calculations.
Things like a placable missile shield can be emulated just by having a bullet with the radius of the shield at zero speed. You don't even need a special algorithm for it, it's just using uncommon parameters.
A gravity field can always re-calculate the trajectories for the missiles it affects. At worst case scenario, you'll end up at the same efficiency as the periodic approach. If only one missile is outside the gravity field, the pre-calculation still wins.

Intersections with units have to be periodic. True. But the beauty about pre-calculation is, that it isn't exclusive to the periodic approach. And you can use it to narrow down likely collision cases beforehand to optimize speed before initiating the periodic check.

And even better: you can hard-limit the CPU load on the missile system. Imagine a situation with hundreds of missiles at the same time. With a system based on pre-calculation only running narrow-case enumerations on units, you can dynamically slow or fasten the periodic check interval for higher/lower accuracy to reduce computing stress. This avoids situations where the FPS drops a lot due to having lots of missiles to calculate.


Besides, how are you going to handle locust missiles? I highly doubt phoenix fire works on locust units. And you certainly don't want your missiles to have health bars or be targettable. Even the Hide/Locust bug does not make a unit untargetable with spells.
 
Level 6
Joined
Sep 18, 2013
Messages
79
Each of existing projectile systems has its flaws and still can be useful for some sort of maps... Whether projectile collision radius is small and colliding objects are rare - any simple system is suitable imo.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
If you don't plan intensive usage of projectiles(< 10-15 per second) then use system which detects collision of every projectile enumerating units\doodads in collision radius. Such system is most accurate and flexible (still can "skip" collision on high speed ,it depends on interval of the processing timer)

Pretty sure at least SEE uses continuous collision detection, so the speed doesn't matter.

It also worked perfectly smooth with hundreds of entities, as far as I remember, so your notion of "intensive usage" is simply wrong.

/Edit
Oh, there was another whole page filled with walls of text that I didn't notice, my bad.
 
Level 6
Joined
Sep 18, 2013
Messages
79
I suppose CCD works fine with static objects but with moving? Sure, moving object could be treated as static due to its low speed (relative to projectile) and then collision detection isn't perfectly accurate?
 
Status
Not open for further replies.
Top