• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Fill Irregilar Area?

Status
Not open for further replies.
Split your areas up into triangles, then use this:

JASS:
function IsPointInTriangle takes real x1, real y1, real x2, real y2, real x3, real y3, real x, real y returns boolean
     local boolean b = (x2 - x) * (y3 - y2) - (x3 - x2) * (y2 - y) >= .0
     return ((x1 - x) * (y2 - y1) - (x2 - x1) * (y1 - y) >= .0) == b and b == ((x3 - x) * (y1 - y3) - (x1 - x3) * (y3 - y) >= .0)
endfunction


Without any further information about what you want to do, there's not much we can do.
 
Level 7
Joined
Nov 18, 2012
Messages
272
1ilqw7.png


I want the red and the green farms gone, assuming that all farms are the same unit type, given only the coordinates of the red farms.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I want the red and the green farms gone, assuming that all farms are the same unit type, given only the coordinates of the red farms.
As mentioned you need to model the entire area as triangles composing only of vertices produced from the points (the red farms). You can then test if a farm is inside each of the triangles to get if it should be removed. The triangle grid will look very similar to the pathing mesh used by SC2 if you were to visualise it. Some complex tree system might allow you to discern which triangle a farm is in in logn time (n is number of triangles), which is pretty efficient given the complexity of the problem.

Another approach if you are only dealing with enclosed spaces (not the above) would be to model everything as tiles and then perform a fill brush operation on the area to generate a region (not rect, region (look at JASS)) consisting of all the area you want to check if something is in.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
No as you just run it in multiple threads in a chain. Would it cause frame drop? Maybe but then again fill operations usually do. For small areas it should be fine though since there are not that many cells to fill.

The fastest is still some form of area test with area made up of triangles from the points. The structure would need to be tiered so that you avoid O(n) based point in triangle tests. I do not know of such a structure off my head.
 
Status
Not open for further replies.
Top