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:10 +01:00
1 parent 69a593e09d
commit cd8f43fa47
4 files changed
+20 -16

No files matched your search

+1 -1
View File
@@ -9423,7 +9423,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
@@ -3366,7 +3366,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);
+13 -13
View File
@@ -299,17 +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
// cph - Made to use R_PointOnSide instead of P_DivlineSide, since the latter
// could return 2 which was ambigous, and the former is
// better optimised; also removes two casts :-)
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 = R_PointOnSide(los->strace.x, los->strace.y, bsp);
INT32 side2 = R_PointOnSide(los->t2x, los->t2y, 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)
{
@@ -319,13 +316,13 @@ 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
return false; // cross the starting side
}
else
{
bspnum = bsp->children[side ^ 1]; // cross the ending side
bspnum = bsp->children[side ^ 1]; // cross the ending side
}
}
}
@@ -339,16 +336,19 @@ 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;
los_t los;
// First check for trivial rejection.
if (P_MobjWasRemoved(t1) == true || P_MobjWasRemoved(t2) == true)
if (!t1 || !t2)
return false;
I_Assert(!P_MobjWasRemoved(t1));
I_Assert(!P_MobjWasRemoved(t2));
if (!t1->subsector || !t2->subsector
|| !t1->subsector->sector || !t2->subsector->sector)
return false;
@@ -453,5 +453,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));
}