optimizations to CL_SelectTraceLine to scan entity list faster
[xonotic/darkplaces.git] / cl_collision.c
index bc88832..c0725fa 100644 (file)
@@ -138,19 +138,16 @@ float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, ve
        // look for embedded bmodels
        for (n = 0;n < MAX_EDICTS;n++)
        {
-               if (!cl_entities[n].state_current.active)
+               if (!cl_entities_active[n])
                        continue;
                ent = &cl_entities[n].render;
+               if (!BoxesOverlap(ent->mins, ent->maxs, tracemins, tracemaxs))
+                       continue;
                if (!ent->model || !ent->model->TraceBox)
                        continue;
                // if transparent and not selectable, skip entity
                if (!(cl_entities[n].state_current.effects & EF_SELECTABLE) && (ent->alpha < 1 || (ent->effects & (EF_ADDITIVE | EF_NODEPTHTEST))))
                        continue;
-               if (ent->mins[0] > tracemaxs[0] || ent->maxs[0] < tracemins[0]
-                || ent->mins[1] > tracemaxs[1] || ent->maxs[1] < tracemins[1]
-                || ent->mins[2] > tracemaxs[2] || ent->maxs[2] < tracemins[2])
-                       continue;
-
                Matrix4x4_Transform(&ent->inversematrix, start, starttransformed);
                Matrix4x4_Transform(&ent->inversematrix, end, endtransformed);