Discussion Most efficient and practical way to do projectile on projectile collisions

Jesus4Lyf

Good Idea™
Reaction score
397
Not really, as each calculation has to be done only once per missile (for homing missiles x times with x being the amount of line segments).
That's my point.

>There is no way it can fail.
A bold statement for a game with teleport spells. If a missile heads straight for a unit, and just misses a linear missile along the way, and then the unit blinks back to the other side of the linear missile, it will be chance whether or not the homing missile hits the linear missile, based on whether or not it recalculates right then.

It's all a bit silly. The linear method actually assumes that nothing interacts with missiles. I've made a map that speeds up/slows down/freezes/pauses missiles in AoE's before. That would screw up linear missiles trajectory paths completely. Furthermore, they were all homing missiles. There is no doubt this would be a periodical O(n^2) solution! It is checking each missile against each other missile (without checking the reverse, so yes, n(n-1), which is still O(n^2)). Worse yet, the calculations are far more intensive than just range checks, everything needs to be recalculated at once when a spell interacts with them (lag!) and it still isn't as accurate as simple range checks.

On the other hand, that's an amazing idea for a map that only needs to handle the collision of linear projectiles. :)
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
That's my point.

>There is no way it can fail.
A bold statement for a game with teleport spells. If a missile heads straight for a unit, and just misses a linear missile along the way, and then the unit blinks back to the other side of the linear missile, it will be chance whether or not the homing missile hits the linear missile, based on whether or not it recalculates right then.
Well ... this is just settings and depends on the turning rate of your homing missiles. Having homing missiles that do change direction by 180 degrees instantly would look ugly anyways.
But I agree that the "linear overlay" of curved missile paths may have problems with teleportation if the current line doesn't get recalculated after the instant direction switch. However, this may really be the only case where it would really fail - compared to those MANY cases where periodic distance checks fail (low missile radii, high missile speeds, etc.).
It's all a bit silly. The linear method actually assumes that nothing interacts with missiles. I've made a map that speeds up/slows down/freezes/pauses missiles in AoE's before.
Well, you could always just recalculate the collision when the missile gets freezed/paused/unfreezed/whatever.

Furthermore, they were all homing missiles. There is no doubt this would be a periodical O(n^2) solution!
Yes, if all are homing missiles, then it really is O(n^2). Then, however, I do not really know how efficient enumeration on WC3 really is and it all depends on the update interval.
Then again, the algorythm is posted is far from being efficiently written. I think you could do the same with much less operations.

Worse yet, the calculations are far more intensive than just range checks, everything needs to be recalculated at once when a spell interacts with them (lag!)
Well, if only one missile gets freezed, you'd only need to compare one missile vs all, so it would 'only' be O(n) in this case.
and it still isn't as accurate as simple range checks.
This, however, is not true. The linear projection method is 100% accurate (if you recalculate it everytime there is a change in movement speed). For curved missile paths, it depends on the number of line segments, but I would still say that its a lot more accurate than periodic distance checks, which require large collision radi or high intervals in order to really have a dense and failure-proof checkpath.

On the other hand, that's an amazing idea for a map that only needs to handle the collision of linear projectiles. :)
Yes, I agree that it may not be suited for really flexible missile systems (especially if Kenny does not use periodic checks, but UnitEntersRect, which beats everything else in terms of speed), but the algorythm is still amazing if you ask me and may be used somewhere else, (I always wanted to create a pool minigame) where you need 100% exact collision coordinates (for example to create reflections, bouncing, or anything else that requires impulse laws of physic) for linear projectiles.

In fact, With UnitEntersRect or periodic distance checks, you can not do reflection at all. You NEED to use pre-calculation.
 

the Immortal

I know, I know...
Reaction score
51
Would anyone be interested in writing a periodic algorithm for collision checking with O(logn*n) complexity? Been studying different trees, including kd, for the last 2 weeks for classes, and wouldn't mind a small training.

.. if, from OP's words, a O(n*n) system could reach 100 w/o lag, using this method should be much faster, like up to 1k missiles w/o lag.


But will only do it if someone thinks it might be needed..
 

SerraAvenger

Cuz I can
Reaction score
234
periodic distance checks are n^2 too, aright?

UnitEntersRect has a loads of downsides... but since wc3 isn't processed concurrently it will work as long as everything a missile might get in contact with has such a rect too.

Because moving a rect somewhere doesn't fire the event for those units that are in the new area - at least IIRC.
 

the Immortal

I know, I know...
Reaction score
51
> periodic distance checks are n^2 too, aright?
Not necessarily. There exists a way to do it with n*logn (binary) complexity, but it's not that easy to write / optimize / balance the needed tree. Still, as I said I can give it a shot if someone's interested.
 

SerraAvenger

Cuz I can
Reaction score
234
> periodic distance checks are n^2 too, aright?
Not necessarily. There exists a way to do it with n*logn (binary) complexity, but it's not that easy to write / optimize / balance the needed tree. Still, as I said I can give it a shot if someone's interested.

I'd love to see the algorithm. +5 rep from me for sure if you do it.
 

the Immortal

I know, I know...
Reaction score
51
Will give it a shot when I have some free time then. But gotta think it over carefully first. A normal kd-tree wouldn't be approppriate as there's no effective/fast way to insert points and keep it balanced. A (simpler) qtree/bin might be better. Can't promise anything though. /slacker
 

Elfian

New Member
Reaction score
0
EDIT: Apff, never saw this thread was so f... old ;D

Code:
local integer i = 0
local integer k = 0

loop
   set i = i + 1
   set k = i

   loop
      set k = k + 1
      if(distance.. projectile[i], projectile[k] bla bla) then
          collision!!
      endif

      exitwhen k == MAX_OBJECTS
    endloop

    exitwhen i == MAX_OBJECTS
endloop

How about that? Did someone say that already? :^| By the way, what about making 200 recycleable projectiles from the initialization and registering to every one of them the event 'units gets in range', there was such an event right? :^|
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
How about that? Did someone say that already? :^|
That's O(n^2), which is about as unoptimal as possible. :p

By the way, what about making 200 recycleable projectiles from the initialization and registering to every one of them the event 'units gets in range', there was such an event right? :^|
I'm guessing you didn't read the thread... Not only was it suggested, but there was a discussion about why that would work poorly. :eek:
 
Reaction score
86
I made a qtree collision detection system in java for a different game. Implementation was needlessly annoying. took me 3 tries, and the 4th time i realized how simple it was. That was in java... A fully fledged programming language. It pains me to think of what it would be like to code in vJass.
 

emjlr3

Change can be a good thing
Reaction score
395
i know this is past due- but to add something to the discussion

somewhere, sometime ago, someone told me that groupenum was faster then a unitinrange event - though this is probably assuming small work loads (aka missile intersecting enemy targets, rather then 100 missile enumeration)

and from what has been stated before, it may just have been that unitinrange was slow to trigger, not a cpu intensive process
 
General chit-chat
Help Users
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top