readd R_PointInSubsectorFast
use it for camera, viewpoint, some precip and sound stuff and (visual) banana slope calc after profiling it a bit, this may be 2-4x faster in most cases
This commit is contained in:
1 parent
0b145123c0
commit
5040666f97
14 files changed
+32
-32
No files matched your search
+1
-1
@@ -2032,7 +2032,7 @@ static void CL_ReloadReceivedSavegame(void)
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
|
||||
camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y);
|
||||
}
|
||||
|
||||
cl_redownloadinggamestate = false;
|
||||
|
||||
@@ -3350,7 +3350,7 @@ static gl_vissprite_t *HWR_NewVisSprite(void)
|
||||
// Finds a floor through which light does not pass.
|
||||
static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
|
||||
{
|
||||
const sector_t *sec = R_PointInSubsector(x, y)->sector;
|
||||
const sector_t *sec = R_PointInSubsectorFast(x, y)->sector;
|
||||
fixed_t floorz = sec->floorheight;
|
||||
|
||||
if (sec->ffloors)
|
||||
|
||||
@@ -132,7 +132,7 @@ void HWR_PortalFrame(gl_portal_t* portal)
|
||||
{
|
||||
portalclipline = NULL;
|
||||
portalcullsector = NULL;
|
||||
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
||||
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4724,7 +4724,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z
|
||||
//sec = R_PointInSubsector(x, y)->sector;
|
||||
|
||||
if (mobj->x != x || mobj->y != y || mobj->subsector == NULL)
|
||||
sec = R_PointInSubsector(x, y)->sector;
|
||||
sec = R_PointInSubsectorFast(x, y)->sector;
|
||||
else
|
||||
sec = mobj->subsector->sector;
|
||||
|
||||
|
||||
+2
-2
@@ -1995,7 +1995,7 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
tmbbox[BOXLEFT] = x - thiscam->radius;
|
||||
|
||||
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
|
||||
newsubsec = R_PointInSubsector(x, y);
|
||||
newsubsec = R_PointInSubsectorFast(x, y);
|
||||
else
|
||||
newsubsec = thiscam->subsector;
|
||||
|
||||
@@ -2181,7 +2181,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
return false;
|
||||
|
||||
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
|
||||
s = R_PointInSubsector(x, y);
|
||||
s = R_PointInSubsectorFast(x, y);
|
||||
else
|
||||
s = thiscam->subsector;
|
||||
|
||||
|
||||
+1
-1
@@ -908,7 +908,7 @@ void P_SetUnderlayPosition(mobj_t *thing)
|
||||
|
||||
void P_SetPrecipitationThingPosition(precipmobj_t *thing)
|
||||
{
|
||||
thing->subsector = R_PointInSubsector(thing->x, thing->y);
|
||||
thing->subsector = R_PointInSubsectorFast(thing->x, thing->y);
|
||||
|
||||
// NOTE: this works because bnext/bprev are at the same
|
||||
// offsets in precipmobj_t and mobj_t
|
||||
|
||||
+4
-4
@@ -755,7 +755,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_PointInSubsectorFast(testx, testy)->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
|
||||
@@ -835,7 +835,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_PointInSubsectorFast(testx, testy)->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
|
||||
@@ -3331,7 +3331,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
|
||||
}
|
||||
}
|
||||
|
||||
thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y);
|
||||
thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y);
|
||||
thiscam->floorz = tmfloorz;
|
||||
thiscam->ceilingz = tmceilingz;
|
||||
|
||||
@@ -10456,7 +10456,7 @@ void P_PrecipitationEffects(void)
|
||||
for (y = yl; y <= yh; y += RADIUSSTEP)
|
||||
for (x = xl; x <= xh; x += RADIUSSTEP)
|
||||
{
|
||||
if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
|
||||
if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
|
||||
continue;
|
||||
|
||||
newdist = S_CalculateSoundDistance(pmo->x, pmo->y, 0, (fixed_t)x, (fixed_t)y, 0);
|
||||
|
||||
+2
-2
@@ -2507,7 +2507,6 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
|
||||
cam->y = players[pnum].mo->y;
|
||||
cam->z = players[pnum].mo->z;
|
||||
cam->angle = players[pnum].mo->angle;
|
||||
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2532,9 +2531,10 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
|
||||
cam->y = thing->y;
|
||||
cam->z = thing->z;
|
||||
cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
|
||||
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
|
||||
}
|
||||
|
||||
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
|
||||
|
||||
cam->chase = false; // tell camera to reset its position next tic
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2022,7 +2022,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
camera[i].y += y;
|
||||
camera[i].z += z;
|
||||
camera[i].reset = true;
|
||||
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
|
||||
camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y);
|
||||
R_RelativeTeleportViewInterpolation(i, x, y, z, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-3
@@ -3406,7 +3406,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num)
|
||||
}
|
||||
|
||||
// update subsector to avoid crashes;
|
||||
cam->subsector = R_PointInSubsector(cam->x, cam->y);
|
||||
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y);
|
||||
}
|
||||
|
||||
void P_ResetCamera(player_t *player, camera_t *thiscam)
|
||||
@@ -3450,7 +3450,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
|
||||
|
||||
thiscam->relativex = 0;
|
||||
|
||||
thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y);
|
||||
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
|
||||
|
||||
thiscam->radius = 20*FRACUNIT;
|
||||
thiscam->height = 16*FRACUNIT;
|
||||
@@ -3686,7 +3686,7 @@ static void P_MoveCameraToSpawn(UINT8 playernum)
|
||||
thiscam->angle = player->mo->angle;
|
||||
thiscam->aiming = 0;
|
||||
|
||||
thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y);
|
||||
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
|
||||
|
||||
thiscam->reset_aiming = true;
|
||||
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid)
|
||||
viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
|
||||
|
||||
viewplayer = newview->player;
|
||||
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
||||
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
|
||||
|
||||
R_SetupFreelook();
|
||||
}
|
||||
|
||||
+2
-4
@@ -579,8 +579,6 @@ static void R_InitTextureMapping(void)
|
||||
doubleclipangle = clipangle*2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// R_InitLightTables
|
||||
// Only inits the zlight table,
|
||||
@@ -1093,7 +1091,7 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector)
|
||||
if (sector != NULL)
|
||||
newview->sector = sector;
|
||||
else
|
||||
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
|
||||
newview->sector = R_PointInSubsectorFast(newview->x, newview->y)->sector;
|
||||
|
||||
R_InterpolateView(rendertimefrac_unpaused, false);
|
||||
}
|
||||
@@ -1333,7 +1331,7 @@ static void R_PortalFrame(portal_t *portal)
|
||||
{
|
||||
portalclipline = NULL;
|
||||
portalcullsector = NULL;
|
||||
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
||||
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-8
@@ -137,16 +137,18 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
|
||||
//
|
||||
// R_PointInSubsector
|
||||
//
|
||||
FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y)
|
||||
{
|
||||
size_t nodenum = numnodes-1;
|
||||
|
||||
while (!(nodenum & NF_SUBSECTOR))
|
||||
nodenum = nodes[nodenum].children[R_PointOnSide(x, y, nodes+nodenum)];
|
||||
|
||||
return &subsectors[nodenum & ~NF_SUBSECTOR];
|
||||
#define R_POINTINSUBSECTOR(FUNCNAME, SIDEFUNC)\
|
||||
FUNCINLINE static ATTRINLINE subsector_t *FUNCNAME(fixed_t x, fixed_t y)\
|
||||
{\
|
||||
size_t nodenum = numnodes-1;\
|
||||
while (!(nodenum & NF_SUBSECTOR))\
|
||||
nodenum = nodes[nodenum].children[SIDEFUNC(x, y, nodes+nodenum)];\
|
||||
return &subsectors[nodenum & ~NF_SUBSECTOR];\
|
||||
}
|
||||
|
||||
R_POINTINSUBSECTOR(R_PointInSubsector, R_PointOnSide)
|
||||
R_POINTINSUBSECTOR(R_PointInSubsectorFast, R_PointOnSideFast)
|
||||
|
||||
subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
|
||||
|
||||
#define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y)
|
||||
|
||||
+2
-2
@@ -961,7 +961,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
|
||||
INT64 x, y, yl, yh, xl, xh;
|
||||
fixed_t newdist;
|
||||
|
||||
if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
|
||||
if (R_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
|
||||
approx_dist = 0;
|
||||
else
|
||||
{
|
||||
@@ -974,7 +974,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
|
||||
for (y = yl; y <= yh; y += FRACUNIT*64)
|
||||
for (x = xl; x <= xh; x += FRACUNIT*64)
|
||||
{
|
||||
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)
|
||||
if (R_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum)
|
||||
{
|
||||
// Found the outdoors!
|
||||
newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0);
|
||||
|
||||
Reference in new issue
Block a user