}
-colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes)
+colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalplanes, const colplanef_t *originalplanes, int supercontents)
{
// TODO: planesbuf could be replaced by a remapping table
int j, k, m, w;
// add the new plane
VectorCopy(originalplanes[j].normal, planesbuf[numplanesbuf].normal);
planesbuf[numplanesbuf].dist = originalplanes[j].dist;
- planesbuf[numplanesbuf].supercontents = originalplanes[j].supercontents;
planesbuf[numplanesbuf].q3surfaceflags = originalplanes[j].q3surfaceflags;
planesbuf[numplanesbuf].texture = originalplanes[j].texture;
numplanesbuf++;
// allocate the brush and copy to it
brush = (colbrushf_t *)Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colpointf_t) * numpointsbuf + sizeof(colplanef_t) * numplanesbuf + sizeof(int) * numelementsbuf);
+ brush->supercontents = supercontents;
brush->numplanes = numplanesbuf;
brush->numpoints = numpointsbuf;
brush->numtriangles = numelementsbuf / 3;
brush->planes[j].normal[1] = planesbuf[j].normal[1];
brush->planes[j].normal[2] = planesbuf[j].normal[2];
brush->planes[j].dist = planesbuf[j].dist;
- brush->planes[j].supercontents = planesbuf[j].supercontents;
brush->planes[j].q3surfaceflags = planesbuf[j].q3surfaceflags;
brush->planes[j].texture = planesbuf[j].texture;
- brush->supercontents |= brush->planes[j].supercontents;
}
for (j = 0;j < brush->numtriangles * 3;j++)
brush->elements[j] = elementsbuf[j];
brush->planes[3].dist = DotProduct(brush->points[0].v, brush->planes[3].normal);
brush->planes[4].dist = DotProduct(brush->points[1].v, brush->planes[4].normal);
- if (developer.integer)
+ if (developer.integer >= 100)
{
// validation code
#if 0
}
}
- if (developer.integer)
+ if (developer.integer >= 100)
{
// validity check - will be disabled later
Collision_ValidateBrush(brush);
// NOTE: start and end of each brush pair must have same numplanes/numpoints
void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end)
{
- int nplane, nplane2, fstartsolid = true, fendsolid = true, brushsolid, hitsupercontents = 0, hitq3surfaceflags = 0;
+ int nplane, nplane2, fstartsolid = true, fendsolid = true, brushsolid, hitq3surfaceflags = 0;
float enterfrac = -1, leavefrac = 1, d1, d2, f, imove, newimpactnormal[3], enterfrac2 = -1;
const colplanef_t *startplane, *endplane;
texture_t *hittexture = NULL;
nplane2 -= thatbrush_start->numplanes;
startplane = thisbrush_start->planes + nplane2;
endplane = thisbrush_end->planes + nplane2;
- if (developer.integer)
+ if (developer.integer >= 100)
{
// any brush with degenerate planes is not worth handling
if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f)
{
startplane = thatbrush_start->planes + nplane2;
endplane = thatbrush_end->planes + nplane2;
- if (developer.integer)
+ if (developer.integer >= 100)
{
// any brush with degenerate planes is not worth handling
if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f)
enterfrac = f;
enterfrac2 = f - collision_impactnudge.value * imove;
VectorLerp(startplane->normal, enterfrac, endplane->normal, newimpactnormal);
- hitsupercontents = startplane->supercontents;
hitq3surfaceflags = startplane->q3surfaceflags;
hittexture = startplane->texture;
}
if (enterfrac < trace->realfraction)
{
enterfrac2 = enterfrac - collision_impactnudge.value * imove;
- trace->hitsupercontents = thatbrush_start->planes[0].supercontents;
+ trace->hitsupercontents = thatbrush_start->supercontents;
trace->hitq3surfaceflags = thatbrush_start->planes[0].q3surfaceflags;
trace->hittexture = thatbrush_start->planes[0].texture;
trace->realfraction = bound(0, enterfrac, 1);
else
#endif
{
- trace->hitsupercontents = hitsupercontents;
+ trace->hitsupercontents = thatbrush_start->supercontents;
trace->hitq3surfaceflags = hitq3surfaceflags;
trace->hittexture = hittexture;
trace->realfraction = bound(0, enterfrac, 1);
// NOTE: start and end brush pair must have same numplanes/numpoints
void Collision_TraceLineBrushFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end)
{
- int nplane, fstartsolid = true, fendsolid = true, brushsolid, hitsupercontents = 0, hitq3surfaceflags = 0;
+ int nplane, fstartsolid = true, fendsolid = true, brushsolid, hitq3surfaceflags = 0;
float enterfrac = -1, leavefrac = 1, d1, d2, f, imove, newimpactnormal[3], enterfrac2 = -1;
const colplanef_t *startplane, *endplane;
texture_t *hittexture = NULL;
endplane = thatbrush_end->planes + nplane;
d1 = DotProduct(startplane->normal, linestart) - startplane->dist - collision_startnudge.value;
d2 = DotProduct(endplane->normal, lineend) - endplane->dist - collision_endnudge.value;
- if (developer.integer)
+ if (developer.integer >= 100)
{
// any brush with degenerate planes is not worth handling
if (DotProduct(startplane->normal, startplane->normal) < 0.9f || DotProduct(endplane->normal, endplane->normal) < 0.9f)
enterfrac = f;
enterfrac2 = f - collision_impactnudge.value * imove;
VectorLerp(startplane->normal, enterfrac, endplane->normal, newimpactnormal);
- hitsupercontents = startplane->supercontents;
hitq3surfaceflags = startplane->q3surfaceflags;
hittexture = startplane->texture;
}
if (enterfrac < trace->realfraction)
{
enterfrac2 = enterfrac - collision_impactnudge.value * imove;
- trace->hitsupercontents = hitsupercontents;
+ trace->hitsupercontents = thatbrush_start->supercontents;
trace->hitq3surfaceflags = hitq3surfaceflags;
trace->hittexture = hittexture;
trace->realfraction = bound(0, enterfrac, 1);
else
#endif
{
- trace->hitsupercontents = hitsupercontents;
+ trace->hitsupercontents = thatbrush_start->supercontents;
trace->hitq3surfaceflags = hitq3surfaceflags;
trace->hittexture = hittexture;
trace->realfraction = bound(0, enterfrac, 1);
polyf_brush.supercontents = supercontents;
for (i = 0;i < polyf_brush.numplanes;i++)
{
- polyf_brush.planes[i].supercontents = supercontents;
polyf_brush.planes[i].q3surfaceflags = q3surfaceflags;
polyf_brush.planes[i].texture = texture;
}
Matrix4x4_Transform(polygonmatrixend, points + i * 3, polyf_brushend.points[i].v);
for (i = 0;i < polyf_brushstart.numplanes;i++)
{
- polyf_brushstart.planes[i].supercontents = supercontents;
polyf_brushstart.planes[i].q3surfaceflags = q3surfaceflags;
polyf_brushstart.planes[i].texture = texture;
}
int i;
for (i = 0;i < MAX_BRUSHFORBOX;i++)
{
- brushforbox_brush[i].supercontents = SUPERCONTENTS_SOLID;
brushforbox_brush[i].numpoints = 8;
brushforbox_brush[i].numplanes = 6;
brushforbox_brush[i].points = brushforbox_point + i * 8;
brushforbox_brush[i].planes = brushforbox_plane + i * 6;
- brushforpoint_brush[i].supercontents = SUPERCONTENTS_SOLID;
brushforpoint_brush[i].numpoints = 1;
brushforpoint_brush[i].numplanes = 0;
brushforpoint_brush[i].points = brushforbox_point + i * 8;
brush->supercontents = supercontents;
for (j = 0;j < brush->numplanes;j++)
{
- brush->planes[j].supercontents = supercontents;
brush->planes[j].q3surfaceflags = q3surfaceflags;
brush->planes[j].texture = texture;
brush->planes[j].dist = furthestplanedist_float(brush->planes[j].normal, brush->points, brush->numpoints);