- return;
- }
- axis = node->type - BIH_SPLITX;
-#if 0
- if (segmentmins[axis] <= node->backmax)
- {
- if (segmentmaxs[axis] >= node->frontmin)
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, end, linestart, lineend);
- nodenum = node->back;
- }
- else if (segmentmaxs[axis] >= node->frontmin)
- nodenum = node->front;
- else
- return; // trace falls between children
-#else
- 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;
- if (frontdist2 < 0)
- sideflags |= 2;
- if (backdist1 < 0)
- sideflags |= 4;
- if (backdist2 < 0)
- sideflags |= 8;
-#if 0
- if (sideflags & 12)
- {
- if ((sideflags & 3) != 3)
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, 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:
- // start end START END
- nodenum = node->front;
- continue;
- case 1:
- // START end START END
-#ifdef BIHLINECLIP
- frontfrac = frontdist1 / (frontdist1 - frontdist2);
- VectorLerp(start, frontfrac, end, newstart); start = newstart;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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, newend); end = newend;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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:
- // START END START END
- return; // line falls in gap between children
- case 4:
- // start end start END
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, end, linestart, lineend);
-#ifdef BIHLINECLIP
- backfrac = backdist1 / (backdist1 - backdist2);
- VectorLerp(start, backfrac, end, newend); end = newend;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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);
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, clipped, end, linestart, lineend);
- backfrac = backdist1 / (backdist1 - backdist2);
- VectorLerp(start, backfrac, end, newend); end = newend;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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, bih, 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);
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, clipped, linestart, lineend);
- backfrac = backdist1 / (backdist1 - backdist2);
- VectorLerp(start, backfrac, end, newend); end = newend;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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, bih, 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, newend); end = newend;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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, bih, node->front, start, end, linestart, lineend);
-#ifdef BIHLINECLIP
- backfrac = backdist1 / (backdist1 - backdist2);
- VectorLerp(start, backfrac, end, newstart); start = newstart;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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);
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, clipped, end, linestart, lineend);
- backfrac = backdist1 / (backdist1 - backdist2);
- VectorLerp(start, backfrac, end, newstart); start = newstart;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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, bih, 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);
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, clipped, linestart, lineend);
- backfrac = backdist1 / (backdist1 - backdist2);
- VectorLerp(start, backfrac, end, newstart); start = newstart;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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, bih, 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, newstart); start = newstart;
- segmentmins[0] = min(start[0], end[0]);
- segmentmins[1] = min(start[1], end[1]);
- segmentmins[2] = min(start[2], end[2]);
- 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:
- // start end start end
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, end, linestart, lineend);
- nodenum = node->back;
- break;
- case 13:
- // START end start end
-#ifdef BIHLINECLIP
- frontfrac = frontdist1 / (frontdist1 - frontdist2);
- VectorLerp(start, frontfrac, end, clipped);
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, clipped, end, linestart, lineend);
-#else
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, 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);
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, clipped, linestart, lineend);
-#else
- Mod_CollisionBIH_TraceLine_RecursiveBIHNode(trace, model, bih, node->front, start, end, linestart, lineend);
-#endif
- nodenum = node->back;
- break;
- case 15:
- // START END start end
- nodenum = node->back;
- continue;