#include "../game/q_shared.h"
#include "qcommon.h"
#include "cm_polylib.h"
Include dependency graph for cm_local.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
|
|
Definition at line 28 of file cm_local.h. Referenced by CM_Trace(), CM_TransformedBoxTrace(), and CM_TransformedPointContents(). |
|
|
Definition at line 29 of file cm_local.h. |
|
|
Definition at line 27 of file cm_local.h. Referenced by CM_ClipHandleToModel(). |
|
|
Definition at line 134 of file cm_local.h. Referenced by CM_CheckFacetPlane(), CM_TraceThroughBrush(), CM_TraceThroughSphere(), and CM_TraceThroughVerticalCylinder(). |
|
|
Referenced by CM_ClipHandleToModel(), CM_ModelBounds(), CM_PointContents(), CM_TestBoundingBoxInCapsule(), CM_Trace(), CM_TraceBoundingBoxThroughCapsule(), and CMod_LoadSubmodels(). |
|
|
Referenced by CM_BoxBrushes(), CM_BoxLeafnums(), CM_BoxLeafnums_r(), CM_PositionTest(), CM_StoreBrushes(), and CM_StoreLeafs(). |
|
||||||||||||||||||||
|
Definition at line 197 of file cm_test.c. References leafList_s::bounds, clipMap_t::checkcount, cm, CM_BoxLeafnums_r(), leafList_s::count, leafList_s::lastLeaf, leafList_t, leafList_s::list, leafList_s::maxcount, leafList_s::overflowed, leafList_s::storeLeafs, and VectorCopy. 00197 {
00198 leafList_t ll;
00199
00200 cm.checkcount++;
00201
00202 VectorCopy( mins, ll.bounds[0] );
00203 VectorCopy( maxs, ll.bounds[1] );
00204 ll.count = 0;
00205 ll.maxcount = listsize;
00206 ll.list = (void *)list;
00207 ll.storeLeafs = CM_StoreBrushes;
00208 ll.lastLeaf = 0;
00209 ll.overflowed = qfalse;
00210
00211 CM_BoxLeafnums_r( &ll, 0 );
00212
00213 return ll.count;
00214 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 140 of file cm_test.c. References leafList_s::bounds, BoxOnPlaneSide(), cNode_t::children, cm, cplane_t, leafList_t, clipMap_t::nodes, cNode_t::plane, s, and leafList_s::storeLeafs. Referenced by CM_BoxBrushes(), CM_BoxLeafnums(), and CM_PositionTest(). 00140 {
00141 cplane_t *plane;
00142 cNode_t *node;
00143 int s;
00144
00145 while (1) {
00146 if (nodenum < 0) {
00147 ll->storeLeafs( ll, nodenum );
00148 return;
00149 }
00150
00151 node = &cm.nodes[nodenum];
00152 plane = node->plane;
00153 s = BoxOnPlaneSide( ll->bounds[0], ll->bounds[1], plane );
00154 if (s == 1) {
00155 nodenum = node->children[0];
00156 } else if (s == 2) {
00157 nodenum = node->children[1];
00158 } else {
00159 // go down both
00160 CM_BoxLeafnums_r( ll, node->children[0] );
00161 nodenum = node->children[1];
00162 }
00163
00164 }
00165 }
|
Here is the call graph for this function:

|
|
Definition at line 97 of file cm_patch.c. References debugFacet, and debugPatchCollide. Referenced by CM_ClearMap(), and CM_LoadMap(). 00097 {
00098 debugPatchCollide = NULL;
00099 debugFacet = NULL;
00100 }
|
|
|
Definition at line 675 of file cm_load.c. References cm, cmodel_t, clipMap_t::cmodels, Com_Error(), ERR_DROP, MAX_SUBMODELS, and clipMap_t::numSubModels. Referenced by CM_ModelBounds(), CM_PointContents(), CM_TestBoundingBoxInCapsule(), CM_Trace(), and CM_TraceBoundingBoxThroughCapsule(). 00675 {
00676 if ( handle < 0 ) {
00677 Com_Error( ERR_DROP, "CM_ClipHandleToModel: bad handle %i", handle );
00678 }
00679 if ( handle < cm.numSubModels ) {
00680 return &cm.cmodels[handle];
00681 }
00682 if ( handle == BOX_MODEL_HANDLE ) {
00683 return &box_model;
00684 }
00685 if ( handle < MAX_SUBMODELS ) {
00686 Com_Error( ERR_DROP, "CM_ClipHandleToModel: bad handle %i < %i < %i",
00687 cm.numSubModels, handle, MAX_SUBMODELS );
00688 }
00689 Com_Error( ERR_DROP, "CM_ClipHandleToModel: bad handle %i", handle + MAX_SUBMODELS );
00690
00691 return NULL;
00692
00693 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1148 of file cm_patch.c. 01148 {
01149 patchCollide_t *pf;
01150 MAC_STATIC cGrid_t grid;
01151 int i, j;
01152
01153 if ( width <= 2 || height <= 2 || !points ) {
01154 Com_Error( ERR_DROP, "CM_GeneratePatchFacets: bad parameters: (%i, %i, %p)",
01155 width, height, points );
01156 }
01157
01158 if ( !(width & 1) || !(height & 1) ) {
01159 Com_Error( ERR_DROP, "CM_GeneratePatchFacets: even sizes are invalid for quadratic meshes" );
01160 }
01161
01162 if ( width > MAX_GRID_SIZE || height > MAX_GRID_SIZE ) {
01163 Com_Error( ERR_DROP, "CM_GeneratePatchFacets: source is > MAX_GRID_SIZE" );
01164 }
01165
01166 // build a grid
01167 grid.width = width;
01168 grid.height = height;
01169 grid.wrapWidth = qfalse;
01170 grid.wrapHeight = qfalse;
01171 for ( i = 0 ; i < width ; i++ ) {
01172 for ( j = 0 ; j < height ; j++ ) {
01173 VectorCopy( points[j*width + i], grid.points[i][j] );
01174 }
01175 }
01176
01177 // subdivide the grid
01178 CM_SetGridWrapWidth( &grid );
01179 CM_SubdivideGridColumns( &grid );
01180 CM_RemoveDegenerateColumns( &grid );
01181
01182 CM_TransposeGrid( &grid );
01183
01184 CM_SetGridWrapWidth( &grid );
01185 CM_SubdivideGridColumns( &grid );
01186 CM_RemoveDegenerateColumns( &grid );
01187
01188 // we now have a grid of points exactly on the curve
01189 // the aproximate surface defined by these points will be
01190 // collided against
01191 pf = Hunk_Alloc( sizeof( *pf ), h_high );
01192 ClearBounds( pf->bounds[0], pf->bounds[1] );
01193 for ( i = 0 ; i < grid.width ; i++ ) {
01194 for ( j = 0 ; j < grid.height ; j++ ) {
01195 AddPointToBounds( grid.points[i][j], pf->bounds[0], pf->bounds[1] );
01196 }
01197 }
01198
01199 c_totalPatchBlocks += ( grid.width - 1 ) * ( grid.height - 1 );
01200
01201 // generate a bsp tree for the surface
01202 CM_PatchCollideFromGrid( &grid, pf );
01203
01204 // expand by one unit for epsilon purposes
01205 pf->bounds[0][0] -= 1;
01206 pf->bounds[0][1] -= 1;
01207 pf->bounds[0][2] -= 1;
01208
01209 pf->bounds[1][0] += 1;
01210 pf->bounds[1][1] += 1;
01211 pf->bounds[1][2] += 1;
01212
01213 return pf;
01214 }
|
|
||||||||||||
|
Definition at line 1513 of file cm_patch.c. References facet_t::borderInward, facet_t::borderPlanes, DotProduct, fabs(), patchCollide_s::facets, i, traceWork_t::isPoint, j, facet_t::numBorders, patchCollide_s::numFacets, sphere_t::offset, offset, traceWork_t::offsets, patchPlane_t::plane, planes, patchCollide_s::planes, qboolean, sphere_t::radius, patchPlane_t::signbits, traceWork_t::sphere, traceWork_t::start, facet_t::surfacePlane, t, sphere_t::use, vec3_t, VectorAdd, VectorCopy, VectorNegate, and VectorSubtract. Referenced by CM_TestInLeaf(). 01513 {
01514 int i, j;
01515 float offset, t;
01516 patchPlane_t *planes;
01517 facet_t *facet;
01518 float plane[4];
01519 vec3_t startp;
01520
01521 if (tw->isPoint) {
01522 return qfalse;
01523 }
01524 //
01525 facet = pc->facets;
01526 for ( i = 0 ; i < pc->numFacets ; i++, facet++ ) {
01527 planes = &pc->planes[ facet->surfacePlane ];
01528 VectorCopy(planes->plane, plane);
01529 plane[3] = planes->plane[3];
01530 if ( tw->sphere.use ) {
01531 // adjust the plane distance apropriately for radius
01532 plane[3] += tw->sphere.radius;
01533
01534 // find the closest point on the capsule to the plane
01535 t = DotProduct( plane, tw->sphere.offset );
01536 if ( t > 0 ) {
01537 VectorSubtract( tw->start, tw->sphere.offset, startp );
01538 }
01539 else {
01540 VectorAdd( tw->start, tw->sphere.offset, startp );
01541 }
01542 }
01543 else {
01544 offset = DotProduct( tw->offsets[ planes->signbits ], plane);
01545 plane[3] -= offset;
01546 VectorCopy( tw->start, startp );
01547 }
01548
01549 if ( DotProduct( plane, startp ) - plane[3] > 0.0f ) {
01550 continue;
01551 }
01552
01553 for ( j = 0; j < facet->numBorders; j++ ) {
01554 planes = &pc->planes[ facet->borderPlanes[j] ];
01555 if (facet->borderInward[j]) {
01556 VectorNegate(planes->plane, plane);
01557 plane[3] = -planes->plane[3];
01558 }
01559 else {
01560 VectorCopy(planes->plane, plane);
01561 plane[3] = planes->plane[3];
01562 }
01563 if ( tw->sphere.use ) {
01564 // adjust the plane distance apropriately for radius
01565 plane[3] += tw->sphere.radius;
01566
01567 // find the closest point on the capsule to the plane
01568 t = DotProduct( plane, tw->sphere.offset );
01569 if ( t > 0.0f ) {
01570 VectorSubtract( tw->start, tw->sphere.offset, startp );
01571 }
01572 else {
01573 VectorAdd( tw->start, tw->sphere.offset, startp );
01574 }
01575 }
01576 else {
01577 // NOTE: this works even though the plane might be flipped because the bbox is centered
01578 offset = DotProduct( tw->offsets[ planes->signbits ], plane);
01579 plane[3] += fabs(offset);
01580 VectorCopy( tw->start, startp );
01581 }
01582
01583 if ( DotProduct( plane, startp ) - plane[3] > 0.0f ) {
01584 break;
01585 }
01586 }
01587 if (j < facet->numBorders) {
01588 continue;
01589 }
01590 // inside this patch facet
01591 return qtrue;
01592 }
01593 return qfalse;
01594 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 90 of file cm_test.c. References b, cbrush_t::bounds, leafList_s::bounds, clipMap_t::brushes, cbrush_t::checkcount, clipMap_t::checkcount, cm, leafList_s::count, cLeaf_t::firstLeafBrush, i, k, clipMap_t::leafbrushes, leafList_t, clipMap_t::leafs, clipMap_t::leafsurfaces, leafList_s::list, leafList_s::maxcount, cLeaf_t::numLeafBrushes, cLeaf_t::numLeafSurfaces, leafList_s::overflowed, and clipMap_t::surfaces. 00090 {
00091 int i, k;
00092 int leafnum;
00093 int brushnum;
00094 cLeaf_t *leaf;
00095 cbrush_t *b;
00096
00097 leafnum = -1 - nodenum;
00098
00099 leaf = &cm.leafs[leafnum];
00100
00101 for ( k = 0 ; k < leaf->numLeafBrushes ; k++ ) {
00102 brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];
00103 b = &cm.brushes[brushnum];
00104 if ( b->checkcount == cm.checkcount ) {
00105 continue; // already checked this brush in another leaf
00106 }
00107 b->checkcount = cm.checkcount;
00108 for ( i = 0 ; i < 3 ; i++ ) {
00109 if ( b->bounds[0][i] >= ll->bounds[1][i] || b->bounds[1][i] <= ll->bounds[0][i] ) {
00110 break;
00111 }
00112 }
00113 if ( i != 3 ) {
00114 continue;
00115 }
00116 if ( ll->count >= ll->maxcount) {
00117 ll->overflowed = qtrue;
00118 return;
00119 }
00120 ((cbrush_t **)ll->list)[ ll->count++ ] = b;
00121 }
00122 #if 0
00123 // store patches?
00124 for ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) {
00125 patch = cm.surfaces[ cm.leafsurfaces[ leaf->firstleafsurface + k ] ];
00126 if ( !patch ) {
00127 continue;
00128 }
00129 }
00130 #endif
00131 }
|
|
||||||||||||
|
Definition at line 73 of file cm_test.c. References cLeaf_t::cluster, cm, leafList_s::count, leafList_s::lastLeaf, leafList_t, clipMap_t::leafs, leafList_s::list, leafList_s::maxcount, and leafList_s::overflowed. 00073 {
00074 int leafNum;
00075
00076 leafNum = -1 - nodenum;
00077
00078 // store the lastLeaf even if the list is overflowed
00079 if ( cm.leafs[ leafNum ].cluster != -1 ) {
00080 ll->lastLeaf = leafNum;
00081 }
00082
00083 if ( ll->count >= ll->maxcount) {
00084 ll->overflowed = qtrue;
00085 return;
00086 }
00087 ll->list[ ll->count++ ] = leafNum;
00088 }
|
|
||||||||||||
|
Definition at line 1377 of file cm_patch.c. References facet_t::borderInward, facet_t::borderPlanes, CM_CheckFacetPlane(), CM_TracePointThroughPatchCollide(), Cvar_Get(), cvar_t, debugFacet, debugPatchCollide, cplane_s::dist, DotProduct, traceWork_t::end, fabs(), patchCollide_s::facets, trace_t::fraction, i, cvar_s::integer, traceWork_t::isPoint, j, cplane_s::normal, facet_t::numBorders, patchCollide_s::numFacets, sphere_t::offset, offset, traceWork_t::offsets, patchPlane_t::plane, trace_t::plane, planes, patchCollide_s::planes, sphere_t::radius, patchPlane_t::signbits, traceWork_t::sphere, traceWork_t::start, facet_t::surfacePlane, t, traceWork_t::trace, sphere_t::use, vec3_t, Vector4Copy, VectorAdd, VectorCopy, VectorNegate, and VectorSubtract. Referenced by CM_TraceThroughPatch(). 01377 {
01378 int i, j, hit, hitnum;
01379 float offset, enterFrac, leaveFrac, t;
01380 patchPlane_t *planes;
01381 facet_t *facet;
01382 float plane[4], bestplane[4];
01383 vec3_t startp, endp;
01384 #ifndef BSPC
01385 static cvar_t *cv;
01386 #endif //BSPC
01387
01388 if (tw->isPoint) {
01389 CM_TracePointThroughPatchCollide( tw, pc );
01390 return;
01391 }
01392
01393 facet = pc->facets;
01394 for ( i = 0 ; i < pc->numFacets ; i++, facet++ ) {
01395 enterFrac = -1.0;
01396 leaveFrac = 1.0;
01397 hitnum = -1;
01398 //
01399 planes = &pc->planes[ facet->surfacePlane ];
01400 VectorCopy(planes->plane, plane);
01401 plane[3] = planes->plane[3];
01402 if ( tw->sphere.use ) {
01403 // adjust the plane distance apropriately for radius
01404 plane[3] += tw->sphere.radius;
01405
01406 // find the closest point on the capsule to the plane
01407 t = DotProduct( plane, tw->sphere.offset );
01408 if ( t > 0.0f ) {
01409 VectorSubtract( tw->start, tw->sphere.offset, startp );
01410 VectorSubtract( tw->end, tw->sphere.offset, endp );
01411 }
01412 else {
01413 VectorAdd( tw->start, tw->sphere.offset, startp );
01414 VectorAdd( tw->end, tw->sphere.offset, endp );
01415 }
01416 }
01417 else {
01418 offset = DotProduct( tw->offsets[ planes->signbits ], plane);
01419 plane[3] -= offset;
01420 VectorCopy( tw->start, startp );
01421 VectorCopy( tw->end, endp );
01422 }
01423
01424 if (!CM_CheckFacetPlane(plane, startp, endp, &enterFrac, &leaveFrac, &hit)) {
01425 continue;
01426 }
01427 if (hit) {
01428 Vector4Copy(plane, bestplane);
01429 }
01430
01431 for ( j = 0; j < facet->numBorders; j++ ) {
01432 planes = &pc->planes[ facet->borderPlanes[j] ];
01433 if (facet->borderInward[j]) {
01434 VectorNegate(planes->plane, plane);
01435 plane[3] = -planes->plane[3];
01436 }
01437 else {
01438 VectorCopy(planes->plane, plane);
01439 plane[3] = planes->plane[3];
01440 }
01441 if ( tw->sphere.use ) {
01442 // adjust the plane distance apropriately for radius
01443 plane[3] += tw->sphere.radius;
01444
01445 // find the closest point on the capsule to the plane
01446 t = DotProduct( plane, tw->sphere.offset );
01447 if ( t > 0.0f ) {
01448 VectorSubtract( tw->start, tw->sphere.offset, startp );
01449 VectorSubtract( tw->end, tw->sphere.offset, endp );
01450 }
01451 else {
01452 VectorAdd( tw->start, tw->sphere.offset, startp );
01453 VectorAdd( tw->end, tw->sphere.offset, endp );
01454 }
01455 }
01456 else {
01457 // NOTE: this works even though the plane might be flipped because the bbox is centered
01458 offset = DotProduct( tw->offsets[ planes->signbits ], plane);
01459 plane[3] += fabs(offset);
01460 VectorCopy( tw->start, startp );
01461 VectorCopy( tw->end, endp );
01462 }
01463
01464 if (!CM_CheckFacetPlane(plane, startp, endp, &enterFrac, &leaveFrac, &hit)) {
01465 break;
01466 }
01467 if (hit) {
01468 hitnum = j;
01469 Vector4Copy(plane, bestplane);
01470 }
01471 }
01472 if (j < facet->numBorders) continue;
01473 //never clip against the back side
01474 if (hitnum == facet->numBorders - 1) continue;
01475
01476 if (enterFrac < leaveFrac && enterFrac >= 0) {
01477 if (enterFrac < tw->trace.fraction) {
01478 if (enterFrac < 0) {
01479 enterFrac = 0;
01480 }
01481 #ifndef BSPC
01482 if (!cv) {
01483 cv = Cvar_Get( "r_debugSurfaceUpdate", "1", 0 );
01484 }
01485 if (cv && cv->integer) {
01486 debugPatchCollide = pc;
01487 debugFacet = facet;
01488 }
01489 #endif //BSPC
01490
01491 tw->trace.fraction = enterFrac;
01492 VectorCopy( bestplane, tw->trace.plane.normal );
01493 tw->trace.plane.dist = bestplane[3];
01494 }
01495 }
01496 }
01497 }
|
Here is the call graph for this function:

|
|
Definition at line 56 of file cm_load.c. Referenced by CM_TraceThroughBrush(), and Com_Frame(). |
|
|
Definition at line 56 of file cm_load.c. Referenced by CM_TraceThroughPatch(), and Com_Frame(). |
|
|
Definition at line 55 of file cm_load.c. Referenced by CM_PointLeafnum_r(), and Com_Frame(). |
|
|
Definition at line 56 of file cm_load.c. Referenced by CM_Trace(), and Com_Frame(). |
|
|
|
Definition at line 62 of file cm_load.c. Referenced by CM_AreasConnected(), CM_LoadMap(), and CM_WriteAreaBits(). |
|
|
Definition at line 63 of file cm_load.c. Referenced by CM_LoadMap(), CM_TestInLeaf(), and CM_TraceThroughLeaf(). |
|
|
Definition at line 64 of file cm_load.c. Referenced by CM_LoadMap(), and CM_TracePointThroughPatchCollide(). |
1.3.9.1