]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - collision.c
Improved sound resampling. It can handle sounds up to 96KHz stereo at a constant...
[xonotic/darkplaces.git] / collision.c
index 983dc09f490a3287cb1626eb496adb2408cdec0a..35e13d4e1542e70683e8c3fc032ec62b75ad064b 100644 (file)
@@ -71,7 +71,7 @@ loc0:
                        if (t->trace->allsolid)
                                t->trace->startsolid = true;
 #if COLLISIONPARANOID >= 3
-                       Con_Printf("S");
+                       Con_Print("S");
 #endif
                        return HULLCHECKSTATE_SOLID;
                }
@@ -79,7 +79,7 @@ loc0:
                {
                        t->trace->allsolid = false;
 #if COLLISIONPARANOID >= 3
-                       Con_Printf("E");
+                       Con_Print("E");
 #endif
                        return HULLCHECKSTATE_EMPTY;
                }
@@ -105,7 +105,7 @@ loc0:
                if (t2 < 0)
                {
 #if COLLISIONPARANOID >= 3
-                       Con_Printf("<");
+                       Con_Print("<");
 #endif
                        num = node->children[1];
                        goto loc0;
@@ -117,7 +117,7 @@ loc0:
                if (t2 >= 0)
                {
 #if COLLISIONPARANOID >= 3
-                       Con_Printf(">");
+                       Con_Print(">");
 #endif
                        num = node->children[0];
                        goto loc0;
@@ -128,7 +128,7 @@ loc0:
        // the line intersects, find intersection point
        // LordHavoc: this uses the original trace for maximum accuracy
 #if COLLISIONPARANOID >= 3
-       Con_Printf("M");
+       Con_Print("M");
 #endif
        if (plane->type < 3)
        {
@@ -179,7 +179,7 @@ loc0:
        t->trace->fraction = bound(0, midf, 1);
 
 #if COLLISIONPARANOID >= 3
-       Con_Printf("D");
+       Con_Print("D");
 #endif
        return HULLCHECKSTATE_DONE;
 }
@@ -333,14 +333,14 @@ void Collision_ValidateBrush(colbrushf_t *brush)
        printbrush = false;
        if (!brush->numpoints)
        {
-               Con_Printf("Collision_ValidateBrush: brush with no points!\n");
+               Con_Print("Collision_ValidateBrush: brush with no points!\n");
                printbrush = true;
        }
 #if 0
        // it's ok for a brush to have one point and no planes...
        if (brush->numplanes == 0 && brush->numpoints != 1)
        {
-               Con_Printf("Collision_ValidateBrush: brush with no planes and more than one point!\n");
+               Con_Print("Collision_ValidateBrush: brush with no planes and more than one point!\n");
                printbrush = true;
        }
 #endif
@@ -365,7 +365,7 @@ void Collision_ValidateBrush(colbrushf_t *brush)
                }
                if (pointsoffplanes == 0) // all points are on all planes
                {
-                       Con_Printf("Collision_ValidateBrush: all points lie on all planes (degenerate, no brush volume!)\n");
+                       Con_Print("Collision_ValidateBrush: all points lie on all planes (degenerate, no brush volume!)\n");
                        printbrush = true;
                }
        }
@@ -432,7 +432,7 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
                // check if there are too many and skip the brush
                if (numplanes >= 256)
                {
-                       Con_Printf("Mod_Q3BSP_LoadBrushes: failed to build collision brush: too many planes for buffer\n");
+                       Con_Print("Mod_Q3BSP_LoadBrushes: failed to build collision brush: too many planes for buffer\n");
                        return NULL;
                }
 
@@ -463,14 +463,14 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
                // check if there are too many polygon vertices for buffer
                if (numpolypoints > maxpolypoints)
                {
-                       Con_Printf("Collision_NewBrushFromPlanes: failed to build collision brush: too many points for buffer\n");
+                       Con_Print("Collision_NewBrushFromPlanes: failed to build collision brush: too many points for buffer\n");
                        return NULL;
                }
 
                // check if there are too many triangle elements for buffer
                if (numelements + (w->numpoints - 2) * 3 > maxelements)
                {
-                       Con_Printf("Collision_NewBrushFromPlanes: failed to build collision brush: too many triangle elements for buffer\n");
+                       Con_Print("Collision_NewBrushFromPlanes: failed to build collision brush: too many triangle elements for buffer\n");
                        return NULL;
                }
 
@@ -487,7 +487,7 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla
                                // check if there are too many and skip the brush
                                if (numpoints >= 256)
                                {
-                                       Con_Printf("Collision_NewBrushFromPlanes: failed to build collision brush: too many points for buffer\n");
+                                       Con_Print("Collision_NewBrushFromPlanes: failed to build collision brush: too many points for buffer\n");
                                        Winding_Free(w);
                                        return NULL;
                                }
