Merge branch 'fix-slope-convex-sectors' into 'next'
Fix physics quirkiness on slopes with convex sectors See merge request STJr/SRB2!2250
This commit is contained in:
parent
5681f5b803
commit
76022b40bf
1 changed files with 45 additions and 0 deletions
|
|
@ -1095,6 +1095,51 @@ void R_Init(void)
|
|||
framecount = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// R_IsPointInSector
|
||||
//
|
||||
boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y)
|
||||
{
|
||||
size_t i;
|
||||
size_t passes = 0;
|
||||
|
||||
for (i = 0; i < sector->linecount; i++)
|
||||
{
|
||||
line_t *line = sector->lines[i];
|
||||
vertex_t *v1, *v2;
|
||||
|
||||
if (line->frontsector == line->backsector)
|
||||
continue;
|
||||
|
||||
v1 = line->v1;
|
||||
v2 = line->v2;
|
||||
|
||||
// make sure v1 is below v2
|
||||
if (v1->y > v2->y)
|
||||
{
|
||||
vertex_t *tmp = v1;
|
||||
v1 = v2;
|
||||
v2 = tmp;
|
||||
}
|
||||
else if (v1->y == v2->y)
|
||||
// horizontal line, we can't match this
|
||||
continue;
|
||||
|
||||
if (v1->y < y && y <= v2->y)
|
||||
{
|
||||
// if the y axis in inside the line, find the point where we intersect on the x axis...
|
||||
fixed_t vx = v1->x + (INT64)(v2->x - v1->x) * (y - v1->y) / (v2->y - v1->y);
|
||||
|
||||
// ...and if that point is to the left of the point, count it as inside.
|
||||
if (vx < x)
|
||||
passes++;
|
||||
}
|
||||
}
|
||||
|
||||
// and odd number of passes means we're inside the polygon.
|
||||
return passes % 2;
|
||||
}
|
||||
|
||||
//
|
||||
// R_PointInSubsector
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in a new issue