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

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. :)
 
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.
 
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..
 
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.
 
> 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.
 
> 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.
 
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
 
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? :^|
 
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:
 
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.
 
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
  • No one is chatting at the moment.
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)
  • The Helper The Helper:
    It will only be on internal network

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top