@@ -571,7 +571,7 @@ colbrushf_t *Collision_AllocBrushFloat(mempool_t *mempool, int numpoints, int nu
 void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush)
 {
        int i;
-       float edge0[3], edge1[3], edge2[3], normal[3], dist, bestdist, temp[3];
+       float edge0[3], edge1[3], edge2[3], normal[3], dist, bestdist;
        colpointf_t *p, *p2;
 
        if (brush->numpoints == 3)
@@ -640,9 +640,12 @@ void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush)
                        if (developer.integer)
                        {
                                // validation code
+#if 0
+                               float temp[3];
+
                                VectorSubtract(brush->points[0].v, brush->points[1].v, edge0);
                                VectorSubtract(brush->points[2].v, brush->points[1].v, edge1);
-                               CrossProduct(edge1, edge0, normal);
+                               CrossProduct(edge0, edge1, normal);
                                VectorNormalize(normal);
                                VectorSubtract(normal, brush->planes[0].normal, temp);
                                if (VectorLength(temp) > 0.01f)
@@ -662,6 +665,7 @@ void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush)
                                        Con_Printf("Collision_CalcPlanesForPolygonBrushFloat: plane 3 (%f %f %f %f) is not perpendicular to edge 1 (%f %f %f to %f %f %f)\n", brush->planes[3].normal[0], brush->planes[3].normal[1], brush->planes[3].normal[2], brush->planes[3].dist, brush->points[0].v[0], brush->points[0].v[1], brush->points[0].v[2], brush->points[1].v[0], brush->points[1].v[1], brush->points[1].v[2]);
                                if (fabs(DotProduct(brush->planes[4].normal, edge2)) > 0.01f)
                                        Con_Printf("Collision_CalcPlanesForPolygonBrushFloat: plane 4 (%f %f %f %f) is not perpendicular to edge 2 (%f %f %f to %f %f %f)\n", brush->planes[4].normal[0], brush->planes[4].normal[1], brush->planes[4].normal[2], brush->planes[4].dist, brush->points[1].v[0], brush->points[1].v[1], brush->points[1].v[2], brush->points[2].v[0], brush->points[2].v[1], brush->points[2].v[2]);
+#endif
 #endif
                                if (fabs(DotProduct(brush->points[0].v, brush->planes[0].normal) - brush->planes[0].dist) > 0.01f || fabs(DotProduct(brush->points[1].v, brush->planes[0].normal) - brush->planes[0].dist) > 0.01f || fabs(DotProduct(brush->points[2].v, brush->planes[0].normal) - brush->planes[0].dist) > 0.01f)
                                        Con_Printf("Collision_CalcPlanesForPolygonBrushFloat: edges (%f %f %f to %f %f %f to %f %f %f) off front plane 0 (%f %f %f %f)\n", brush->points[0].v[0], brush->points[0].v[1], brush->points[0].v[2], brush->points[1].v[0], brush->points[1].v[1], brush->points[1].v[2], brush->points[2].v[0], brush->points[2].v[1], brush->points[2].v[2], brush->planes[0].normal[0], brush->planes[0].normal[1], brush->planes[0].normal[2], brush->planes[0].dist);
@@ -771,7 +775,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                                // any brush with degenerate planes is not worth handling
                                if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f)
                                {
-                                       Con_Printf("Collision_TraceBrushBrushFloat: degenerate thisbrush plane!\n");
+                                       Con_Print("Collision_TraceBrushBrushFloat: degenerate thisbrush plane!\n");
                                        return;
                                }
                                f = furthestplanedist_float(startplane->normal, thisbrush_start->points, thisbrush_start->numpoints);
@@ -790,7 +794,7 @@ void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush
                                // any brush with degenerate planes is not worth handling
                                if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f)
                                {
-                                       Con_Printf("Collision_TraceBrushBrushFloat: degenerate thatbrush plane!\n");
+                                       Con_Print("Collision_TraceBrushBrushFloat: degenerate thatbrush plane!\n");
                                        return;
                                }
                                f = furthestplanedist_float(startplane->normal, thatbrush_start->points, thatbrush_start->numpoints);
@@ -917,7 +921,7 @@ void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const
                        // any brush with degenerate planes is not worth handling
                        if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f)
                        {
-                               Con_Printf("Collision_TraceLineBrushFloat: degenerate plane!\n");
+                               Con_Print("Collision_TraceLineBrushFloat: degenerate plane!\n");
                                return;
                        }
                        if (thatbrush_start->numpoints)
@@ -1045,7 +1049,7 @@ void Collision_TraceBrushPolygonFloat(trace_t *trace, const colbrushf_t *thisbru
 {
        if (numpoints > 256)
        {
-               Con_Printf("Polygon with more than 256 points not supported yet (fixme!)\n");
+               Con_Print("Polygon with more than 256 points not supported yet (fixme!)\n");
                return;
        }
        polyf_brush.numpoints = numpoints;
@@ -1094,7 +1098,7 @@ void Collision_TraceLinePolygonFloat(trace_t *trace, const vec3_t linestart, con
 {
        if (numpoints > 256)
        {
-               Con_Printf("Polygon with more than 256 points not supported yet (fixme!)\n");
+               Con_Print("Polygon with more than 256 points not supported yet (fixme!)\n");
                return;
        }
        polyf_brush.numpoints = numpoints;
@@ -1155,7 +1159,7 @@ void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t
        int i;
        if (numpoints > 256)
        {
-               Con_Printf("Polygon with more than 256 points not supported yet (fixme!)\n");
+               Con_Print("Polygon with more than 256 points not supported yet (fixme!)\n");
                return;
        }
        polyf_brushstart.numpoints = numpoints;