Blender  V3.3
btVoronoiSimplexSolver.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef BT_VORONOI_SIMPLEX_SOLVER_H
17 #define BT_VORONOI_SIMPLEX_SOLVER_H
18 
20 
21 #define VORONOI_SIMPLEX_MAX_VERTS 5
22 
24 #define BT_USE_EQUAL_VERTEX_THRESHOLD
25 
26 #ifdef BT_USE_DOUBLE_PRECISION
27 #define VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD 1e-12f
28 #else
29 #define VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD 0.0001f
30 #endif //BT_USE_DOUBLE_PRECISION
31 
33 {
35  {
36  reset();
37  }
38 
39  void reset()
40  {
41  usedVertexA = false;
42  usedVertexB = false;
43  usedVertexC = false;
44  usedVertexD = false;
45  }
46  unsigned short usedVertexA : 1;
47  unsigned short usedVertexB : 1;
48  unsigned short usedVertexC : 1;
49  unsigned short usedVertexD : 1;
50  unsigned short unused1 : 1;
51  unsigned short unused2 : 1;
52  unsigned short unused3 : 1;
53  unsigned short unused4 : 1;
54 };
55 
57 {
59  //MASK for m_usedVertices
60  //stores the simplex vertex-usage, using the MASK,
61  // if m_usedVertices & MASK then the related vertex is used
65 
66  void reset()
67  {
68  m_degenerate = false;
71  }
72  bool isValid()
73  {
74  bool valid = (m_barycentricCoords[0] >= btScalar(0.)) &&
75  (m_barycentricCoords[1] >= btScalar(0.)) &&
76  (m_barycentricCoords[2] >= btScalar(0.)) &&
77  (m_barycentricCoords[3] >= btScalar(0.));
78 
79  return valid;
80  }
82  {
86  m_barycentricCoords[3] = d;
87  }
88 };
89 
92 #ifdef NO_VIRTUAL_INTERFACE
95 #else
98 #endif
99 {
100 public:
102 
104 
108 
113 
116 
118 
120 
121  void removeVertex(int index);
122  void reduceVertices(const btUsageBitfield& usedVerts);
124 
125  bool closestPtPointTetrahedron(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d, btSubSimplexClosestResult& finalResult);
126  int pointOutsideOfPlane(const btVector3& p, const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d);
128 
129 public:
132  {
133  }
134  void reset();
135 
136  void addVertex(const btVector3& w, const btVector3& p, const btVector3& q);
137 
139  {
141  }
142 
144  {
145  return m_equalVertexThreshold;
146  }
147 
148  bool closest(btVector3 & v);
149 
151 
152  bool fullSimplex() const
153  {
154  return (m_numVertices == 4);
155  }
156 
157  int getSimplex(btVector3 * pBuf, btVector3 * qBuf, btVector3 * yBuf) const;
158 
159  bool inSimplex(const btVector3& w);
160 
161  void backup_closest(btVector3 & v);
162 
163  bool emptySimplex() const;
164 
165  void compute_points(btVector3 & p1, btVector3 & p2);
166 
167  int numVertices() const
168  {
169  return m_numVertices;
170  }
171 };
172 
173 #endif //BT_VORONOI_SIMPLEX_SOLVER_H
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:425
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:285
#define btSimplexSolverInterface
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
void reduceVertices(const btUsageBitfield &usedVerts)
btVoronoiSimplexSolver
int getSimplex(btVector3 *pBuf, btVector3 *qBuf, btVector3 *yBuf) const
void addVertex(const btVector3 &w, const btVector3 &p, const btVector3 &q)
btVector3 m_cachedP2
bool closestPtPointTetrahedron(const btVector3 &p, const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &d, btSubSimplexClosestResult &finalResult)
int m_numVertices
btScalar getEqualVertexThreshold() const
#define VORONOI_SIMPLEX_MAX_VERTS
btVector3 m_cachedV
bool inSimplex(const btVector3 &w)
bool emptySimplex() const
void setEqualVertexThreshold(btScalar threshold)
bool m_cachedValidClosest
btVector3 m_lastW
int pointOutsideOfPlane(const btVector3 &p, const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &d)
Test if point p and d lie on opposite sides of plane through abc.
btVector3 m_simplexVectorW[VORONOI_SIMPLEX_MAX_VERTS]
btVector3 m_cachedP1
btSubSimplexClosestResult m_cachedBC
void compute_points(btVector3 &p1, btVector3 &p2)
bool fullSimplex() const
int numVertices() const
bool updateClosestVectorAndPoints()
bool closestPtPointTriangle(const btVector3 &p, const btVector3 &a, const btVector3 &b, const btVector3 &c, btSubSimplexClosestResult &result)
#define VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD
bool closest(btVector3 &v)
btVector3 m_simplexPointsP[VORONOI_SIMPLEX_MAX_VERTS]
bool m_needsUpdate
void reset()
btVector3 m_simplexPointsQ[VORONOI_SIMPLEX_MAX_VERTS]
void removeVertex(int index)
void backup_closest(btVector3 &v)
btScalar m_equalVertexThreshold
btScalar maxVertex()
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void setBarycentricCoordinates(btScalar a=btScalar(0.), btScalar b=btScalar(0.), btScalar c=btScalar(0.), btScalar d=btScalar(0.))
unsigned short usedVertexC
unsigned short usedVertexB
unsigned short unused4
unsigned short usedVertexA
unsigned short unused1
unsigned short unused3
unsigned short unused2
unsigned short usedVertexD