From b2097e2f93921dbb061f7ed6c79c7ff76dcadd2c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jan 2025 21:50:02 +0100 Subject: [PATCH] apparently this is slower for everything but rendering --- src/d_clisrv.c | 2 +- src/hardware/hw_main.c | 2 +- src/hardware/hw_portal.c | 2 +- src/p_map.c | 4 ++-- src/p_mobj.c | 4 ++-- src/p_setup.c | 4 ++-- src/p_sight.c | 4 ++-- src/p_user.c | 4 ++-- src/r_fps.c | 2 +- src/r_main.h | 15 +-------------- src/s_sound.c | 4 ++-- 11 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 457dbe251..54df3af04 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2008,7 +2008,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y); + camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); } cl_redownloadinggamestate = false; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fe70914b7..87d4d046a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3210,7 +3210,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_PointInSubsectorFast(x, y)->sector; + const sector_t *sec = R_PointInSubsector(x, y)->sector; fixed_t floorz = sec->floorheight; if (sec->ffloors) diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index f26e71331..27d77af2e 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -132,7 +132,7 @@ void HWR_PortalFrame(gl_portal_t* portal) { portalclipline = NULL; portalcullsector = NULL; - viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; + viewsector = R_PointInSubsector(viewx, viewy)->sector; } } diff --git a/src/p_map.c b/src/p_map.c index 73522b6fa..707ef26b0 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2004,7 +2004,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_PointInSubsectorFast(x, y); + newsubsec = R_PointInSubsector(x, y); else newsubsec = thiscam->subsector; @@ -2191,7 +2191,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_PointInSubsectorFast(x, y); + s = R_PointInSubsector(x, y); else s = thiscam->subsector; diff --git a/src/p_mobj.c b/src/p_mobj.c index 336b9adef..8d728c389 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3348,7 +3348,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled if (!itsatwodlevel) P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); - thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); + thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; thiscam->ceilingz = tmceilingz; @@ -10426,7 +10426,7 @@ void P_PrecipitationEffects(void) for (y = yl; y <= yh; y += RADIUSSTEP) for (x = xl; x <= xh; x += RADIUSSTEP) { - if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! + if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0); diff --git a/src/p_setup.c b/src/p_setup.c index 65393f412..2f730fdec 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2498,7 +2498,7 @@ 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_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) + cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } else { @@ -2523,7 +2523,7 @@ 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_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) + cam->subsector = R_PointInSubsector(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 diff --git a/src/p_sight.c b/src/p_sight.c index 862b98e03..5f31df827 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -305,8 +305,8 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { register node_t *bsp = nodes + bspnum; - INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1)); - INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); + INT32 side = (fast ? R_PointOnSide(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x,los->strace.y, (divline_t *)bsp) & 1)); + INT32 side2 = (fast ? R_PointOnSide(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); if (side == side2) { diff --git a/src/p_user.c b/src/p_user.c index 5d025e9a4..07a66075a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3421,7 +3421,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // update subsector to avoid crashes; - cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); + cam->subsector = R_PointInSubsector(cam->x, cam->y); } #undef intsign @@ -3465,7 +3465,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->relativex = 0; - thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y); + thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y); thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; diff --git a/src/r_fps.c b/src/r_fps.c index b861dea56..92eb37a32 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -198,7 +198,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); viewplayer = newview->player; - viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; + viewsector = R_PointInSubsector(viewx, viewy)->sector; R_SetupFreelook(); } diff --git a/src/r_main.h b/src/r_main.h index b8aae6d56..a3938fd0a 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -182,18 +182,6 @@ FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t return &subsectors[nodenum & ~NF_SUBSECTOR]; } -// uses R_PointOnSideFast -// SHOULD NOT BE USED FOR ANYTHING GAMEPLAY RELATED!! -FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsectorFast(fixed_t x, fixed_t y) -{ - size_t nodenum = numnodes-1; - - while (!(nodenum & NF_SUBSECTOR)) - nodenum = nodes[nodenum].children[R_PointOnSideFast(x, y, nodes+nodenum)]; - - return &subsectors[nodenum & ~NF_SUBSECTOR]; -} - // // R_IsPointInSubsector, same as above but returns 0 if not in subsector // @@ -209,8 +197,7 @@ FUNCINLINE static ATTRINLINE subsector_t *R_IsPointInSubsector(fixed_t x, fixed_ while (!(nodenum & NF_SUBSECTOR)) { node = &nodes[nodenum]; - //side = R_PointOnSide(x, y, node); - side = R_PointOnSideFast(x, y, node); // this is fine since R_IsPointInSubsector is only used for precip spawn unless you disable noclipcam lol + side = R_PointOnSide(x, y, node); nodenum = node->children[side]; } diff --git a/src/s_sound.c b/src/s_sound.c index aa2a1a773..58146d1a8 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -955,7 +955,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_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) approx_dist = 0; else { @@ -968,7 +968,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_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum) + if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) { // Found the outdoors! newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0);