wonky: cache and reuse our testpoint subsector for sloped mobj z checks
its suprisingly common for the test coords to not change between calling those functions, so we can potentially save us alot of R_PointInSubsector calls Need to check for branch prediction slowdowns, but from some quick timedemoing, this speeds up things a bunch
This commit is contained in:
1 parent
2c9149d5ab
commit
e32f3de468
1 file changed
+18
-2
+18
-2
@@ -572,6 +572,8 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
|
||||
if (sector->f_slope)
|
||||
{
|
||||
fixed_t testx, testy;
|
||||
static fixed_t oldtestx = 0, oldtesty = 0;
|
||||
static subsector_t *subsec = NULL;
|
||||
pslope_t *slope = sector->f_slope;
|
||||
|
||||
// Get the corner of the object that should be the highest on the slope
|
||||
@@ -594,8 +596,14 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
|
||||
testx += x;
|
||||
testy += y;
|
||||
|
||||
if (oldtestx != testx || oldtesty != testy)
|
||||
subsec = R_PointInSubsector(testx, testy);
|
||||
|
||||
oldtestx = testx;
|
||||
oldtesty = testy;
|
||||
|
||||
// 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 (subsec->sector == (boundsec ? boundsec : sector))
|
||||
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
|
||||
@@ -659,6 +667,8 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
|
||||
if (sector->c_slope)
|
||||
{
|
||||
fixed_t testx, testy;
|
||||
static fixed_t oldtestx = 0, oldtesty = 0;
|
||||
static subsector_t *subsec = NULL;
|
||||
pslope_t *slope = sector->c_slope;
|
||||
|
||||
// Get the corner of the object that should be the highest on the slope
|
||||
@@ -681,8 +691,14 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
|
||||
testx += x;
|
||||
testy += y;
|
||||
|
||||
if (oldtestx != testx || oldtesty != testy)
|
||||
subsec = R_PointInSubsector(testx, testy);
|
||||
|
||||
oldtestx = testx;
|
||||
oldtesty = testy;
|
||||
|
||||
// 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 (subsec->sector == (boundsec ? boundsec : sector))
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user