mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-03-12 22:01:31 +00:00
Fixed some problems with determining which sector a thing is in
This commit is contained in:
parent
3a4695ba92
commit
8648227423
1 changed files with 11 additions and 3 deletions
|
@ -542,7 +542,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
uint c = 0;
|
||||
Vector2D v1, v2;
|
||||
|
||||
bool selfreferencing = true;
|
||||
|
||||
// Go for all sidedefs
|
||||
foreach(Sidedef sd in sidedefs)
|
||||
{
|
||||
|
@ -553,6 +554,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. On top of a vertex?
|
||||
if(p == v1 || p == v2) return countontopastrue;
|
||||
|
||||
// If both sidedefs of any one line aren't referencing the same sector, then it's not a self-referencing sector
|
||||
if (sd.Other == null || (sd.Other != null && sd.Other.Sector != this))
|
||||
selfreferencing = false;
|
||||
|
||||
// Check for intersection
|
||||
if(v1.y != v2.y //mxd. If line is not horizontal...
|
||||
&& p.y > (v1.y < v2.y ? v1.y : v2.y) //mxd. ...And test point y intersects with the line y bounds...
|
||||
|
@ -562,8 +567,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
c++; //mxd. ...Count the line as crossed
|
||||
}
|
||||
|
||||
// Inside this polygon when we crossed odd number of polygon lines
|
||||
return (c % 2 != 0);
|
||||
// Inside this polygon when we crossed odd number of polygon lines (for non-self-referencing sectors)
|
||||
if (!selfreferencing)
|
||||
return (c % 2 != 0);
|
||||
else
|
||||
return (c % 2 == 0);
|
||||
}
|
||||
|
||||
// This creates a bounding box rectangle
|
||||
|
|
Loading…
Reference in a new issue