Reapply "optimize z position checking for mobjs without collision and camera"
This reverts commit 0dca45ca6c.
This commit is contained in:
1 parent
740eb5d860
commit
426dd1489a
3 files changed
+50
-4
No files matched your search
+4
-4
@@ -618,7 +618,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 (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
|
||||
return P_GetZAt(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
|
||||
@@ -695,7 +695,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 (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
|
||||
return P_GetZAt(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
|
||||
@@ -774,7 +774,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_GetZAt(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
|
||||
@@ -852,7 +852,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_GetZAt(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
|
||||
|
||||
@@ -1031,6 +1031,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_SetupFrame
|
||||
//
|
||||
|
||||
@@ -122,6 +122,7 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
|
||||
angle_t R_PlayerSliptideAngle(player_t *player);
|
||||
|
||||
fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
|
||||
boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y);
|
||||
|
||||
//
|
||||
// R_PointInSubsector
|
||||
|
||||
Reference in new issue
Block a user