ScummVM API documentation
dgPolygonSoupBuilder.h
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /****************************************************************************
23 *
24 * Visual C++ 6.0 created by: Julio Jerez
25 *
26 ****************************************************************************/
27 #ifndef __dgPolygonSoupDatabaseBuilder0x23413452233__
28 #define __dgPolygonSoupDatabaseBuilder0x23413452233__
29 
30 
31 #include "dgStdafx.h"
32 #include "dgRef.h"
33 #include "dgArray.h"
34 #include "dgIntersections.h"
35 
36 
38 public:
39  dgInt32 m_count;
40  dgInt32 *m_index;
41  dgPlane m_normal;
42  dgInt64 m_edgeMap[256];
43 };
44 
46 public:
49 
50  DG_CLASS_ALLOCATOR(allocator)
51 
52  void Begin();
53  void End(bool optimize);
54  void AddMesh(const dgFloat32 *const vertex, dgInt32 vertexCount, dgInt32 strideInBytes, dgInt32 faceCount,
55  const dgInt32 *const faceArray, const dgInt32 *const indexArray, const dgInt32 *const faceTagsData, const dgMatrix &worldMatrix);
56 
57  void SingleFaceFixup();
58 
59 private:
60 
61  void Optimize(bool optimize);
62  void EndAndOptimize(bool optimize);
63  void OptimizeByGroupID();
64  void OptimizeByIndividualFaces();
65  dgInt32 FilterFace(dgInt32 count, dgInt32 *const indexArray);
66  dgInt32 AddConvexFace(dgInt32 count, dgInt32 *const indexArray, dgInt32 *const facesArray);
67  void OptimizeByGroupID(dgPolygonSoupDatabaseBuilder &source, dgInt32 faceNumber, dgInt32 faceIndexNumber, dgPolygonSoupDatabaseBuilder &leftOver);
68 
69  void PackArray();
70 
71 // void WriteDebugOutput (const char* name);
72 
73 public:
74  struct VertexArray: public dgArray<dgBigVector> {
75  VertexArray(dgMemoryAllocator *const allocator)
76  : dgArray<dgBigVector>(1024 * 256, allocator) {
77  }
78  };
79 
80  struct IndexArray: public dgArray<dgInt32> {
81  IndexArray(dgMemoryAllocator *const allocator)
82  : dgArray<dgInt32>(1024 * 256, allocator) {
83  }
84  };
85 
86  dgInt32 m_run;
87  dgInt32 m_faceCount;
88  dgInt32 m_indexCount;
89  dgInt32 m_vertexCount;
90  dgInt32 m_normalCount;
91  IndexArray m_faceVertexCount;
92  IndexArray m_vertexIndex;
93  IndexArray m_normalIndex;
94  VertexArray m_vertexPoints;
95  VertexArray m_normalPoints;
96  dgMemoryAllocator *m_allocator;
97 
98 };
99 
100 
101 
102 
103 
104 #endif
105 
Definition: dgPlane.h:29
Definition: dgPolygonSoupBuilder.h:74
Definition: dgPolygonSoupBuilder.h:37
Definition: dgPolygonSoupBuilder.h:45
Definition: dgArray.h:33
Definition: dgPolygonSoupBuilder.h:80
Definition: dgMatrix.h:41
Definition: dgMemory.h:80