My Project: dynamics.mod/NewtonDynamics/source/core/dgPolygonSoupBuilder.h Source File

My Project

dgPolygonSoupBuilder.h
Go to the documentation of this file.
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
37 class AdjacentdFaces
38 {
39 public:
40 dgInt32 m_count;
41 dgInt32 *m_index;
42 dgPlane m_normal;
43 dgInt64 m_edgeMap[256];
44 };
45
46 class dgPolygonSoupDatabaseBuilder
47 {
48 class dgFaceMap;
49 class dgFaceInfo;
50 class dgFaceBucket;
51 class dgPolySoupFilterAllocator;
52 public:
53
54 dgPolygonSoupDatabaseBuilder (dgMemoryAllocator* const allocator);
55 dgPolygonSoupDatabaseBuilder (const dgPolygonSoupDatabaseBuilder& sopurce);
56 ~dgPolygonSoupDatabaseBuilder ();
57
58 DG_CLASS_ALLOCATOR(allocator)
59
60 void Begin();
61 void End(bool optimize);
62 void AddMesh (const dgFloat32* const vertex, dgInt32 vertexCount, dgInt32 strideInBytes, dgInt32 faceCount,
63 const dgInt32* const faceArray, const dgInt32* const indexArray, const dgInt32* const faceTagsData, const dgMatrix& worldMatrix);
64
65 private:
66 void Optimize(dgInt32 faceId, const dgFaceBucket& faceBucket, const dgPolygonSoupDatabaseBuilder& source);
67
68 void Finalize();
69 void FinalizeAndOptimize();
70 void OptimizeByIndividualFaces();
71 dgInt32 FilterFace (dgInt32 count, dgInt32* const indexArray);
72 dgInt32 AddConvexFace (dgInt32 count, dgInt32* const indexArray, dgInt32* const facesArray);
73 void PackArray();
74
75
76
77 public:
78 class dgVertexArray: public dgArray<dgBigVector>
79 {
80 public:
81 dgVertexArray(dgMemoryAllocator* const allocator)
82 :dgArray<dgBigVector>(1024 * 32, allocator)
83 {
84 }
85 };
86
87 class dgIndexArray: public dgArray<dgInt32>
88 {
89 public:
90 dgIndexArray(dgMemoryAllocator* const allocator)
91 :dgArray<dgInt32>(1024 * 32, allocator)
92 {
93 }
94 };
95
96 dgInt32 m_run;
97 dgInt32 m_faceCount;
98 dgInt32 m_indexCount;
99 dgInt32 m_vertexCount;
100 dgInt32 m_normalCount;
101 dgIndexArray m_faceVertexCount;
102 dgIndexArray m_vertexIndex;
103 dgIndexArray m_normalIndex;
104 dgVertexArray m_vertexPoints;
105 dgVertexArray m_normalPoints;
106 dgMemoryAllocator* m_allocator;
107
108 };
109
110
111
112
113
114 #endif
115
dgPlane
Definition: dgPlane.h:29
AdjacentdFaces::m_normal
dgPlane m_normal
Definition: dgPolygonSoupBuilder.h:42
dgPolygonSoupDatabaseBuilder::m_vertexPoints
dgVertexArray m_vertexPoints
Definition: dgPolygonSoupBuilder.h:104
dgInt64
long long dgInt64
Definition: dgTypes.h:222
AdjacentdFaces::m_edgeMap
dgInt64 m_edgeMap[256]
Definition: dgPolygonSoupBuilder.h:43
dgPolygonSoupDatabaseBuilder::m_faceCount
dgInt32 m_faceCount
Definition: dgPolygonSoupBuilder.h:97
dgPolygonSoupDatabaseBuilder::dgIndexArray::dgIndexArray
dgIndexArray(dgMemoryAllocator *const allocator)
Definition: dgPolygonSoupBuilder.h:90
dgPolygonSoupDatabaseBuilder::m_normalIndex
dgIndexArray m_normalIndex
Definition: dgPolygonSoupBuilder.h:103
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgPolygonSoupDatabaseBuilder::dgVertexArray::dgVertexArray
dgVertexArray(dgMemoryAllocator *const allocator)
Definition: dgPolygonSoupBuilder.h:81
dgPolygonSoupDatabaseBuilder::m_vertexIndex
dgIndexArray m_vertexIndex
Definition: dgPolygonSoupBuilder.h:102
DG_CLASS_ALLOCATOR
#define DG_CLASS_ALLOCATOR(allocator)
Definition: dgMemory.h:60
AdjacentdFaces
Definition: dgPolygonSoupBuilder.h:37
dgPolygonSoupDatabaseBuilder
Definition: dgPolygonSoupBuilder.h:46
dgPolygonSoupDatabaseBuilder::m_indexCount
dgInt32 m_indexCount
Definition: dgPolygonSoupBuilder.h:98
dgPolygonSoupDatabaseBuilder::dgFaceMap
Definition: dgPolygonSoupBuilder.cpp:54
dgPolygonSoupDatabaseBuilder::m_vertexCount
dgInt32 m_vertexCount
Definition: dgPolygonSoupBuilder.h:99
dgStdafx.h
dgPolygonSoupDatabaseBuilder::dgFaceInfo
Definition: dgPolygonSoupBuilder.cpp:38
dgPolygonSoupDatabaseBuilder::dgFaceBucket
Definition: dgPolygonSoupBuilder.cpp:45
dgArray
Definition: dgArray.h:33
AdjacentdFaces::m_count
dgInt32 m_count
Definition: dgPolygonSoupBuilder.h:40
AdjacentdFaces::m_index
dgInt32 * m_index
Definition: dgPolygonSoupBuilder.h:41
dgPolygonSoupDatabaseBuilder::m_allocator
dgMemoryAllocator * m_allocator
Definition: dgPolygonSoupBuilder.h:106
dgPolygonSoupDatabaseBuilder::m_normalCount
dgInt32 m_normalCount
Definition: dgPolygonSoupBuilder.h:100
dgPolygonSoupDatabaseBuilder::dgIndexArray
Definition: dgPolygonSoupBuilder.h:87
dgPolygonSoupDatabaseBuilder::m_faceVertexCount
dgIndexArray m_faceVertexCount
Definition: dgPolygonSoupBuilder.h:101
dgPolygonSoupDatabaseBuilder::dgPolySoupFilterAllocator
Definition: dgPolygonSoupBuilder.cpp:85
dgPolygonSoupDatabaseBuilder::dgVertexArray
Definition: dgPolygonSoupBuilder.h:78
dgMatrix
Definition: dgMatrix.h:40
dgMemoryAllocator
Definition: dgMemory.h:73
dgPolygonSoupDatabaseBuilder::m_normalPoints
dgVertexArray m_normalPoints
Definition: dgPolygonSoupBuilder.h:105
dgBigVector
Definition: dgVector.h:207
dgIntersections.h
dgArray.h
dgPolygonSoupDatabaseBuilder::m_run
dgInt32 m_run
Definition: dgPolygonSoupBuilder.h:96
dgRef.h