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