#include "qfiles.h"
Include dependency graph for cm_public.h:

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

Go to the source code of this file.
Functions | |
| void | CM_AdjustAreaPortalState (int area1, int area2, qboolean open) |
| qboolean | CM_AreasConnected (int area1, int area2) |
| int | CM_BoxLeafnums (const vec3_t mins, const vec3_t maxs, int *list, int listsize, int *lastLeaf) |
| void | CM_BoxTrace (trace_t *results, const vec3_t start, const vec3_t end, vec3_t mins, vec3_t maxs, clipHandle_t model, int brushmask, int capsule) |
| void | CM_ClearMap (void) |
| byte * | CM_ClusterPVS (int cluster) |
| void | CM_DrawDebugSurface (void(*drawPoly)(int color, int numPoints, float *points)) |
| char * | CM_EntityString (void) |
| clipHandle_t | CM_InlineModel (int index) |
| int | CM_LeafArea (int leafnum) |
| int | CM_LeafCluster (int leafnum) |
| int | CM_LerpTag (orientation_t *tag, clipHandle_t model, int startFrame, int endFrame, float frac, const char *tagName) |
| void | CM_LoadMap (const char *name, qboolean clientload, int *checksum) |
| int | CM_MarkFragments (int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer) |
| void | CM_ModelBounds (clipHandle_t model, vec3_t mins, vec3_t maxs) |
| int | CM_NumClusters (void) |
| int | CM_NumInlineModels (void) |
| int | CM_PointContents (const vec3_t p, clipHandle_t model) |
| int | CM_PointLeafnum (const vec3_t p) |
| clipHandle_t | CM_TempBoxModel (const vec3_t mins, const vec3_t maxs, int capsule) |
| void | CM_TransformedBoxTrace (trace_t *results, const vec3_t start, const vec3_t end, vec3_t mins, vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles, int capsule) |
| int | CM_TransformedPointContents (const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles) |
| int | CM_WriteAreaBits (byte *buffer, int area) |
|
||||||||||||||||
|
Definition at line 385 of file cm_test.c. References clipMap_t::areaPortals, cm, CM_FloodAreaConnections(), Com_Error(), ERR_DROP, and clipMap_t::numAreas. Referenced by SV_AdjustAreaPortalState(). 00385 {
00386 if ( area1 < 0 || area2 < 0 ) {
00387 return;
00388 }
00389
00390 if ( area1 >= cm.numAreas || area2 >= cm.numAreas ) {
00391 Com_Error (ERR_DROP, "CM_ChangeAreaPortalState: bad area number");
00392 }
00393
00394 if ( open ) {
00395 cm.areaPortals[ area1 * cm.numAreas + area2 ]++;
00396 cm.areaPortals[ area2 * cm.numAreas + area1 ]++;
00397 } else {
00398 cm.areaPortals[ area1 * cm.numAreas + area2 ]--;
00399 cm.areaPortals[ area2 * cm.numAreas + area1 ]--;
00400 if ( cm.areaPortals[ area2 * cm.numAreas + area1 ] < 0 ) {
00401 Com_Error (ERR_DROP, "CM_AdjustAreaPortalState: negative reference count");
00402 }
00403 }
00404
00405 CM_FloodAreaConnections ();
00406 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 414 of file cm_test.c. References clipMap_t::areas, cm, cm_noAreas, Com_Error(), ERR_DROP, cArea_t::floodnum, cvar_s::integer, clipMap_t::numAreas, and qboolean. Referenced by SV_AddEntitiesVisibleFromPoint(), SV_GameSystemCalls(), and SV_inPVS(). 00414 {
00415 #ifndef BSPC
00416 if ( cm_noAreas->integer ) {
00417 return qtrue;
00418 }
00419 #endif
00420
00421 if ( area1 < 0 || area2 < 0 ) {
00422 return qfalse;
00423 }
00424
00425 if (area1 >= cm.numAreas || area2 >= cm.numAreas) {
00426 Com_Error (ERR_DROP, "area >= cm.numAreas");
00427 }
00428
00429 if (cm.areas[area1].floodnum == cm.areas[area2].floodnum) {
00430 return qtrue;
00431 }
00432 return qfalse;
00433 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 172 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. Referenced by SV_LinkEntity(). 00172 {
00173 leafList_t ll;
00174
00175 cm.checkcount++;
00176
00177 VectorCopy( mins, ll.bounds[0] );
00178 VectorCopy( maxs, ll.bounds[1] );
00179 ll.count = 0;
00180 ll.maxcount = listsize;
00181 ll.list = list;
00182 ll.storeLeafs = CM_StoreLeafs;
00183 ll.lastLeaf = 0;
00184 ll.overflowed = qfalse;
00185
00186 CM_BoxLeafnums_r( &ll, 0 );
00187
00188 *lastLeaf = ll.lastLeaf;
00189 return ll.count;
00190 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||
|
Definition at line 1367 of file cm_trace.c. References CM_Trace(), NULL, and vec3_origin. Referenced by BotImport_Trace(), CL_CgameSystemCalls(), and SV_Trace(). 01369 {
01370 CM_Trace( results, start, end, mins, maxs, model, vec3_origin, brushmask, capsule, NULL );
01371 }
|
Here is the call graph for this function:

|
|
Definition at line 665 of file cm_load.c. References cm, CM_ClearLevelPatches(), and Com_Memset(). Referenced by CL_FlushMemory(), and SV_SpawnServer(). 00665 {
00666 Com_Memset( &cm, 0, sizeof( cm ) );
00667 CM_ClearLevelPatches();
00668 }
|
Here is the call graph for this function:

|
|
Definition at line 312 of file cm_test.c. References byte, clipMap_t::clusterBytes, cm, clipMap_t::numClusters, clipMap_t::vised, and clipMap_t::visibility. Referenced by R_inPVS(), SV_AddEntitiesVisibleFromPoint(), SV_inPVS(), and SV_inPVSIgnorePortals(). 00312 {
00313 if (cluster < 0 || cluster >= cm.numClusters || !cm.vised ) {
00314 return cm.visibility;
00315 }
00316
00317 return cm.visibility + cluster * cm.clusterBytes;
00318 }
|
|
|
Definition at line 1616 of file cm_patch.c. References BaseWindingForPlane(), facet_t::borderInward, facet_t::borderPlanes, BotDrawDebugPolygons(), patchCollide_s::bounds, ChopWindingInPlace(), Com_Printf(), Cvar_Get(), cvar_t, debugBlockPoints, DotProduct, f, fabs(), patchCollide_s::facets, FreeWinding(), i, cvar_s::integer, j, k, n, facet_t::numBorders, patchCollide_s::numFacets, winding_t::numpoints, winding_t::p, patchCollide_t, patchPlane_t::plane, patchCollide_s::planes, facet_t::surfacePlane, v, v1, v2, cvar_s::value, vec3_origin, vec3_t, Vector4Copy, VectorCopy, VectorNegate, VectorSubtract, and w. 01616 {
01617 static cvar_t *cv;
01618 #ifndef BSPC
01619 static cvar_t *cv2;
01620 #endif
01621 const patchCollide_t *pc;
01622 facet_t *facet;
01623 winding_t *w;
01624 int i, j, k, n;
01625 int curplanenum, planenum, curinward, inward;
01626 float plane[4];
01627 vec3_t mins = {-15, -15, -28}, maxs = {15, 15, 28};
01628 //vec3_t mins = {0, 0, 0}, maxs = {0, 0, 0};
01629 vec3_t v1, v2;
01630
01631 #ifndef BSPC
01632 if ( !cv2 )
01633 {
01634 cv2 = Cvar_Get( "r_debugSurface", "0", 0 );
01635 }
01636
01637 if (cv2->integer != 1)
01638 {
01639 BotDrawDebugPolygons(drawPoly, cv2->integer);
01640 return;
01641 }
01642 #endif
01643
01644 if ( !debugPatchCollide ) {
01645 return;
01646 }
01647
01648 #ifndef BSPC
01649 if ( !cv ) {
01650 cv = Cvar_Get( "cm_debugSize", "2", 0 );
01651 }
01652 #endif
01653 pc = debugPatchCollide;
01654
01655 for ( i = 0, facet = pc->facets ; i < pc->numFacets ; i++, facet++ ) {
01656
01657 for ( k = 0 ; k < facet->numBorders + 1; k++ ) {
01658 //
01659 if (k < facet->numBorders) {
01660 planenum = facet->borderPlanes[k];
01661 inward = facet->borderInward[k];
01662 }
01663 else {
01664 planenum = facet->surfacePlane;
01665 inward = qfalse;
01666 //continue;
01667 }
01668
01669 Vector4Copy( pc->planes[ planenum ].plane, plane );
01670
01671 //planenum = facet->surfacePlane;
01672 if ( inward ) {
01673 VectorSubtract( vec3_origin, plane, plane );
01674 plane[3] = -plane[3];
01675 }
01676
01677 plane[3] += cv->value;
01678 //*
01679 for (n = 0; n < 3; n++)
01680 {
01681 if (plane[n] > 0) v1[n] = maxs[n];
01682 else v1[n] = mins[n];
01683 } //end for
01684 VectorNegate(plane, v2);
01685 plane[3] += fabs(DotProduct(v1, v2));
01686 //*/
01687
01688 w = BaseWindingForPlane( plane, plane[3] );
01689 for ( j = 0 ; j < facet->numBorders + 1 && w; j++ ) {
01690 //
01691 if (j < facet->numBorders) {
01692 curplanenum = facet->borderPlanes[j];
01693 curinward = facet->borderInward[j];
01694 }
01695 else {
01696 curplanenum = facet->surfacePlane;
01697 curinward = qfalse;
01698 //continue;
01699 }
01700 //
01701 if (curplanenum == planenum) continue;
01702
01703 Vector4Copy( pc->planes[ curplanenum ].plane, plane );
01704 if ( !curinward ) {
01705 VectorSubtract( vec3_origin, plane, plane );
01706 plane[3] = -plane[3];
01707 }
01708 // if ( !facet->borderNoAdjust[j] ) {
01709 plane[3] -= cv->value;
01710 // }
01711 for (n = 0; n < 3; n++)
01712 {
01713 if (plane[n] > 0) v1[n] = maxs[n];
01714 else v1[n] = mins[n];
01715 } //end for
01716 VectorNegate(plane, v2);
01717 plane[3] -= fabs(DotProduct(v1, v2));
01718
01719 ChopWindingInPlace( &w, plane, plane[3], 0.1f );
01720 }
01721 if ( w ) {
01722 if ( facet == debugFacet ) {
01723 drawPoly( 4, w->numpoints, w->p[0] );
01724 //Com_Printf("blue facet has %d border planes\n", facet->numBorders);
01725 } else {
01726 drawPoly( 1, w->numpoints, w->p[0] );
01727 }
01728 FreeWinding( w );
01729 }
01730 else
01731 Com_Printf("winding chopped away by border planes\n");
01732 }
01733 }
01734
01735 // draw the debug block
01736 {
01737 vec3_t v[3];
01738
01739 VectorCopy( debugBlockPoints[0], v[0] );
01740 VectorCopy( debugBlockPoints[1], v[1] );
01741 VectorCopy( debugBlockPoints[2], v[2] );
01742 drawPoly( 2, 3, v[0] );
01743
01744 VectorCopy( debugBlockPoints[2], v[0] );
01745 VectorCopy( debugBlockPoints[3], v[1] );
01746 VectorCopy( debugBlockPoints[0], v[2] );
01747 drawPoly( 2, 3, v[0] );
01748 }
01749
01750 #if 0
01751 vec3_t v[4];
01752
01753 v[0][0] = pc->bounds[1][0];
01754 v[0][1] = pc->bounds[1][1];
01755 v[0][2] = pc->bounds[1][2];
01756
01757 v[1][0] = pc->bounds[1][0];
01758 v[1][1] = pc->bounds[0][1];
01759 v[1][2] = pc->bounds[1][2];
01760
01761 v[2][0] = pc->bounds[0][0];
01762 v[2][1] = pc->bounds[0][1];
01763 v[2][2] = pc->bounds[1][2];
01764
01765 v[3][0] = pc->bounds[0][0];
01766 v[3][1] = pc->bounds[1][1];
01767 v[3][2] = pc->bounds[1][2];
01768
01769 drawPoly( 4, v[0] );
01770 #endif
01771 }
|
Here is the call graph for this function:

|
|
Definition at line 715 of file cm_load.c. References cm, and clipMap_t::entityString. Referenced by BotImport_BSPEntityData(), and SV_InitGameVM(). 00715 {
00716 return cm.entityString;
00717 }
|
|
|
Definition at line 700 of file cm_load.c. References clipHandle_t, cm, Com_Error(), ERR_DROP, and clipMap_t::numSubModels. Referenced by AAS_CalcReachAndClusters(), BotImport_BSPModelMinsMaxsOrigin(), CL_CgameSystemCalls(), SV_ClearWorld(), SV_ClipHandleForEntity(), and SV_SetBrushModel(). 00700 {
00701 if ( index < 0 || index >= cm.numSubModels ) {
00702 Com_Error (ERR_DROP, "CM_InlineModel: bad number");
00703 }
00704 return index;
00705 }
|
Here is the call graph for this function:

|
|
Definition at line 726 of file cm_load.c. References cLeaf_t::area, cm, Com_Error(), ERR_DROP, clipMap_t::leafs, and clipMap_t::numLeafs. Referenced by SV_AddEntitiesVisibleFromPoint(), SV_inPVS(), SV_inPVSIgnorePortals(), and SV_LinkEntity(). 00726 {
00727 if ( leafnum < 0 || leafnum >= cm.numLeafs ) {
00728 Com_Error (ERR_DROP, "CM_LeafArea: bad number");
00729 }
00730 return cm.leafs[leafnum].area;
00731 }
|
Here is the call graph for this function:

|
|
Definition at line 719 of file cm_load.c. References cLeaf_t::cluster, cm, Com_Error(), ERR_DROP, clipMap_t::leafs, and clipMap_t::numLeafs. Referenced by SV_AddEntitiesVisibleFromPoint(), SV_inPVS(), SV_inPVSIgnorePortals(), and SV_LinkEntity(). 00719 {
00720 if (leafnum < 0 || leafnum >= cm.numLeafs) {
00721 Com_Error (ERR_DROP, "CM_LeafCluster: bad number");
00722 }
00723 return cm.leafs[leafnum].cluster;
00724 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 569 of file cm_load.c. References BSP_VERSION, byte, cm, CM_ClearLevelPatches(), CM_FloodAreaConnections(), CM_InitBoxHull(), cm_noAreas, cm_noCurves, cm_playerCurveClip, cmod_base, CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadEntityString(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadLeafSurfaces(), CMod_LoadNodes(), CMod_LoadPatches(), CMod_LoadPlanes(), CMod_LoadShaders(), CMod_LoadSubmodels(), CMod_LoadVisibility(), clipMap_t::cmodels, Com_BlockChecksum(), Com_DPrintf(), Com_Error(), Com_Memset(), CVAR_ARCHIVE, CVAR_CHEAT, Cvar_Get(), ERR_DROP, FS_FreeFile(), FS_ReadFile(), h_high, header, Hunk_Alloc(), i, length(), LittleLong(), LoadQuakeFile(), LUMP_BRUSHES, LUMP_BRUSHSIDES, LUMP_DRAWVERTS, LUMP_ENTITIES, LUMP_LEAFBRUSHES, LUMP_LEAFS, LUMP_LEAFSURFACES, LUMP_MODELS, LUMP_NODES, LUMP_PLANES, LUMP_SHADERS, LUMP_SURFACES, LUMP_VISIBILITY, dheader_t::lumps, clipMap_t::name, name, clipMap_t::numAreas, clipMap_t::numClusters, clipMap_t::numLeafs, Q_strncpyz(), quakefile_t, strcmp(), and dheader_t::version. Referenced by AAS_CalcReachAndClusters(), CL_CM_LoadMap(), and SV_SpawnServer(). 00569 {
00570 int *buf;
00571 int i;
00572 dheader_t header;
00573 int length;
00574 static unsigned last_checksum;
00575
00576 if ( !name || !name[0] ) {
00577 Com_Error( ERR_DROP, "CM_LoadMap: NULL name" );
00578 }
00579
00580 #ifndef BSPC
00581 cm_noAreas = Cvar_Get ("cm_noAreas", "0", CVAR_CHEAT);
00582 cm_noCurves = Cvar_Get ("cm_noCurves", "0", CVAR_CHEAT);
00583 cm_playerCurveClip = Cvar_Get ("cm_playerCurveClip", "1", CVAR_ARCHIVE|CVAR_CHEAT );
00584 #endif
00585 Com_DPrintf( "CM_LoadMap( %s, %i )\n", name, clientload );
00586
00587 if ( !strcmp( cm.name, name ) && clientload ) {
00588 *checksum = last_checksum;
00589 return;
00590 }
00591
00592 // free old stuff
00593 Com_Memset( &cm, 0, sizeof( cm ) );
00594 CM_ClearLevelPatches();
00595
00596 if ( !name[0] ) {
00597 cm.numLeafs = 1;
00598 cm.numClusters = 1;
00599 cm.numAreas = 1;
00600 cm.cmodels = Hunk_Alloc( sizeof( *cm.cmodels ), h_high );
00601 *checksum = 0;
00602 return;
00603 }
00604
00605 //
00606 // load the file
00607 //
00608 #ifndef BSPC
00609 length = FS_ReadFile( name, (void **)&buf );
00610 #else
00611 length = LoadQuakeFile((quakefile_t *) name, (void **)&buf);
00612 #endif
00613
00614 if ( !buf ) {
00615 Com_Error (ERR_DROP, "Couldn't load %s", name);
00616 }
00617
00618 last_checksum = LittleLong (Com_BlockChecksum (buf, length));
00619 *checksum = last_checksum;
00620
00621 header = *(dheader_t *)buf;
00622 for (i=0 ; i<sizeof(dheader_t)/4 ; i++) {
00623 ((int *)&header)[i] = LittleLong ( ((int *)&header)[i]);
00624 }
00625
00626 if ( header.version != BSP_VERSION ) {
00627 Com_Error (ERR_DROP, "CM_LoadMap: %s has wrong version number (%i should be %i)"
00628 , name, header.version, BSP_VERSION );
00629 }
00630
00631 cmod_base = (byte *)buf;
00632
00633 // load into heap
00634 CMod_LoadShaders( &header.lumps[LUMP_SHADERS] );
00635 CMod_LoadLeafs (&header.lumps[LUMP_LEAFS]);
00636 CMod_LoadLeafBrushes (&header.lumps[LUMP_LEAFBRUSHES]);
00637 CMod_LoadLeafSurfaces (&header.lumps[LUMP_LEAFSURFACES]);
00638 CMod_LoadPlanes (&header.lumps[LUMP_PLANES]);
00639 CMod_LoadBrushSides (&header.lumps[LUMP_BRUSHSIDES]);
00640 CMod_LoadBrushes (&header.lumps[LUMP_BRUSHES]);
00641 CMod_LoadSubmodels (&header.lumps[LUMP_MODELS]);
00642 CMod_LoadNodes (&header.lumps[LUMP_NODES]);
00643 CMod_LoadEntityString (&header.lumps[LUMP_ENTITIES]);
00644 CMod_LoadVisibility( &header.lumps[LUMP_VISIBILITY] );
00645 CMod_LoadPatches( &header.lumps[LUMP_SURFACES], &header.lumps[LUMP_DRAWVERTS] );
00646
00647 // we are NOT freeing the file, because it is cached for the ref
00648 FS_FreeFile (buf);
00649
00650 CM_InitBoxHull ();
00651
00652 CM_FloodAreaConnections ();
00653
00654 // allow this to be cached if it is loaded by the server
00655 if ( !clientload ) {
00656 Q_strncpyz( cm.name, name, sizeof( cm.name ) );
00657 }
00658 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 831 of file cm_load.c. References CM_ClipHandleToModel(), cmodel_t, cmodel_s::maxs, cmodel_s::mins, and VectorCopy. Referenced by BotImport_BSPModelMinsMaxsOrigin(), CM_TestBoundingBoxInCapsule(), CM_TestCapsuleInCapsule(), CM_TraceBoundingBoxThroughCapsule(), CM_TraceCapsuleThroughCapsule(), SV_ClearWorld(), and SV_SetBrushModel(). 00831 {
00832 cmodel_t *cmod;
00833
00834 cmod = CM_ClipHandleToModel( model );
00835 VectorCopy( cmod->mins, mins );
00836 VectorCopy( cmod->maxs, maxs );
00837 }
|
Here is the call graph for this function:

|
|
Definition at line 707 of file cm_load.c. References cm, and clipMap_t::numClusters. 00707 {
00708 return cm.numClusters;
00709 }
|
|
|
Definition at line 711 of file cm_load.c. References cm, and clipMap_t::numSubModels. Referenced by CL_CgameSystemCalls(). 00711 {
00712 return cm.numSubModels;
00713 }
|
|
||||||||||||
|
Definition at line 226 of file cm_test.c. References b, clipMap_t::brushes, cm, CM_ClipHandleToModel(), CM_PointLeafnum_r(), cmodel_t, cbrush_t::contents, d, cplane_s::dist, DotProduct, cLeaf_t::firstLeafBrush, i, k, cmodel_s::leaf, clipMap_t::leafbrushes, clipMap_t::leafs, cplane_s::normal, cLeaf_t::numLeafBrushes, clipMap_t::numNodes, cbrush_t::numsides, p, cbrushside_t::plane, and cbrush_t::sides. Referenced by BotImport_PointContents(), CL_CgameSystemCalls(), CM_TransformedPointContents(), and SV_PointContents(). 00226 {
00227 int leafnum;
00228 int i, k;
00229 int brushnum;
00230 cLeaf_t *leaf;
00231 cbrush_t *b;
00232 int contents;
00233 float d;
00234 cmodel_t *clipm;
00235
00236 if (!cm.numNodes) { // map not loaded
00237 return 0;
00238 }
00239
00240 if ( model ) {
00241 clipm = CM_ClipHandleToModel( model );
00242 leaf = &clipm->leaf;
00243 } else {
00244 leafnum = CM_PointLeafnum_r (p, 0);
00245 leaf = &cm.leafs[leafnum];
00246 }
00247
00248 contents = 0;
00249 for (k=0 ; k<leaf->numLeafBrushes ; k++) {
00250 brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];
00251 b = &cm.brushes[brushnum];
00252
00253 // see if the point is in the brush
00254 for ( i = 0 ; i < b->numsides ; i++ ) {
00255 d = DotProduct( p, b->sides[i].plane->normal );
00256 // FIXME test for Cash
00257 // if ( d >= b->sides[i].plane->dist ) {
00258 if ( d > b->sides[i].plane->dist ) {
00259 break;
00260 }
00261 }
00262
00263 if ( i == b->numsides ) {
00264 contents |= b->contents;
00265 }
00266 }
00267
00268 return contents;
00269 }
|
Here is the call graph for this function:

|
|
Definition at line 56 of file cm_test.c. References cm, CM_PointLeafnum_r(), clipMap_t::numNodes, and p. Referenced by SV_AddEntitiesVisibleFromPoint(), SV_inPVS(), and SV_inPVSIgnorePortals(). 00056 {
00057 if ( !cm.numNodes ) { // map not loaded
00058 return 0;
00059 }
00060 return CM_PointLeafnum_r (p, 0);
00061 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 798 of file cm_load.c. References cbrush_t::bounds, box_brush, box_model, box_planes, clipHandle_t, cplane_s::dist, cmodel_s::maxs, cmodel_s::mins, and VectorCopy. Referenced by CL_CgameSystemCalls(), CM_TestBoundingBoxInCapsule(), CM_TraceBoundingBoxThroughCapsule(), and SV_ClipHandleForEntity(). 00798 {
00799
00800 VectorCopy( mins, box_model.mins );
00801 VectorCopy( maxs, box_model.maxs );
00802
00803 if ( capsule ) {
00804 return CAPSULE_MODEL_HANDLE;
00805 }
00806
00807 box_planes[0].dist = maxs[0];
00808 box_planes[1].dist = -maxs[0];
00809 box_planes[2].dist = mins[0];
00810 box_planes[3].dist = -mins[0];
00811 box_planes[4].dist = maxs[1];
00812 box_planes[5].dist = -maxs[1];
00813 box_planes[6].dist = mins[1];
00814 box_planes[7].dist = -mins[1];
00815 box_planes[8].dist = maxs[2];
00816 box_planes[9].dist = -maxs[2];
00817 box_planes[10].dist = mins[2];
00818 box_planes[11].dist = -mins[2];
00819
00820 VectorCopy( mins, box_brush->bounds[0] );
00821 VectorCopy( maxs, box_brush->bounds[1] );
00822
00823 return BOX_MODEL_HANDLE;
00824 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 1381 of file cm_trace.c. References BOX_MODEL_HANDLE, CM_Trace(), CreateRotationMatrix(), trace_t::endpos, trace_t::fraction, sphere_t::halfheight, i, cplane_s::normal, offset, sphere_t::offset, trace_t::plane, qboolean, sphere_t::radius, RotatePoint(), t, TransposeMatrix(), sphere_t::use, vec3_t, VectorSet, and VectorSubtract. Referenced by CL_CgameSystemCalls(), SV_ClipMoveToEntities(), SV_ClipToEntity(), and SV_EntityContact(). 01384 {
01385 trace_t trace;
01386 vec3_t start_l, end_l;
01387 qboolean rotated;
01388 vec3_t offset;
01389 vec3_t symetricSize[2];
01390 vec3_t matrix[3], transpose[3];
01391 int i;
01392 float halfwidth;
01393 float halfheight;
01394 float t;
01395 sphere_t sphere;
01396
01397 if ( !mins ) {
01398 mins = vec3_origin;
01399 }
01400 if ( !maxs ) {
01401 maxs = vec3_origin;
01402 }
01403
01404 // adjust so that mins and maxs are always symetric, which
01405 // avoids some complications with plane expanding of rotated
01406 // bmodels
01407 for ( i = 0 ; i < 3 ; i++ ) {
01408 offset[i] = ( mins[i] + maxs[i] ) * 0.5;
01409 symetricSize[0][i] = mins[i] - offset[i];
01410 symetricSize[1][i] = maxs[i] - offset[i];
01411 start_l[i] = start[i] + offset[i];
01412 end_l[i] = end[i] + offset[i];
01413 }
01414
01415 // subtract origin offset
01416 VectorSubtract( start_l, origin, start_l );
01417 VectorSubtract( end_l, origin, end_l );
01418
01419 // rotate start and end into the models frame of reference
01420 if ( model != BOX_MODEL_HANDLE &&
01421 (angles[0] || angles[1] || angles[2]) ) {
01422 rotated = qtrue;
01423 } else {
01424 rotated = qfalse;
01425 }
01426
01427 halfwidth = symetricSize[ 1 ][ 0 ];
01428 halfheight = symetricSize[ 1 ][ 2 ];
01429
01430 sphere.use = capsule;
01431 sphere.radius = ( halfwidth > halfheight ) ? halfheight : halfwidth;
01432 sphere.halfheight = halfheight;
01433 t = halfheight - sphere.radius;
01434
01435 if (rotated) {
01436 // rotation on trace line (start-end) instead of rotating the bmodel
01437 // NOTE: This is still incorrect for bounding boxes because the actual bounding
01438 // box that is swept through the model is not rotated. We cannot rotate
01439 // the bounding box or the bmodel because that would make all the brush
01440 // bevels invalid.
01441 // However this is correct for capsules since a capsule itself is rotated too.
01442 CreateRotationMatrix(angles, matrix);
01443 RotatePoint(start_l, matrix);
01444 RotatePoint(end_l, matrix);
01445 // rotated sphere offset for capsule
01446 sphere.offset[0] = matrix[0][ 2 ] * t;
01447 sphere.offset[1] = -matrix[1][ 2 ] * t;
01448 sphere.offset[2] = matrix[2][ 2 ] * t;
01449 }
01450 else {
01451 VectorSet( sphere.offset, 0, 0, t );
01452 }
01453
01454 // sweep the box through the model
01455 CM_Trace( &trace, start_l, end_l, symetricSize[0], symetricSize[1], model, origin, brushmask, capsule, &sphere );
01456
01457 // if the bmodel was rotated and there was a collision
01458 if ( rotated && trace.fraction != 1.0 ) {
01459 // rotation of bmodel collision plane
01460 TransposeMatrix(matrix, transpose);
01461 RotatePoint(trace.plane.normal, transpose);
01462 }
01463
01464 // re-calculate the end position of the trace because the trace.endpos
01465 // calculated by CM_Trace could be rotated and have an offset
01466 trace.endpos[0] = start[0] + trace.fraction * (end[0] - start[0]);
01467 trace.endpos[1] = start[1] + trace.fraction * (end[1] - start[1]);
01468 trace.endpos[2] = start[2] + trace.fraction * (end[2] - start[2]);
01469
01470 *results = trace;
01471 }
|
Here is the call graph for this function:
