Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

cm_patch.h (3173B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 GNU General Public License for more details.
     16 
     17 You should have received a copy of the GNU General Public License
     18 along with Foobar; if not, write to the Free Software
     19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20 ===========================================================================
     21 */
     22 
     23 //#define	CULL_BBOX
     24 
     25 /*
     26 
     27 This file does not reference any globals, and has these entry points:
     28 
     29 void CM_ClearLevelPatches( void );
     30 struct patchCollide_s	*CM_GeneratePatchCollide( int width, int height, const vec3_t *points );
     31 void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );
     32 qboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );
     33 void CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, flaot *points) );
     34 
     35 
     36 Issues for collision against curved surfaces:
     37 
     38 Surface edges need to be handled differently than surface planes
     39 
     40 Plane expansion causes raw surfaces to expand past expanded bounding box
     41 
     42 Position test of a volume against a surface is tricky.
     43 
     44 Position test of a point against a surface is not well defined, because the surface has no volume.
     45 
     46 
     47 Tracing leading edge points instead of volumes?
     48 Position test by tracing corner to corner? (8*7 traces -- ouch)
     49 
     50 coplanar edges
     51 triangulated patches
     52 degenerate patches
     53 
     54   endcaps
     55   degenerate
     56 
     57 WARNING: this may misbehave with meshes that have rows or columns that only
     58 degenerate a few triangles.  Completely degenerate rows and columns are handled
     59 properly.
     60 */
     61 
     62 
     63 #define	MAX_FACETS			1024
     64 #define	MAX_PATCH_PLANES	2048
     65 
     66 typedef struct {
     67 	float	plane[4];
     68 	int		signbits;		// signx + (signy<<1) + (signz<<2), used as lookup during collision
     69 } patchPlane_t;
     70 
     71 typedef struct {
     72 	int			surfacePlane;
     73 	int			numBorders;		// 3 or four + 6 axial bevels + 4 or 3 * 4 edge bevels
     74 	int			borderPlanes[4+6+16];
     75 	int			borderInward[4+6+16];
     76 	qboolean	borderNoAdjust[4+6+16];
     77 } facet_t;
     78 
     79 typedef struct patchCollide_s {
     80 	vec3_t	bounds[2];
     81 	int		numPlanes;			// surface planes plus edge planes
     82 	patchPlane_t	*planes;
     83 	int		numFacets;
     84 	facet_t	*facets;
     85 } patchCollide_t;
     86 
     87 
     88 #define	MAX_GRID_SIZE	129
     89 
     90 typedef struct {
     91 	int			width;
     92 	int			height;
     93 	qboolean	wrapWidth;
     94 	qboolean	wrapHeight;
     95 	vec3_t	points[MAX_GRID_SIZE][MAX_GRID_SIZE];	// [width][height]
     96 } cGrid_t;
     97 
     98 #define	SUBDIVIDE_DISTANCE	16	//4	// never more than this units away from curve
     99 #define	PLANE_TRI_EPSILON	0.1
    100 #define	WRAP_POINT_EPSILON	0.1
    101 
    102 
    103 struct patchCollide_s	*CM_GeneratePatchCollide( int width, int height, vec3_t *points );