29 #include "../precompiled.h"
32 #define POLYTOPE_VERTEX_EPSILON 0.1f
41 int i,
j, k, *windingVerts;
46 memset( &newVert, 0,
sizeof( newVert ) );
48 for ( i = 0; i < numPlanes; i++ ) {
52 for ( j = 0; j < numPlanes; j++ ) {
65 for ( k = 0; k <
verts.
Num(); j++ ) {
71 newVert.
xyz = w[
j].ToVec3();
101 scale = bounds[1] - center;
105 verts[1].xyz = center + idVec3( 2.0
f * c1 * scale.
x, 0.0f, c3 * scale.
z );
106 verts[2].xyz = center + idVec3( -c1 * scale.
x, c2 * scale.
y, c3 * scale.
z );
107 verts[3].xyz = center + idVec3( -c1 * scale.
x, -c2 * scale.
y, c3 * scale.
z );
135 scale = bounds[1] - center;
139 verts[1].xyz = center + idVec3( scale.
x, -scale.
y, -scale.
z );
140 verts[2].xyz = center + idVec3( scale.
x, scale.
y, -scale.
z );
141 verts[3].xyz = center + idVec3( -scale.
x, scale.
y, -scale.
z );
142 verts[4].xyz = center + idVec3( -scale.
x, -scale.
y, scale.
z );
143 verts[5].xyz = center + idVec3( scale.
x, -scale.
y, scale.
z );
144 verts[6].xyz = center + idVec3( scale.
x, scale.
y, scale.
z );
145 verts[7].xyz = center + idVec3( -scale.
x, scale.
y, scale.
z );
197 scale = bounds[1] - center;
201 verts[1].xyz = center + idVec3( -scale.
x, 0.0f, 0.0f );
202 verts[2].xyz = center + idVec3( 0.0
f, scale.
y, 0.0f );
203 verts[3].xyz = center + idVec3( 0.0
f, -scale.
y, 0.0f );
204 verts[4].xyz = center + idVec3( 0.0
f, 0.0
f, scale.
z );
205 verts[5].xyz = center + idVec3( 0.0
f, 0.0
f, -scale.
z );
277 int *onPlaneEdges[2];
279 onPlaneEdges[0] = (
int *) _alloca(
indexes.
Num() / 3 *
sizeof(
int ) );
280 onPlaneEdges[1] = (
int *) _alloca(
indexes.
Num() / 3 *
sizeof(
int ) );
282 side =
Split( plane, epsilon, &surface[0], &surface[1], onPlaneEdges[0], onPlaneEdges[1] );
287 for ( s = 0; s < 2; s++ ) {
296 *front = polytopeSurfaces[0];
297 *back = polytopeSurfaces[1];
304 for ( s = 0; s < 2; s++ ) {
306 surf = polytopeSurfaces[
s];
312 for ( i = 1; onPlaneEdges[
s][
i] >= 0; i++ ) {
313 for ( j = i+1; onPlaneEdges[
s][
j] >= 0; j++ ) {
317 idSwap( onPlaneEdges[s][i], onPlaneEdges[s][j] );
323 for ( i = 2; onPlaneEdges[
s][
i] >= 0; i++ ) {
idList< idDrawVert > verts
idVec3 GetCenter(void) const
void SetNum(int newnum, bool resize=true)
GLenum GLenum GLenum GLenum GLenum scale
void SetupIcosahedron(const idBounds &bounds)
void SetupDodecahedron(const idBounds &bounds)
GLfloat GLfloat GLfloat v2
idList< int > edgeIndexes
int Split(const idPlane &plane, const float epsilon, idSurface **front, idSurface **back, int *frontOnPlaneEdges=NULL, int *backOnPlaneEdges=NULL) const
int GetNumPoints(void) const
#define MAX_POINTS_ON_WINDING
GLubyte GLubyte GLubyte GLubyte w
void SetupHexahedron(const idBounds &bounds)
#define INTSIGNBITNOTSET(i)
idList< surfaceEdge_t > edges
void SetupCylinder(const idBounds &bounds, const int numSides)
#define POLYTOPE_VERTEX_EPSILON
void SetupTetrahedron(const idBounds &bounds)
int SplitPolytope(const idPlane &plane, const float epsilon, idSurface_Polytope **front, idSurface_Polytope **back) const
ID_INLINE void idSwap(type &a, type &b)
int Append(const type &obj)
void GenerateEdgeIndexes(void)
void SwapTriangles(idSurface &surf)
void SetupOctahedron(const idBounds &bounds)
void FromPlanes(const idPlane *planes, const int numPlanes)
void SetupCone(const idBounds &bounds, const int numSides)
void BaseForPlane(const idVec3 &normal, const float dist)
bool ClipInPlace(const idPlane &plane, const float epsilon=ON_EPSILON, const bool keepOn=false)