2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Minor refactor ( add BoundsIntersect function ) (#986)

This commit is contained in:
Hamdi 2023-09-27 18:41:37 +01:00 committed by GitHub
parent 5ec8c29185
commit b7f6eb8023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 32 deletions

View File

@ -418,3 +418,12 @@ qboolean VectorCompare(const vec_t *v1, const vec_t *v2)
} }
#endif // #if !defined(REHLDS_SSE) #endif // #if !defined(REHLDS_SSE)
qboolean BoundsIntersect(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2)
{
if (mins1[0] > maxs2[0] || mins1[1] > maxs2[1] || mins1[2] > maxs2[2])
return FALSE;
if (maxs1[0] < mins2[0] || maxs1[1] < mins2[1] || maxs1[2] < mins2[2])
return FALSE;
return TRUE;
}

View File

@ -171,3 +171,4 @@ void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
NOBODY void FloorDivMod(double numer, double denom, int *quotient, int *rem); NOBODY void FloorDivMod(double numer, double denom, int *quotient, int *rem);
NOBODY int GreatestCommonDivisor(int i1, int i2); NOBODY int GreatestCommonDivisor(int i1, int i2);
NOBODY fixed16_t Invert24To16(fixed16_t val); NOBODY fixed16_t Invert24To16(fixed16_t val);
qboolean BoundsIntersect(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2);

View File

@ -525,7 +525,6 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
edict_t *check; edict_t *check;
int e; int e;
physent_t *ve; physent_t *ve;
int i;
link_t *next; link_t *next;
float *fmax; float *fmax;
float *fmin; float *fmin;
@ -588,13 +587,7 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs)
if (check->v.flags & FL_CLIENT) if (check->v.flags & FL_CLIENT)
SV_GetTrueMinMax(e - 1, &fmin, &fmax); SV_GetTrueMinMax(e - 1, &fmin, &fmax);
for (i = 0; i < 3; i++) if (!BoundsIntersect(pmove_mins, pmove_maxs, fmin, fmax))
{
if (fmin[i] > pmove_maxs[i] || fmax[i] < pmove_mins[i])
break;
}
if (i != 3)
continue; continue;
if (check->v.solid || check->v.skin != -16) if (check->v.solid || check->v.skin != -16)

View File

@ -359,12 +359,7 @@ void SV_TouchLinks(edict_t *ent, areanode_t *node)
if (touch->v.solid != SOLID_TRIGGER) if (touch->v.solid != SOLID_TRIGGER)
continue; continue;
if (ent->v.absmin[0] > touch->v.absmax[0] if (!BoundsIntersect(ent->v.absmin, ent->v.absmax, touch->v.absmin, touch->v.absmax))
|| ent->v.absmin[1] > touch->v.absmax[1]
|| ent->v.absmin[2] > touch->v.absmax[2]
|| ent->v.absmax[0] < touch->v.absmin[0]
|| ent->v.absmax[1] < touch->v.absmin[1]
|| ent->v.absmax[2] < touch->v.absmin[2])
continue; continue;
// check brush triggers accuracy // check brush triggers accuracy
@ -647,12 +642,7 @@ int SV_LinkContents(areanode_t *node, const vec_t *pos)
if (Mod_GetType(touch->v.modelindex) != mod_brush) if (Mod_GetType(touch->v.modelindex) != mod_brush)
continue; continue;
if (pos[0] > touch->v.absmax[0] if (!BoundsIntersect(pos, pos, touch->v.absmin, touch->v.absmax))
|| pos[1] > touch->v.absmax[1]
|| pos[2] > touch->v.absmax[2]
|| pos[0] < touch->v.absmin[0]
|| pos[1] < touch->v.absmin[1]
|| pos[2] < touch->v.absmin[2])
continue; continue;
int contents = touch->v.skin; int contents = touch->v.skin;
@ -1216,12 +1206,7 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip)
if (clip->ignoretrans && touch->v.rendermode != kRenderNormal && !(touch->v.flags & FL_WORLDBRUSH)) if (clip->ignoretrans && touch->v.rendermode != kRenderNormal && !(touch->v.flags & FL_WORLDBRUSH))
continue; continue;
if (clip->boxmins[0] > touch->v.absmax[0] if (!BoundsIntersect(clip->boxmins, clip->boxmaxs, touch->v.absmin, touch->v.absmax))
|| clip->boxmins[1] > touch->v.absmax[1]
|| clip->boxmins[2] > touch->v.absmax[2]
|| clip->boxmaxs[0] < touch->v.absmin[0]
|| clip->boxmaxs[1] < touch->v.absmin[1]
|| clip->boxmaxs[2] < touch->v.absmin[2])
continue; continue;
if (touch->v.solid != SOLID_SLIDEBOX if (touch->v.solid != SOLID_SLIDEBOX
@ -1310,12 +1295,7 @@ void SV_ClipToWorldbrush(areanode_t *node, moveclip_t *clip)
if (!(touch->v.flags & FL_WORLDBRUSH)) if (!(touch->v.flags & FL_WORLDBRUSH))
continue; continue;
if (clip->boxmins[0] > touch->v.absmax[0] if (!BoundsIntersect(clip->boxmins, clip->boxmaxs, touch->v.absmin, touch->v.absmax))
|| clip->boxmins[1] > touch->v.absmax[1]
|| clip->boxmins[2] > touch->v.absmax[2]
|| clip->boxmaxs[0] < touch->v.absmin[0]
|| clip->boxmaxs[1] < touch->v.absmin[1]
|| clip->boxmaxs[2] < touch->v.absmin[2])
continue; continue;
if (clip->trace.allsolid) if (clip->trace.allsolid)