optimized checksight for nametags and camera

idk should this be exposed to lua too?
This commit is contained in:
Alug committed 2024-12-08 15:26:40 +01:00
1 parent f7c7dae3a5
commit 3080f2953d
4 files changed
+13 -10

No files matched your search

+1 -1
View File
@@ -9118,7 +9118,7 @@ static void K_drawNameTags(void)
distance = R_PointToDist(players[i].mo->x, players[i].mo->y);
if (distance > maxdistance)
continue;
if (!P_CheckSight(stplyr->mo, players[i].mo))
if (!P_CheckSightFast(stplyr->mo, players[i].mo))
continue;
switch (cv_nametagtrans.value)
+5 -1
View File
@@ -364,7 +364,11 @@ boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z);
void P_SlideMove(mobj_t *mo, boolean forceslide);
void P_BouncePlayerMove(mobj_t *mo);
void P_BounceMove(mobj_t *mo);
boolean P_CheckSight(mobj_t *t1, mobj_t *t2);
#define P_CheckSight(t1, t2) P_CheckSight2(t1, t2, false)
#define P_CheckSightFast(t1, t2) P_CheckSight2(t1, t2, true)
boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast);
void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fixed_t radius);
boolean P_CheckSector(sector_t *sector, boolean crunch);
+1 -1
View File
@@ -3294,7 +3294,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
if (player->pflags & PF_TIMEOVER)
player->kartstuff[k_timeovercam] = (2*TICRATE)+1;
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
if (!resetcalled && !(player->pflags & PF_NOCLIP || leveltime < introtime) && !P_CheckSightFast(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead.
P_ResetCamera(player, thiscam);
else
P_SlideCameraMove(thiscam);
+6 -7
View File
@@ -299,15 +299,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los)
// if strace crosses the given node successfully.
//
// killough 4/20/98: rewritten to remove tail recursion, clean up, and optimize
static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast)
{
while (!(bspnum & NF_SUBSECTOR))
{
register node_t *bsp = nodes + bspnum;
INT32 side = P_DivlineSide(los->strace.x,los->strace.y,(divline_t *)bsp)&1;
INT32 side2 = P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp);
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);
if (side == side2)
{
@@ -316,7 +315,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
else
{
// the partition plane is crossed here
if (!P_CrossBSPNode(bsp->children[side], los))
if (!P_CrossBSPNode(bsp->children[side], los, fast))
{
return false; // cross the starting side
}
@@ -336,7 +335,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los)
// Returns true if a straight line between t1 and t2 is unobstructed.
// Uses REJECT.
//
boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast)
{
const sector_t *s1, *s2;
size_t pnum;
@@ -453,5 +452,5 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2)
}
// the head node is the last node output
return P_CrossBSPNode((INT32)numnodes - 1, &los);
return (P_CrossBSPNode((INT32)numnodes - 1, &los, fast));
}