brush.planes[i].q3surfaceflags = q3surfaceflags;
brush.planes[i].texture = texture;
}
- if(stride)
+ if(stride > 0)
{
int k, cnt, tri;
cnt = (numtriangles + stride - 1) / stride;
}
}
}
- else
+ else if(stride == 0)
{
for (i = 0;i < numtriangles;i++, element3i += 3)
{
}
}
}
+ else
+ {
+ for (i = 0;i < numtriangles;i++, element3i += 3)
+ {
+ VectorCopy(vertex3f + element3i[0] * 3, points[0].v);
+ VectorCopy(vertex3f + element3i[1] * 3, points[1].v);
+ VectorCopy(vertex3f + element3i[2] * 3, points[2].v);
+ Collision_SnapCopyPoints(brush.numpoints, points, points, COLLISION_SNAPSCALE, COLLISION_SNAP);
+ Collision_CalcEdgeDirsForPolygonBrushFloat(&brush);
+ Collision_CalcPlanesForPolygonBrushFloat(&brush);
+ //Collision_PrintBrushAsQHull(&brush, "brush");
+ Collision_TraceBrushBrushFloat(trace, thisbrush_start, thisbrush_end, &brush, &brush);
+ }
+ }
}
void Collision_TraceLineTriangleMeshFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, int numtriangles, const int *element3i, const float *vertex3f, int stride, float *bbox6f, int supercontents, int q3surfaceflags, texture_t *texture, const vec3_t segmentmins, const vec3_t segmentmaxs)
{
int i;
-#if 1
// FIXME: snap vertices?
- if(stride)
+ if(stride > 0)
{
int k, cnt, tri;
cnt = (numtriangles + stride - 1) / stride;
for (i = 0;i < numtriangles;i++, element3i += 3)
Collision_TraceLineTriangleFloat(trace, linestart, lineend, vertex3f + element3i[0] * 3, vertex3f + element3i[1] * 3, vertex3f + element3i[2] * 3, supercontents, q3surfaceflags, texture);
}
-#else
- colpointf_t points[3];
- colpointf_t edgedirs[3];
- colplanef_t planes[5];
- colbrushf_t brush;
- memset(&brush, 0, sizeof(brush));
- brush.isaabb = false;
- brush.hasaabbplanes = false;
- brush.numpoints = 3;
- brush.numedgedirs = 3;
- brush.numplanes = 5;
- brush.points = points;
- brush.edgedirs = edgedirs;
- brush.planes = planes;
- brush.supercontents = supercontents;
- brush.q3surfaceflags = q3surfaceflags;
- brush.texture = texture;
- for (i = 0;i < brush.numplanes;i++)
- {
- brush.planes[i].q3surfaceflags = q3surfaceflags;
- brush.planes[i].texture = texture;
- }
- for (i = 0;i < numtriangles;i++, element3i += 3)
- {
- if (TriangleOverlapsBox(vertex3f + element3i[0]*3, vertex3 + [element3i[1]*3, vertex3f + element3i[2]*3, segmentmins, segmentmaxs))
- {
- VectorCopy(vertex3f + element3i[0] * 3, points[0].v);
- VectorCopy(vertex3f + element3i[1] * 3, points[1].v);
- VectorCopy(vertex3f + element3i[2] * 3, points[2].v);
- Collision_SnapCopyPoints(brush.numpoints, points, points, COLLISION_SNAPSCALE, COLLISION_SNAP);
- Collision_CalcEdgeDirsForPolygonBrushFloat(&brush);
- Collision_CalcPlanesForPolygonBrushFloat(&brush);
- //Collision_PrintBrushAsQHull(&brush, "brush");
- Collision_TraceLineBrushFloat(trace, linestart, lineend, &brush, &brush);
- }
- }
-#endif
}
void Collision_BrushForBox(colboxbrushf_t *boxbrush, const vec3_t mins, const vec3_t maxs, int supercontents, int q3surfaceflags, texture_t *texture)
cvar_t r_subdivisions_collision_maxtess = {0, "r_subdivisions_collision_maxtess", "1024", "maximum number of subdivisions (prevents curves beyond a certain detail level, limits smoothing)"};
cvar_t r_subdivisions_collision_maxvertices = {0, "r_subdivisions_collision_maxvertices", "4225", "maximum vertices allowed per subdivided curve"};
cvar_t mod_q3bsp_curves_collisions = {0, "mod_q3bsp_curves_collisions", "1", "enables collisions with curves (SLOW)"};
-cvar_t mod_q3bsp_curves_collisions_stride = {0, "mod_q3bsp_curves_collisions_stride", "16", "collisions against curves: optimize performance by doing a combined collision check for this triangle amount first"};
-cvar_t mod_q3bsp_curves_stride = {0, "mod_q3bsp_curves_stride", "16", "particle effect collisions against curves: optimize performance by doing a combined collision check for this triangle amount first"};
+cvar_t mod_q3bsp_curves_collisions_stride = {0, "mod_q3bsp_curves_collisions_stride", "16", "collisions against curves: optimize performance by doing a combined collision check for this triangle amount first (-1 avoids any box tests)"};
+cvar_t mod_q3bsp_curves_stride = {0, "mod_q3bsp_curves_stride", "16", "particle effect collisions against curves: optimize performance by doing a combined collision check for this triangle amount first (-1 avoids any box tests)"};
cvar_t mod_q3bsp_optimizedtraceline = {0, "mod_q3bsp_optimizedtraceline", "1", "whether to use optimized traceline code for line traces (as opposed to tracebox code)"};
cvar_t mod_q3bsp_debugtracebrush = {0, "mod_q3bsp_debugtracebrush", "0", "selects different tracebrush bsp recursion algorithms (for debugging purposes only)"};
cvar_t mod_q3bsp_lightmapmergepower = {CVAR_SAVE, "mod_q3bsp_lightmapmergepower", "4", "merges the quake3 128x128 lightmap textures into larger lightmap group textures to speed up rendering, 1 = 256x256, 2 = 512x512, 3 = 1024x1024, 4 = 2048x2048, 5 = 4096x4096, ..."};
surface = info->model->data_surfaces + *mark;
if (surface->texture->supercontents & SUPERCONTENTS_SOLID)
{
- if(surface->num_bboxstride)
+ if(surface->num_bboxstride > 0)
{
int i, cnt, tri;
cnt = (surface->num_triangles + surface->num_bboxstride - 1) / surface->num_bboxstride;
int j, k, cnt, tri;
float *mins, *maxs;
const float *vert;
+ *collisionstride = stride;
if(stride > 0)
{
- *collisionstride = stride;
cnt = (num_triangles + stride - 1) / stride;
*collisionbbox6f = (float *) Mem_Alloc(loadmodel->mempool, sizeof(float[6]) * cnt);
for(j = 0; j < cnt; ++j)
}
}
else
- {
- *collisionstride = 0;
*collisionbbox6f = NULL;
- }
}
typedef struct patchtess_s