• 🏆 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!

[JASS] Checking if point/region is ( partly) in region.

Status
Not open for further replies.

Ardenian

A

Ardenian

I currently create a dungeon generator and have the problem that I have to check for overlaps when creating dungeon rooms.

My current approach is to check if the edges and the center of a room are within another room, based on x and y values of the corresponding points.
However, this is quite odd to read and perform, the reason why I don't post a script,
also because there is still a possibility there is an undetected overlap.

Therefore I would like to know, what is the most efficient way to check if there is an overlap between two different regions ?
Now the problem comes: I initally don't have regions.

Each dungeon rooms has a clear defined edge at the top left. One can create all other locations of this room with that point.
I would like to create regions with two points, the top left edge and the bottom right one.

However, how do I transform these two points into a region and how do I check if two of these regions overlap ( saving each region of a dungeon room in a variable) ?
 

Ardenian

A

Ardenian

It is not about whether two regions have the same edge, but whether two regions share points.
 

Ardenian

A

Ardenian

Ahh, that's what I looked for, thank you! I don't even need regions in this case then, I guess.
 

Ardenian

A

Ardenian

Update: I feel a bit stupid, but I cannot get it to work.
From your link, edo494:
Code:
//If you have four coordinates – ((X,Y),(A,B)) and ((X1,Y1),(A1,B1)) – 
//rather than two plus width and height, it would look like this:

if (A<X1 or A1<X or B<Y1 or B1<Y):
    Intersection = Empty
else:
    Intersection = Not Empty

My rectangles are:
(x, y), ( x2, y2) and
(udg_RoomX[overlap],udg_RoomY[overlap]), (udg_RoomX[overlap]+128*udg_RoomBreadth[overlap],udg_RoomY[overlap]-128*udg_RoomLength[overlap])

The first (,) is the top left edge, the second (,) the bottom right edge.

So, the check has to be:
JASS:
if x2<udg_RoomX[overlap] or udg_RoomX[overlap]+128*udg_RoomBreadth[overlap]<x or y2<udg_RoomY[overlap] or udg_RoomY[overlap]-128*udg_RoomLength[overlap]<y then
    set overlapcheck = false // no overlap
else
    set overlapcheck = true // there is an intersection
endif

Is this correct ? Because it does not work.
 
Status
Not open for further replies.
Top