Changeset 8284 for code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h
- Timestamp:
- Apr 21, 2011, 6:58:23 PM (14 years ago)
- Location:
- code/branches/kicklib2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib2
- Property svn:mergeinfo changed
-
code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h
r5781 r8284 1 /* 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 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 */ 1 15 2 16 #ifndef BT_CONVEX_INTERNAL_SHAPE_H … … 4 18 5 19 #include "btConvexShape.h" 20 #include "LinearMath/btAabbUtil2.h" 21 6 22 7 23 ///The btConvexInternalShape is an internal base class, shared by most convex shape implementations. … … 36 52 { 37 53 return m_implicitShapeDimensions; 54 } 55 56 ///warning: use setImplicitShapeDimensions with care 57 ///changing a collision shape while the body is in the world is not recommended, 58 ///it is best to remove the body from the world, then make the change, and re-add it 59 ///alternatively flush the contact points, see documentation for 'cleanProxyFromPairs' 60 void setImplicitShapeDimensions(const btVector3& dimensions) 61 { 62 m_implicitShapeDimensions = dimensions; 38 63 } 39 64 … … 86 111 } 87 112 113 virtual int calculateSerializeBufferSize() const; 114 115 ///fills the dataBuffer and returns the struct name (and 0 on failure) 116 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; 88 117 89 118 90 119 }; 91 120 121 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 122 struct btConvexInternalShapeData 123 { 124 btCollisionShapeData m_collisionShapeData; 125 126 btVector3FloatData m_localScaling; 127 128 btVector3FloatData m_implicitShapeDimensions; 129 130 float m_collisionMargin; 131 132 int m_padding; 133 134 }; 135 136 137 138 SIMD_FORCE_INLINE int btConvexInternalShape::calculateSerializeBufferSize() const 139 { 140 return sizeof(btConvexInternalShapeData); 141 } 142 143 ///fills the dataBuffer and returns the struct name (and 0 on failure) 144 SIMD_FORCE_INLINE const char* btConvexInternalShape::serialize(void* dataBuffer, btSerializer* serializer) const 145 { 146 btConvexInternalShapeData* shapeData = (btConvexInternalShapeData*) dataBuffer; 147 btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer); 148 149 m_implicitShapeDimensions.serializeFloat(shapeData->m_implicitShapeDimensions); 150 m_localScaling.serializeFloat(shapeData->m_localScaling); 151 shapeData->m_collisionMargin = float(m_collisionMargin); 152 153 return "btConvexInternalShapeData"; 154 } 155 156 157 158 159 ///btConvexInternalAabbCachingShape adds local aabb caching for convex shapes, to avoid expensive bounding box calculations 160 class btConvexInternalAabbCachingShape : public btConvexInternalShape 161 { 162 btVector3 m_localAabbMin; 163 btVector3 m_localAabbMax; 164 bool m_isLocalAabbValid; 165 166 protected: 167 168 btConvexInternalAabbCachingShape(); 169 170 void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax) 171 { 172 m_isLocalAabbValid = true; 173 m_localAabbMin = aabbMin; 174 m_localAabbMax = aabbMax; 175 } 176 177 inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const 178 { 179 btAssert(m_isLocalAabbValid); 180 aabbMin = m_localAabbMin; 181 aabbMax = m_localAabbMax; 182 } 183 184 inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const 185 { 186 187 //lazy evaluation of local aabb 188 btAssert(m_isLocalAabbValid); 189 btTransformAabb(m_localAabbMin,m_localAabbMax,margin,trans,aabbMin,aabbMax); 190 } 191 192 public: 193 194 virtual void setLocalScaling(const btVector3& scaling); 195 196 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; 197 198 void recalcLocalAabb(); 199 200 }; 92 201 93 202 #endif //BT_CONVEX_INTERNAL_SHAPE_H
Note: See TracChangeset
for help on using the changeset viewer.