RavEngine
Loading...
Searching...
No Matches
GuEdgeList.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef GU_EDGE_LIST_H
30#define GU_EDGE_LIST_H
31
32#include "foundation/PxSimpleTypes.h"
33#include "common/PxPhysXCommonConfig.h"
34
35#include "foundation/Px.h"
36#include "foundation/PxUserAllocated.h"
37
38namespace physx
39{
40namespace Gu
41{
43 {
44 PX_EDGE_UNDEFINED,
45
49
50 PX_EDGE_FORCE_DWORD = 0x7fffffff
51 };
52
53 enum EdgeFlag
54 {
55 PX_EDGE_ACTIVE = (1<<0)
56 };
57
59 struct EdgeData
60 {
61 PxU32 Ref0;
62 PxU32 Ref1;
63 };
64 PX_COMPILE_TIME_ASSERT(sizeof(EdgeData) == 8);
65
67 struct Edge8Data
68 {
69 PxU8 Ref0;
70 PxU8 Ref1;
71 };
73
76 {
77 PxU16 Flags;
78 PxU16 Count;
79 PxU32 Offset;
80 };
82
85 {
86 PxU32 mLink[3];
87 };
89
90 enum
91 {
92 MSH_EDGE_LINK_MASK = 0x0fffffff,
93 MSH_ACTIVE_EDGE_MASK = 0x80000000,
94 MSH_ACTIVE_VERTEX_MASK = 0x40000000
95 };
96
98 {
99 public:
100 PX_INLINE static PxU32 GetEdge01(const EdgeTriangleData& data) { return data.mLink[0] & MSH_EDGE_LINK_MASK; }
101 PX_INLINE static PxU32 GetEdge12(const EdgeTriangleData& data) { return data.mLink[1] & MSH_EDGE_LINK_MASK; }
102 PX_INLINE static PxU32 GetEdge20(const EdgeTriangleData& data) { return data.mLink[2] & MSH_EDGE_LINK_MASK; }
103 PX_INLINE static PxU32 GetEdge(const EdgeTriangleData& data, PxU32 i) { return data.mLink[i] & MSH_EDGE_LINK_MASK; }
104
105 PX_INLINE static PxIntBool HasActiveEdge01(const EdgeTriangleData& data) { return PxIntBool(data.mLink[0] & MSH_ACTIVE_EDGE_MASK); }
106 PX_INLINE static PxIntBool HasActiveEdge12(const EdgeTriangleData& data) { return PxIntBool(data.mLink[1] & MSH_ACTIVE_EDGE_MASK); }
107 PX_INLINE static PxIntBool HasActiveEdge20(const EdgeTriangleData& data) { return PxIntBool(data.mLink[2] & MSH_ACTIVE_EDGE_MASK); }
108 PX_INLINE static PxIntBool HasActiveEdge(const EdgeTriangleData& data, PxU32 i) { return PxIntBool(data.mLink[i] & MSH_ACTIVE_EDGE_MASK); }
109 };
110
113 {
115 NbFaces (0),
116 DFaces (NULL),
117 WFaces (NULL),
118 FacesToEdges (false),
119 EdgesToFaces (false),
120 Verts (NULL),
121 Epsilon (0.1f)
122 {}
123
124 PxU32 NbFaces;
125 const PxU32* DFaces;
126 const PxU16* WFaces;
127
128 bool FacesToEdges;
129 bool EdgesToFaces;
130 const PxVec3* Verts;
131 float Epsilon;
132 };
133
135 {
136 public:
137 PX_PHYSX_COMMON_API EdgeList();
138 PX_PHYSX_COMMON_API ~EdgeList();
139
140 PX_PHYSX_COMMON_API bool init(const EDGELISTCREATE& create);
141
142 bool load(PxInputStream& stream);
143
144 PX_FORCE_INLINE PxU32 getNbEdges() const { return mNbEdges; }
145 PX_FORCE_INLINE const EdgeData* getEdges() const { return mEdges; }
146 PX_FORCE_INLINE const EdgeData& getEdge(PxU32 edge_index) const { return mEdges[edge_index]; }
147
148 PX_FORCE_INLINE PxU32 getNbFaces() const { return mNbFaces; }
149 PX_FORCE_INLINE const EdgeTriangleData* getEdgeTriangles() const { return mEdgeFaces; }
150 PX_FORCE_INLINE const EdgeTriangleData& getEdgeTriangle(PxU32 face_index) const { return mEdgeFaces[face_index]; }
151
152 PX_FORCE_INLINE const EdgeDescData* getEdgeToTriangles() const { return mEdgeToTriangles; }
153 PX_FORCE_INLINE const EdgeDescData& getEdgeToTriangles(PxU32 edge_index) const { return mEdgeToTriangles[edge_index]; }
154 PX_FORCE_INLINE const PxU32* getFacesByEdges() const { return mFacesByEdges; }
155 PX_FORCE_INLINE PxU32 getFacesByEdges(PxU32 face_index) const { return mFacesByEdges[face_index]; }
156
157 private:
158 // The edge list
159 PxU32 mNbEdges;
160 EdgeData* mEdges;
161 // Faces to edges
162 PxU32 mNbFaces;
163 EdgeTriangleData* mEdgeFaces;
164 // Edges to faces
165 EdgeDescData* mEdgeToTriangles;
166 PxU32* mFacesByEdges;
167
168 bool createFacesToEdges(PxU32 nb_faces, const PxU32* dfaces, const PxU16* wfaces);
169 bool createEdgesToFaces(PxU32 nb_faces, const PxU32* dfaces, const PxU16* wfaces);
170 bool computeActiveEdges(PxU32 nb_faces, const PxU32* dfaces, const PxU16* wfaces, const PxVec3* verts, float epsilon);
171 };
172
173} // namespace Gu
174
175}
176
177#endif
Definition GuEdgeList.h:135
PX_PHYSX_COMMON_API bool init(const EDGELISTCREATE &create)
Definition GuEdgeList.cpp:100
Definition GuEdgeList.h:98
Input stream class for I/O.
Definition PxIO.h:50
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
#define PX_INLINE
Definition PxPreprocessor.h:320
EdgeType
Definition GuEdgeList.h:43
@ PX_EDGE_BOUNDARY
Edge belongs to a single triangle.
Definition GuEdgeList.h:46
@ PX_EDGE_INTERNAL
Edge belongs to exactly two triangles.
Definition GuEdgeList.h:47
@ PX_EDGE_SINGULAR
Edge belongs to three or more triangles.
Definition GuEdgeList.h:48
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
The edge-list creation structure.
Definition GuEdgeList.h:113
PxU32 NbFaces
Number of faces in source topo.
Definition GuEdgeList.h:124
const PxU32 * DFaces
List of faces (dwords) or NULL.
Definition GuEdgeList.h:125
const PxU16 * WFaces
List of faces (words) or NULL.
Definition GuEdgeList.h:126
Basic edge-data using 8-bit references.
Definition GuEdgeList.h:68
PxU8 Ref0
First vertex reference.
Definition GuEdgeList.h:69
PxU8 Ref1
Second vertex reference.
Definition GuEdgeList.h:70
Basic edge-data.
Definition GuEdgeList.h:60
PxU32 Ref1
Second vertex reference.
Definition GuEdgeList.h:62
PxU32 Ref0
First vertex reference
Definition GuEdgeList.h:61
A count/offset pair = an edge descriptor.
Definition GuEdgeList.h:76
Edge<->triangle mapping.
Definition GuEdgeList.h:85