diff --git a/bih.h b/bih.h index 9b48becd4..32b1d4b5d 100644 --- a/bih.h +++ b/bih.h @@ -39,14 +39,18 @@ typedef struct bih_node_s // TODO: move bounds data to parent node and remove it from leafs? float mins[3]; float maxs[3]; - // node indexes of children (always > this node's index) - int front; - int back; - // interval of children - float frontmin; // children[0] - float backmax; // children[1] - // BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list - int children[BIH_MAXUNORDEREDCHILDREN]; + union { + struct{ + // node indexes of children (always > this node's index) + int front; + int back; + // interval of children + float frontmin; // children[0] + float backmax; // children[1] + }; + // BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list + int children[BIH_MAXUNORDEREDCHILDREN]; + }; } bih_node_t; diff --git a/com_crc16.c b/com_crc16.c index 1b3a96524..f98260573 100644 --- a/com_crc16.c +++ b/com_crc16.c @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CRC_INIT_VALUE 0xffff #define CRC_XOR_VALUE 0x0000 -static unsigned short crctable[256] = +static const u16 crctable[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, @@ -89,7 +89,7 @@ unsigned short CRC_Block_CaseInsensitive(const unsigned char *data, size_t size) } // QuakeWorld -static unsigned char chktbl[1024 + 4] = +static const u8 chktbl[1024 + 4] = { 0x78,0xd2,0x94,0xe3,0x41,0xec,0xd6,0xd5,0xcb,0xfc,0xdb,0x8a,0x4b,0xcc,0x85,0x01, 0x23,0xd2,0xe5,0xf2,0x29,0xa7,0x45,0x94,0x4a,0x62,0xe3,0xa5,0x6f,0x3f,0xe1,0x7a, @@ -131,7 +131,7 @@ static unsigned char chktbl[1024 + 4] = // QuakeWorld unsigned char COM_BlockSequenceCRCByteQW(unsigned char *base, int length, int sequence) { - unsigned char *p; + const unsigned char *p; unsigned char chkb[60 + 4]; p = chktbl + (sequence % (sizeof(chktbl) - 8)); diff --git a/model_brush.c b/model_brush.c index a69a7eed1..69082e61b 100644 --- a/model_brush.c +++ b/model_brush.c @@ -6815,19 +6815,23 @@ void Mod_CollisionBIH_TracePoint(model_t *model, const frameblend_t *frameblend, { nodenum = nodestack[--nodestackpos]; node = bih->nodes + nodenum; + assert(node->type <= BIH_UNORDERED); #if 1 if (!BoxesOverlap(start, start, node->mins, node->maxs)) continue; #endif - if (node->type <= BIH_SPLITZ && nodestackpos+2 <= 1024) + if (node->type != BIH_UNORDERED) { + if(nodestackpos > 1024 - 2) + //Out of stack + continue; axis = node->type - BIH_SPLITX; if (start[axis] >= node->frontmin) nodestack[nodestackpos++] = node->front; if (start[axis] <= node->backmax) nodestack[nodestackpos++] = node->back; } - else if (node->type == BIH_UNORDERED) + else { for (axis = 0;axis < BIH_MAXUNORDEREDCHILDREN && node->children[axis] >= 0;axis++) { @@ -6904,37 +6908,130 @@ static void Mod_CollisionBIH_TraceLineShared(model_t *model, const frameblend_t sweepnodemaxs[2] = max(nodestart[2], nodeend[2]) + 1; if (!BoxesOverlap(sweepnodemins, sweepnodemaxs, node->mins, node->maxs) && !collision_bih_fullrecursion.integer) continue; - if (node->type <= BIH_SPLITZ && nodestackpos+2 <= 1024) + assert(node->type <= BIH_UNORDERED); + if (node->type != BIH_UNORDERED) { + if(nodestackpos > 1024 - 2) + //Out of stack + continue; // recurse children of the split axis = node->type - BIH_SPLITX; d1 = node->backmax - nodestart[axis]; d2 = node->backmax - nodeend[axis]; d3 = nodestart[axis] - node->frontmin; d4 = nodeend[axis] - node->frontmin; + f = 1.f / (nodeend[axis] - nodestart[axis]); if (collision_bih_fullrecursion.integer) d1 = d2 = d3 = d4 = 1; // force full recursion switch((d1 < 0) | ((d2 < 0) << 1) | ((d3 < 0) << 2) | ((d4 < 0) << 3)) { - case 0: /* >>>> */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 1: /* <>>> */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 2: /* ><>> */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 3: /* <<>> */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 4: /* >><> */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 5: /* <><> */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 6: /* ><<> */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 7: /* <<<> */ f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 8: /* >>>< */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 9: /* <>>< */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 10: /* ><>< */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 11: /* <<>< */ f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 12: /* >><< */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; break; - case 13: /* <><< */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; break; - case 14: /* ><<< */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; break; - case 15: /* <<<< */ break; - } - } - else if (node->type == BIH_UNORDERED) + case 0: /* >>>> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 1: /* <>>> */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 2: /* ><>> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 3: /* <<>> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 4: /* >><> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 5: /* <><> */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 6: /* ><<> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 7: /* <<<> */ + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 8: /* >>>< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 9: /* <>>< */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 10: /* ><>< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 11: /* <<>< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 12: /* >><< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + break; + case 13: /* <><< */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + break; + case 14: /* ><<< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + break; + case 15: /* <<<< */ + break; + } + } + else { // calculate sweep bounds for this node // copy node bounds into local variables @@ -7027,8 +7124,10 @@ void Mod_CollisionBIH_TraceBrush(model_t *model, const frameblend_t *frameblend, trace->skipmaterialflagsmask = skipmaterialflagsmask; // calculate tracebox-like parameters for efficient culling - VectorMAM(0.5f, thisbrush_start->mins, 0.5f, thisbrush_start->maxs, start); - VectorMAM(0.5f, thisbrush_end->mins, 0.5f, thisbrush_end->maxs, end); + VectorAdd(thisbrush_start->mins, thisbrush_start->maxs, start); + VectorAdd(thisbrush_end->mins, thisbrush_end->maxs, end); + VectorM(0.5f, start, start); + VectorM(0.5f, end, end); VectorSubtract(thisbrush_start->mins, start, startmins); VectorSubtract(thisbrush_start->maxs, start, startmaxs); VectorSubtract(thisbrush_end->mins, end, endmins); @@ -7062,35 +7161,128 @@ void Mod_CollisionBIH_TraceBrush(model_t *model, const frameblend_t *frameblend, sweepnodemaxs[2] = max(nodestart[2], nodeend[2]) + maxs[2] + 1; if (!BoxesOverlap(sweepnodemins, sweepnodemaxs, node->mins, node->maxs)) continue; - if (node->type <= BIH_SPLITZ && nodestackpos+2 <= 1024) + assert(node->type <= BIH_UNORDERED); + if (node->type != BIH_UNORDERED) { + if(nodestackpos > 1024 - 2) + //Out of stack + continue; // recurse children of the split axis = node->type - BIH_SPLITX; - d1 = node->backmax - nodestart[axis] - mins[axis]; - d2 = node->backmax - nodeend[axis] - mins[axis]; - d3 = nodestart[axis] - node->frontmin + maxs[axis]; - d4 = nodeend[axis] - node->frontmin + maxs[axis]; + d1 = node->backmax - mins[axis] - nodestart[axis]; + d2 = node->backmax - mins[axis] - nodeend[axis]; + d3 = nodestart[axis] - (node->frontmin - maxs[axis]); + d4 = nodeend[axis] - (node->frontmin - maxs[axis]); + f = 1.f / (nodeend[axis] - nodestart[axis]); switch((d1 < 0) | ((d2 < 0) << 1) | ((d3 < 0) << 2) | ((d4 < 0) << 3)) { - case 0: /* >>>> */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 1: /* <>>> */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 2: /* ><>> */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 3: /* <<>> */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 4: /* >><> */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 5: /* <><> */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 6: /* ><<> */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 7: /* <<<> */ f = d3 / (d3 - d4); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 8: /* >>>< */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 9: /* <>>< */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 10: /* ><>< */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 11: /* <<>< */ f = d3 / (d3 - d4); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->front; break; - case 12: /* >><< */ VectorCopy(nodestart, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; break; - case 13: /* <><< */ f = d1 / (d1 - d2); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos]); VectorCopy( nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; break; - case 14: /* ><<< */ f = d1 / (d1 - d2); VectorCopy(nodestart, nodestackline[nodestackpos]); VectorLerp(nodestart, f, nodeend, nodestackline[nodestackpos] + 3); nodestack[nodestackpos++] = node->back; break; - case 15: /* <<<< */ break; - } - } - else if (node->type == BIH_UNORDERED) + case 0: /* >>>> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 1: /* <>>> */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 2: /* ><>> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 3: /* <<>> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 4: /* >><> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 5: /* <><> */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 6: /* ><<> */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 7: /* <<<> */ + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 8: /* >>>< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 9: /* <>>< */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 10: /* ><>< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 11: /* <<>< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, -d3 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->front; + break; + case 12: /* >><< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + break; + case 13: /* <><< */ + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos]); + VectorCopy(nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + break; + case 14: /* ><<< */ + VectorCopy(nodestart, nodestackline[nodestackpos]); + VectorLerp(nodestart, d1 * f, nodeend, nodestackline[nodestackpos] + 3); + nodestack[nodestackpos++] = node->back; + break; + case 15: /* <<<< */ + break; + } + } + else { // calculate sweep bounds for this node // copy node bounds into local variables and expand to get Minkowski Sum of the two shapes