Lines Matching refs:tw

161 void CM_TestBoxInBrush( traceWork_t *tw, cbrush_t *brush ) {  in CM_TestBoxInBrush()  argument
175 if ( tw->bounds[0][0] > brush->bounds[1][0] in CM_TestBoxInBrush()
176 || tw->bounds[0][1] > brush->bounds[1][1] in CM_TestBoxInBrush()
177 || tw->bounds[0][2] > brush->bounds[1][2] in CM_TestBoxInBrush()
178 || tw->bounds[1][0] < brush->bounds[0][0] in CM_TestBoxInBrush()
179 || tw->bounds[1][1] < brush->bounds[0][1] in CM_TestBoxInBrush()
180 || tw->bounds[1][2] < brush->bounds[0][2] in CM_TestBoxInBrush()
185 if ( tw->sphere.use ) { in CM_TestBoxInBrush()
193 dist = plane->dist + tw->sphere.radius; in CM_TestBoxInBrush()
195 t = DotProduct( plane->normal, tw->sphere.offset ); in CM_TestBoxInBrush()
198 VectorSubtract( tw->start, tw->sphere.offset, startp ); in CM_TestBoxInBrush()
202 VectorAdd( tw->start, tw->sphere.offset, startp ); in CM_TestBoxInBrush()
218 dist = plane->dist - DotProduct( tw->offsets[ plane->signbits ], plane->normal ); in CM_TestBoxInBrush()
220 d1 = DotProduct( tw->start, plane->normal ) - dist; in CM_TestBoxInBrush()
230 tw->trace.startsolid = tw->trace.allsolid = qtrue; in CM_TestBoxInBrush()
231 tw->trace.fraction = 0; in CM_TestBoxInBrush()
232 tw->trace.contents = brush->contents; in CM_TestBoxInBrush()
242 void CM_TestInLeaf( traceWork_t *tw, cLeaf_t *leaf ) { argument
257 if ( !(b->contents & tw->contents)) {
261 CM_TestBoxInBrush( tw, b );
262 if ( tw->trace.allsolid ) {
283 if ( !(patch->contents & tw->contents)) {
287 if ( CM_PositionTestInPatchCollide( tw, patch->pc ) ) {
288 tw->trace.startsolid = tw->trace.allsolid = qtrue;
289 tw->trace.fraction = 0;
290 tw->trace.contents = patch->contents;
304 void CM_TestCapsuleInCapsule( traceWork_t *tw, clipHandle_t model ) { argument
314 VectorAdd(tw->start, tw->sphere.offset, top);
315 VectorSubtract(tw->start, tw->sphere.offset, bottom);
326 r = Square(tw->sphere.radius + radius);
332 tw->trace.startsolid = tw->trace.allsolid = qtrue;
333 tw->trace.fraction = 0;
337 tw->trace.startsolid = tw->trace.allsolid = qtrue;
338 tw->trace.fraction = 0;
344 tw->trace.startsolid = tw->trace.allsolid = qtrue;
345 tw->trace.fraction = 0;
349 tw->trace.startsolid = tw->trace.allsolid = qtrue;
350 tw->trace.fraction = 0;
360 tw->trace.startsolid = tw->trace.allsolid = qtrue;
361 tw->trace.fraction = 0;
373 void CM_TestBoundingBoxInCapsule( traceWork_t *tw, clipHandle_t model ) { argument
387 tw->start[i] -= offset[i];
388 tw->end[i] -= offset[i];
392 tw->sphere.use = qtrue;
393 tw->sphere.radius = ( size[1][0] > size[1][2] ) ? size[1][2]: size[1][0];
394 tw->sphere.halfheight = size[1][2];
395 VectorSet( tw->sphere.offset, 0, 0, size[1][2] - tw->sphere.radius );
398 h = CM_TempBoxModel(tw->size[0], tw->size[1], qfalse);
401 CM_TestInLeaf( tw, &cmod->leaf );
410 void CM_PositionTest( traceWork_t *tw ) { argument
416 VectorAdd( tw->start, tw->size[0], ll.bounds[0] );
417 VectorAdd( tw->start, tw->size[1], ll.bounds[1] );
440 CM_TestInLeaf( tw, &cm.leafs[leafs[i]] );
441 if ( tw->trace.allsolid ) {
462 void CM_TraceThroughPatch( traceWork_t *tw, cPatch_t *patch ) { argument
467 oldFrac = tw->trace.fraction;
469 CM_TraceThroughPatchCollide( tw, patch->pc );
471 if ( tw->trace.fraction < oldFrac ) {
472 tw->trace.surfaceFlags = patch->surfaceFlags;
473 tw->trace.contents = patch->contents;
482 void CM_TraceThroughBrush( traceWork_t *tw, cbrush_t *brush ) { argument
510 if ( tw->sphere.use ) {
521 dist = plane->dist + tw->sphere.radius;
524 t = DotProduct( plane->normal, tw->sphere.offset );
527 VectorSubtract( tw->start, tw->sphere.offset, startp );
528 VectorSubtract( tw->end, tw->sphere.offset, endp );
532 VectorAdd( tw->start, tw->sphere.offset, startp );
533 VectorAdd( tw->end, tw->sphere.offset, endp );
588 dist = plane->dist - DotProduct( tw->offsets[ plane->signbits ], plane->normal );
590 d1 = DotProduct( tw->start, plane->normal ) - dist;
591 d2 = DotProduct( tw->end, plane->normal ) - dist;
638 tw->trace.startsolid = qtrue;
640 tw->trace.allsolid = qtrue;
641 tw->trace.fraction = 0;
642 tw->trace.contents = brush->contents;
648 if (enterFrac > -1 && enterFrac < tw->trace.fraction) {
652 tw->trace.fraction = enterFrac;
653 tw->trace.plane = *clipplane;
654 tw->trace.surfaceFlags = leadside->surfaceFlags;
655 tw->trace.contents = brush->contents;
665 void CM_TraceThroughLeaf( traceWork_t *tw, cLeaf_t *leaf ) { argument
681 if ( !(b->contents & tw->contents) ) {
685 if ( !CM_BoundsIntersect( tw->bounds[0], tw->bounds[1],
690 CM_TraceThroughBrush( tw, b );
691 if ( !tw->trace.fraction ) {
712 if ( !(patch->contents & tw->contents) ) {
716 CM_TraceThroughPatch( tw, patch );
717 if ( !tw->trace.fraction ) {
733 void CM_TraceThroughSphere( traceWork_t *tw, vec3_t origin, float radius, vec3_t start, vec3_t end … argument
742 tw->trace.fraction = 0;
743 tw->trace.startsolid = qtrue;
748 tw->trace.allsolid = qtrue;
787 if ( fraction < tw->trace.fraction ) {
788 tw->trace.fraction = fraction;
800 VectorCopy(dir, tw->trace.plane.normal);
801 VectorAdd( tw->modelOrigin, intersection, intersection);
802 tw->trace.plane.dist = DotProduct(tw->trace.plane.normal, intersection);
803 tw->trace.contents = CONTENTS_BODY;
821 void CM_TraceThroughVerticalCylinder( traceWork_t *tw, vec3_t origin, float radius, float halfheigh… argument
837 tw->trace.fraction = 0;
838 tw->trace.startsolid = qtrue;
842 tw->trace.allsolid = qtrue;
885 if ( fraction < tw->trace.fraction ) {
892 tw->trace.fraction = fraction;
903 VectorCopy(dir, tw->trace.plane.normal);
904 VectorAdd( tw->modelOrigin, intersection, intersection);
905 tw->trace.plane.dist = DotProduct(tw->trace.plane.normal, intersection);
906 tw->trace.contents = CONTENTS_BODY;
924 void CM_TraceCapsuleThroughCapsule( traceWork_t *tw, clipHandle_t model ) { argument
933 if ( tw->bounds[0][0] > maxs[0] + RADIUS_EPSILON
934 || tw->bounds[0][1] > maxs[1] + RADIUS_EPSILON
935 || tw->bounds[0][2] > maxs[2] + RADIUS_EPSILON
936 || tw->bounds[1][0] < mins[0] - RADIUS_EPSILON
937 || tw->bounds[1][1] < mins[1] - RADIUS_EPSILON
938 || tw->bounds[1][2] < mins[2] - RADIUS_EPSILON
943 VectorAdd(tw->start, tw->sphere.offset, starttop);
944 VectorSubtract(tw->start, tw->sphere.offset, startbottom);
945 VectorAdd(tw->end, tw->sphere.offset, endtop);
946 VectorSubtract(tw->end, tw->sphere.offset, endbottom);
963 radius += tw->sphere.radius;
965 if ( tw->start[0] != tw->end[0] || tw->start[1] != tw->end[1] ) {
967 h = halfheight + tw->sphere.halfheight - radius;
971 CM_TraceThroughVerticalCylinder(tw, offset, radius, h, tw->start, tw->end);
975 CM_TraceThroughSphere(tw, top, radius, startbottom, endbottom);
976 CM_TraceThroughSphere(tw, bottom, radius, starttop, endtop);
986 void CM_TraceBoundingBoxThroughCapsule( traceWork_t *tw, clipHandle_t model ) { argument
1000 tw->start[i] -= offset[i];
1001 tw->end[i] -= offset[i];
1005 tw->sphere.use = qtrue;
1006 tw->sphere.radius = ( size[1][0] > size[1][2] ) ? size[1][2]: size[1][0];
1007 tw->sphere.halfheight = size[1][2];
1008 VectorSet( tw->sphere.offset, 0, 0, size[1][2] - tw->sphere.radius );
1011 h = CM_TempBoxModel(tw->size[0], tw->size[1], qfalse);
1014 CM_TraceThroughLeaf( tw, &cmod->leaf );
1029 void CM_TraceThroughTree( traceWork_t *tw, int num, float p1f, float p2f, vec3_t p1, vec3_t p2) { argument
1039 if (tw->trace.fraction <= p1f) {
1045 CM_TraceThroughLeaf( tw, &cm.leafs[-1-num] );
1060 offset = tw->extents[plane->type];
1064 if ( tw->isPoint ) {
1074 CM_TraceThroughTree( tw, node->children[0], p1f, p2f, p1, p2 );
1078 CM_TraceThroughTree( tw, node->children[1], p1f, p2f, p1, p2 );
1113 CM_TraceThroughTree( tw, node->children[side], p1f, midf, p1, mid );
1130 CM_TraceThroughTree( tw, node->children[side^1], midf, p2f, mid, p2 );
1145 traceWork_t tw; local
1156 Com_Memset( &tw, 0, sizeof(tw) );
1157 tw.trace.fraction = 1; // assume it goes the entire distance until shown otherwise
1158 VectorCopy(origin, tw.modelOrigin);
1161 *results = tw.trace;
1175 tw.contents = brushmask;
1182 tw.size[0][i] = mins[i] - offset[i];
1183 tw.size[1][i] = maxs[i] - offset[i];
1184 tw.start[i] = start[i] + offset[i];
1185 tw.end[i] = end[i] + offset[i];
1190 tw.sphere = *sphere;
1193 tw.sphere.use = capsule;
1194 tw.sphere.radius = ( tw.size[1][0] > tw.size[1][2] ) ? tw.size[1][2]: tw.size[1][0];
1195 tw.sphere.halfheight = tw.size[1][2];
1196 VectorSet( tw.sphere.offset, 0, 0, tw.size[1][2] - tw.sphere.radius );
1199 tw.maxOffset = tw.size[1][0] + tw.size[1][1] + tw.size[1][2];
1202 tw.offsets[0][0] = tw.size[0][0];
1203 tw.offsets[0][1] = tw.size[0][1];
1204 tw.offsets[0][2] = tw.size[0][2];
1206 tw.offsets[1][0] = tw.size[1][0];
1207 tw.offsets[1][1] = tw.size[0][1];
1208 tw.offsets[1][2] = tw.size[0][2];
1210 tw.offsets[2][0] = tw.size[0][0];
1211 tw.offsets[2][1] = tw.size[1][1];
1212 tw.offsets[2][2] = tw.size[0][2];
1214 tw.offsets[3][0] = tw.size[1][0];
1215 tw.offsets[3][1] = tw.size[1][1];
1216 tw.offsets[3][2] = tw.size[0][2];
1218 tw.offsets[4][0] = tw.size[0][0];
1219 tw.offsets[4][1] = tw.size[0][1];
1220 tw.offsets[4][2] = tw.size[1][2];
1222 tw.offsets[5][0] = tw.size[1][0];
1223 tw.offsets[5][1] = tw.size[0][1];
1224 tw.offsets[5][2] = tw.size[1][2];
1226 tw.offsets[6][0] = tw.size[0][0];
1227 tw.offsets[6][1] = tw.size[1][1];
1228 tw.offsets[6][2] = tw.size[1][2];
1230 tw.offsets[7][0] = tw.size[1][0];
1231 tw.offsets[7][1] = tw.size[1][1];
1232 tw.offsets[7][2] = tw.size[1][2];
1237 if ( tw.sphere.use ) {
1239 if ( tw.start[i] < tw.end[i] ) {
1240 tw.bounds[0][i] = tw.start[i] - fabs(tw.sphere.offset[i]) - tw.sphere.radius;
1241 tw.bounds[1][i] = tw.end[i] + fabs(tw.sphere.offset[i]) + tw.sphere.radius;
1243 tw.bounds[0][i] = tw.end[i] - fabs(tw.sphere.offset[i]) - tw.sphere.radius;
1244 tw.bounds[1][i] = tw.start[i] + fabs(tw.sphere.offset[i]) + tw.sphere.radius;
1250 if ( tw.start[i] < tw.end[i] ) {
1251 tw.bounds[0][i] = tw.start[i] + tw.size[0][i];
1252 tw.bounds[1][i] = tw.end[i] + tw.size[1][i];
1254 tw.bounds[0][i] = tw.end[i] + tw.size[0][i];
1255 tw.bounds[1][i] = tw.start[i] + tw.size[1][i];
1267 tw.sphere.use = qfalse;
1268 CM_TestInLeaf( &tw, &cmod->leaf );
1273 CM_TestCapsuleInCapsule( &tw, model );
1278 if ( tw.sphere.use ) {
1279 CM_TestCapsuleInCapsule( &tw, model );
1282 CM_TestBoundingBoxInCapsule( &tw, model );
1286 CM_TestInLeaf( &tw, &cmod->leaf );
1289 CM_PositionTest( &tw );
1295 if ( tw.size[0][0] == 0 && tw.size[0][1] == 0 && tw.size[0][2] == 0 ) {
1296 tw.isPoint = qtrue;
1297 VectorClear( tw.extents );
1299 tw.isPoint = qfalse;
1300 tw.extents[0] = tw.size[1][0];
1301 tw.extents[1] = tw.size[1][1];
1302 tw.extents[2] = tw.size[1][2];
1311 tw.sphere.use = qfalse;
1312 CM_TraceThroughLeaf( &tw, &cmod->leaf );
1317 CM_TraceCapsuleThroughCapsule( &tw, model );
1322 if ( tw.sphere.use ) {
1323 CM_TraceCapsuleThroughCapsule( &tw, model );
1326 CM_TraceBoundingBoxThroughCapsule( &tw, model );
1330 CM_TraceThroughLeaf( &tw, &cmod->leaf );
1333 CM_TraceThroughTree( &tw, 0, 0, 1, tw.start, tw.end );
1338 if ( tw.trace.fraction == 1 ) {
1339 VectorCopy (end, tw.trace.endpos);
1342 tw.trace.endpos[i] = start[i] + tw.trace.fraction * (end[i] - start[i]);
1349 assert(tw.trace.allsolid ||
1350 tw.trace.fraction == 1.0 ||
1351 VectorLengthSquared(tw.trace.plane.normal) > 0.9999);
1352 *results = tw.trace;