const int *e;
const texture_t *texture;
int axis;
-#if 0
+#define BIHLINECLIP
+#ifdef BIHLINECLIP
int sideflags;
vec_t frontdist1;
vec_t frontdist2;
while (nodenum >= 0)
{
node = model->collision_bih.nodes + nodenum;
-#if 1
+#if 0
if (!BoxesOverlap(segmentmins, segmentmaxs, node->mins, node->maxs))
return;
#endif
axis = node->type - BIH_SPLITX;
-#if 1
+#if 0
if (segmentmins[axis] <= node->backmax)
{
if (segmentmaxs[axis] >= node->frontmin)
else
return; // trace falls between children
#else
- frontdist1 = start[axis] - node->backmax;
- frontdist2 = end[axis] - node->backmax;
- backdist1 = start[axis] - node->frontmin;
- backdist2 = end[axis] - node->frontmin;
+ frontdist1 = start[axis] - node->frontmin;
+ frontdist2 = end[axis] - node->frontmin;
+ backdist1 = start[axis] - node->backmax;
+ backdist2 = end[axis] - node->backmax;
sideflags = 0;
if (frontdist1 < 0)
sideflags |= 1;
sideflags |= 4;
if (backdist2 < 0)
sideflags |= 8;
+#if 0
+ if (sideflags & 12)
+ {
+ if ((sideflags & 3) != 3)
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+ nodenum = node->back;
+ }
+ else if ((sideflags & 3) != 3)
+ nodenum = node->front;
+ else
+ return; // trace falls between children
+#else
switch(sideflags)
{
case 0:
continue;
case 1:
// START end START END
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[0]);
start = clipped[0];
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#endif
nodenum = node->front;
break;
case 2:
+#ifdef BIHLINECLIP
// start END START END
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[0]);
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#endif
nodenum = node->front;
break;
case 3:
case 4:
// start end start END
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#ifdef BIHLINECLIP
backfrac = backdist1 / (backdist1 - backdist2);
VectorLerp(start, backfrac, end, clipped[0]);
end = clipped[0];
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#endif
nodenum = node->back;
break;
case 5:
// START end start END
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[1]);
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, clipped[1], end, linestart, lineend);
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#else
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#endif
nodenum = node->back;
break;
case 6:
// start END start END
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[1]);
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, clipped[1], linestart, lineend);
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#else
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#endif
nodenum = node->back;
break;
case 7:
// START END start END
+#ifdef BIHLINECLIP
backfrac = backdist1 / (backdist1 - backdist2);
VectorLerp(start, backfrac, end, clipped[0]);
end = clipped[0];
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#endif
nodenum = node->back;
break;
case 8:
// start end START end
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#ifdef BIHLINECLIP
backfrac = backdist1 / (backdist1 - backdist2);
VectorLerp(start, backfrac, end, clipped[0]);
start = clipped[0];
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#endif
nodenum = node->back;
break;
case 9:
// START end START end
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[1]);
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, clipped[1], end, linestart, lineend);
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#else
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#endif
nodenum = node->back;
break;
case 10:
// start END START end
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[1]);
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, clipped[1], linestart, lineend);
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#else
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#endif
nodenum = node->back;
break;
case 11:
// START END START end
+#ifdef BIHLINECLIP
backfrac = backdist1 / (backdist1 - backdist2);
VectorLerp(start, backfrac, end, clipped[0]);
start = clipped[0];
segmentmaxs[0] = max(start[0], end[0]);
segmentmaxs[1] = max(start[1], end[1]);
segmentmaxs[2] = max(start[2], end[2]);
+#endif
nodenum = node->back;
break;
case 12:
break;
case 13:
// START end start end
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[1]);
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, clipped[1], end, linestart, lineend);
+#else
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#endif
nodenum = node->back;
break;
case 14:
// start END start end
+#ifdef BIHLINECLIP
frontfrac = frontdist1 / (frontdist1 - frontdist2);
VectorLerp(start, frontfrac, end, clipped[1]);
Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, clipped[1], linestart, lineend);
+#else
+ Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, node->front, start, end, linestart, lineend);
+#endif
nodenum = node->back;
break;
case 15:
nodenum = node->back;
continue;
}
+#endif
#endif
}
if (!model->collision_bih.leafs)