mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Merge branch 'optimize-slope-z-positioning' into 'next'
Optimize Z position functions on sloped sectors See merge request STJr/SRB2!2214
This commit is contained in:
commit
cae7161b2e
3 changed files with 33 additions and 4 deletions
|
@ -1123,7 +1123,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
|
|||
testy += y;
|
||||
|
||||
// If the highest point is in the sector, then we have it easy! Just get the Z at that point
|
||||
if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
|
||||
if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy))
|
||||
return P_GetSlopeZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
|
@ -1200,7 +1200,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
|
|||
testy += y;
|
||||
|
||||
// If the highest point is in the sector, then we have it easy! Just get the Z at that point
|
||||
if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
|
||||
if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy))
|
||||
return P_GetSlopeZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
|
@ -1278,7 +1278,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
|
|||
testy += y;
|
||||
|
||||
// If the highest point is in the sector, then we have it easy! Just get the Z at that point
|
||||
if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
|
||||
if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy))
|
||||
return P_GetSlopeZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
|
@ -1355,7 +1355,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
|
|||
testy += y;
|
||||
|
||||
// If the highest point is in the sector, then we have it easy! Just get the Z at that point
|
||||
if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
|
||||
if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy))
|
||||
return P_GetSlopeZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
|
|
28
src/r_main.c
28
src/r_main.c
|
@ -1027,6 +1027,34 @@ void R_Init(void)
|
|||
framecount = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// R_IsPointInSector
|
||||
//
|
||||
boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y)
|
||||
{
|
||||
size_t i;
|
||||
line_t *closest = NULL;
|
||||
fixed_t closestdist = INT32_MAX;
|
||||
|
||||
for (i = 0; i < sector->linecount; i++)
|
||||
{
|
||||
vertex_t v;
|
||||
fixed_t dist;
|
||||
|
||||
// find the line closest to the point we're looking for.
|
||||
P_ClosestPointOnLine(x, y, sector->lines[i], &v);
|
||||
dist = R_PointToDist2(0, 0, v.x - x, v.y - y);
|
||||
if (dist < closestdist)
|
||||
{
|
||||
closest = sector->lines[i];
|
||||
closestdist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
// if the side of the closest line is in this sector, we're inside of it.
|
||||
return P_PointOnLineSide(x, y, closest) == 0 ? closest->frontsector == sector : closest->backsector == sector;
|
||||
}
|
||||
|
||||
//
|
||||
// R_PointInSubsector
|
||||
//
|
||||
|
|
|
@ -79,6 +79,7 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y);
|
|||
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
|
||||
|
||||
fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
|
||||
boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y);
|
||||
subsector_t *R_PointInSubsector(fixed_t x, fixed_t y);
|
||||
subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y);
|
||||
|
||||
|
|
Loading…
Reference in a new issue