|
Quake Style - Quake 3 Tutorials Code Helpers - FindRadius for Quake 3 A useful function which will find entities around a certain object! |
// (NOBODY): Code helper function
//
gentity_t *findradius (gentity_t *from, vec3_t org, float rad)
{
vec3_t eorg;
int j;
if (!from)
from = g_entities;
else
from++;
for (; from < &g_entities[level.num_entities]; from++)
{
if (!from->inuse)
continue;
for (j=0; j<3; j++)
eorg[j] = org[j] - (from->r.currentOrigin[j] + (from->r.mins[j] + from->r.maxs[j])*0.5);
if (VectorLength(eorg) > rad)
continue;
return from;
}
return NULL;
}
gentity_t *findradius (gentity_t *from, vec3_t org, float rad);