Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

cm_patch.h File Reference

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

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  cGrid_t
struct  facet_t
struct  patchCollide_s
struct  patchPlane_t

Defines

#define MAX_FACETS   1024
#define MAX_GRID_SIZE   129
#define MAX_PATCH_PLANES   2048
#define PLANE_TRI_EPSILON   0.1
#define SUBDIVIDE_DISTANCE   16
#define WRAP_POINT_EPSILON   0.1

Typedefs

typedef patchCollide_s patchCollide_t

Functions

patchCollide_sCM_GeneratePatchCollide (int width, int height, vec3_t *points)


Define Documentation

#define MAX_FACETS   1024
 

Definition at line 63 of file cm_patch.h.

Referenced by VL_InitSurfacesForTesting(), and VS_InitSurfacesForTesting().

#define MAX_GRID_SIZE   129
 

Definition at line 88 of file cm_patch.h.

Referenced by CM_GeneratePatchCollide().

#define MAX_PATCH_PLANES   2048
 

Definition at line 64 of file cm_patch.h.

#define PLANE_TRI_EPSILON   0.1
 

Definition at line 99 of file cm_patch.h.

Referenced by CM_FindPlane().

#define SUBDIVIDE_DISTANCE   16
 

Definition at line 98 of file cm_patch.h.

#define WRAP_POINT_EPSILON   0.1
 

Definition at line 100 of file cm_patch.h.

Referenced by CM_SetGridWrapWidth().


Typedef Documentation

typedef struct patchCollide_s patchCollide_t
 

Referenced by AAS_CreateCurveBrushes(), CM_DrawDebugSurface(), CM_GeneratePatchCollide(), and CM_PatchCollideFromGrid().


Function Documentation

struct patchCollide_s* CM_GeneratePatchCollide int  width,
int  height,
vec3_t points
 

Definition at line 1148 of file cm_patch.c.

References AddPointToBounds(), c_totalPatchBlocks, ClearBounds(), CM_PatchCollideFromGrid(), CM_RemoveDegenerateColumns(), CM_SetGridWrapWidth(), CM_SubdivideGridColumns(), CM_TransposeGrid(), Com_Error(), ERR_DROP, h_high, height, Hunk_Alloc(), i, j, MAX_GRID_SIZE, patchCollide_t, pf, points, VectorCopy, and width.

Referenced by AAS_CreateCurveBrushes(), and CMod_LoadPatches().

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 }

Here is the call graph for this function:


Generated on Thu Aug 25 14:36:39 2005 for Quake III Arena by  doxygen 1.3.9.1