Blender  V3.3
btSoftBodyConcaveCollisionAlgorithm.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_SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H
17 #define BT_SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H
18 
24 class btDispatcher;
27 class btSoftBody;
28 class btCollisionShape;
29 
30 #include "LinearMath/btHashMap.h"
31 
32 #include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" //for definition of MAX_NUM_PARTS_IN_BITS
33 
34 struct btTriIndex
35 {
38 
39  btTriIndex(int partId, int triangleIndex, btCollisionShape* shape)
40  {
41  m_PartIdTriangleIndex = (partId << (31 - MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
42  m_childShape = shape;
43  }
44 
45  int getTriangleIndex() const
46  {
47  // Get only the lower bits where the triangle index is stored
48  unsigned int x = 0;
49  unsigned int y = (~(x & 0)) << (31 - MAX_NUM_PARTS_IN_BITS);
50  return (m_PartIdTriangleIndex & ~(y));
51  }
52  int getPartId() const
53  {
54  // Get only the highest bits where the part index is stored
56  }
57  int getUid() const
58  {
59  return m_PartIdTriangleIndex;
60  }
61 };
62 
65 {
66  btSoftBody* m_softBody;
67  const btCollisionObject* m_triBody;
68 
69  btVector3 m_aabbMin;
70  btVector3 m_aabbMax;
71 
72  btManifoldResult* m_resultOut;
73 
74  btDispatcher* m_dispatcher;
75  const btDispatcherInfo* m_dispatchInfoPtr;
76  btScalar m_collisionMarginTriangle;
77 
79 
80 public:
82 
83  // btPersistentManifold* m_manifoldPtr;
84 
85  btSoftBodyTriangleCallback(btDispatcher* dispatcher, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, bool isSwapped);
86 
87  void setTimeStepAndCounters(btScalar collisionMarginTriangle, const btCollisionObjectWrapper* triObjWrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
88 
90 
91  virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
92 
93  void clearCache();
94 
96  {
97  return m_aabbMin;
98  }
100  {
101  return m_aabbMax;
102  }
103 };
104 
107 {
108  bool m_isSwapped;
109 
110  btSoftBodyTriangleCallback m_btSoftBodyTriangleCallback;
111 
112 public:
114 
116 
117  virtual void processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
118 
120 
121  virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
122  {
123  //we don't add any manifolds
124  }
125 
126  void clearCache();
127 
129  {
131  {
133  return new (mem) btSoftBodyConcaveCollisionAlgorithm(ci, body0Wrap, body1Wrap, false);
134  }
135  };
136 
138  {
140  {
142  return new (mem) btSoftBodyConcaveCollisionAlgorithm(ci, body0Wrap, body1Wrap, true);
143  }
144  };
145 };
146 
147 #endif //BT_SOFT_BODY_CONCAVE_COLLISION_ALGORITHM_H
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
btVector3 m_aabbMax
btVector3 m_aabbMin
btCollisionObject
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
#define MAX_NUM_PARTS_IN_BITS
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define SIMD_FORCE_INLINE
Definition: btScalar.h:280
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
virtual void * allocateCollisionAlgorithm(int size)=0
btManifoldResult is a helper class to manage contact results.
btSoftBodyConcaveCollisionAlgorithm supports collision between soft body shapes and (concave) triange...
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btSoftBodyConcaveCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)
btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
For each triangle in the concave mesh that overlaps with the AABB of a soft body (m_softBody),...
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)
btSoftBodyTriangleCallback(btDispatcher *dispatcher, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
SIMD_FORCE_INLINE const btVector3 & getAabbMin() const
SIMD_FORCE_INLINE const btVector3 & getAabbMax() const
void setTimeStepAndCounters(btScalar collisionMarginTriangle, const btCollisionObjectWrapper *triObjWrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
virtual btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
class btCollisionShape * m_childShape
btTriIndex(int partId, int triangleIndex, btCollisionShape *shape)