]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_collision.c
detect bogus texture upload attempts and print the info to console
[xonotic/darkplaces.git] / cl_collision.c
index 1bc60f72a26ae88411683ccd7e507654d87179dd..8269bebbf22dbedddec4c5aef1952f39976507ea 100644 (file)
@@ -1,5 +1,6 @@
 
 #include "quakedef.h"
+#include "cl_collision.h"
 
 /*
 // not yet used
@@ -30,11 +31,16 @@ physentity_t;
 
 int cl_traceline_endcontents;
 
-float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels)
+float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels, entity_render_t **hitent)
 {
-       double maxfrac;
+       float maxfrac;
+       int n;
+       entity_render_t *ent;
+       float tracemins[3], tracemaxs[3];
        trace_t trace;
 
+       if (hitent)
+               *hitent = NULL;
        Mod_CheckLoaded(cl.worldmodel);
        Collision_ClipTrace(&trace, NULL, cl.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, start, vec3_origin, vec3_origin, end);
 
@@ -44,12 +50,11 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
                VectorCopy (trace.plane.normal, normal);
        cl_traceline_endcontents = trace.endcontents;
        maxfrac = trace.fraction;
+       if (hitent && trace.fraction < 1)
+               *hitent = &cl_entities[0].render;
 
        if (hitbmodels && cl_num_brushmodel_entities)
        {
-               int n;
-               entity_render_t *ent;
-               double tracemins[3], tracemaxs[3];
                tracemins[0] = min(start[0], end[0]);
                tracemaxs[0] = max(start[0], end[0]);
                tracemins[1] = min(start[1], end[1]);
@@ -76,9 +81,12 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
                                if (normal)
                                        VectorCopy(trace.plane.normal, normal);
                                cl_traceline_endcontents = trace.endcontents;
+                               if (hitent)
+                                       *hitent = ent;
                        }
                }
        }
+       if (maxfrac < 0 || maxfrac > 1) Con_Printf("fraction out of bounds %f %s:%d\n", maxfrac, __LINE__, __FILE__);
        return maxfrac;
 }