diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5d5c81b18..57725717f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -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; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 86643e1fb..dbbcec6c6 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -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) diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 909214171..db17d05bf 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_PointInSubsector(viewx, viewy)->sector; + viewsector = R_PointInSubsectorFast(viewx, viewy)->sector; } } diff --git a/src/k_kart.c b/src/k_kart.c index 2b65709c7..319675196 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -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; diff --git a/src/p_map.c b/src/p_map.c index 3b49ee38a..216b20bb7 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -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; diff --git a/src/p_maputl.c b/src/p_maputl.c index 7b748c22e..11e7a1050 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -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 diff --git a/src/p_mobj.c b/src/p_mobj.c index 07ceeac54..b4851d0de 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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); diff --git a/src/p_setup.c b/src/p_setup.c index 396925f8e..556f0e0cc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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 } diff --git a/src/p_spec.c b/src/p_spec.c index 1661117b8..5e7496870 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -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; } diff --git a/src/p_user.c b/src/p_user.c index 5d974b71b..e6057019f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -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; diff --git a/src/r_fps.c b/src/r_fps.c index b358eae71..b19834eed 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -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(); } diff --git a/src/r_main.cpp b/src/r_main.cpp index b2b5ed73f..f6144c64e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -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; } } diff --git a/src/r_main.h b/src/r_main.h index 2e27d6036..efe3fc31c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -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) diff --git a/src/s_sound.c b/src/s_sound.c index 5c49c4955..0a968caba 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -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);