Lots of speedups and cleanups in client code, dynamically allocated cl_entities ...
[xonotic/darkplaces.git] / cl_collision.c
index ea667b6..6457fbf 100644 (file)
@@ -28,48 +28,6 @@ typedef struct physentity_s
 physentity_t;
 */
 
-static entity_render_t *traceline_entity[MAX_EDICTS];
-static int traceline_entities;
-
-// builds list of entities for TraceLine to check later
-void CL_TraceLine_ScanForBModels(void)
-{
-       int i;
-       entity_render_t *ent;
-       model_t *model;
-       traceline_entities = 0;
-       for (i = 1;i < MAX_EDICTS;i++)
-       {
-               ent = &cl_entities[i].render;
-               model = ent->model;
-               // look for embedded brush models only
-               if (model && model->name[0] == '*')
-               {
-                       if (model->type == mod_brush)
-                       {
-                               traceline_entity[traceline_entities++] = ent;
-                               if (ent->angles[0] || ent->angles[2])
-                               {
-                                       // pitch or roll
-                                       VectorAdd(ent->origin, model->rotatedmins, ent->mins);
-                                       VectorAdd(ent->origin, model->rotatedmaxs, ent->maxs);
-                               }
-                               else if (ent->angles[1])
-                               {
-                                       // yaw
-                                       VectorAdd(ent->origin, model->yawmins, ent->mins);
-                                       VectorAdd(ent->origin, model->yawmaxs, ent->maxs);
-                               }
-                               else
-                               {
-                                       VectorAdd(ent->origin, model->normalmins, ent->mins);
-                                       VectorAdd(ent->origin, model->normalmaxs, ent->maxs);
-                               }
-                       }
-               }
-       }
-}
-
 int cl_traceline_endcontents;
 
 float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels)
@@ -87,7 +45,7 @@ float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int
        cl_traceline_endcontents = trace.endcontents;
        maxfrac = trace.fraction;
 
-       if (hitbmodels && traceline_entities)
+       if (hitbmodels && cl_num_brushmodel_entities)
        {
                int n;
                entity_render_t *ent;
@@ -100,9 +58,9 @@ float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int
                tracemaxs[2] = max(start[2], end[2]);
 
                // look for embedded bmodels
-               for (n = 0;n < traceline_entities;n++)
+               for (n = 0;n < cl_num_brushmodel_entities;n++)
                {
-                       ent = traceline_entity[n];
+                       ent = cl_brushmodel_entities[n];
                        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])