Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 27, 2011, 7:43:24 AM (14 years ago)
Author:
rgrieder
Message:

Updated Bullet Physics Engine from v2.74 to v2.77

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h

    r5781 r7983  
     1/*
     2Bullet Continuous Collision Detection and Physics Library
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
     4
     5This software is provided 'as-is', without any express or implied warranty.
     6In no event will the authors be held liable for any damages arising from the use of this software.
     7Permission is granted to anyone to use this software for any purpose,
     8including commercial applications, and to alter it and redistribute it freely,
     9subject to the following restrictions:
     10
     111. 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.
     122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
     133. This notice may not be removed or altered from any source distribution.
     14*/
    115
    216#ifndef BT_CONVEX_INTERNAL_SHAPE_H
     
    418
    519#include "btConvexShape.h"
     20#include "LinearMath/btAabbUtil2.h"
     21
    622
    723///The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
     
    3652        {
    3753                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;
    3863        }
    3964
     
    86111        }
    87112
     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;
    88117
    89118       
    90119};
    91120
     121///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     122struct  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
     138SIMD_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)
     144SIMD_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
     160class btConvexInternalAabbCachingShape : public btConvexInternalShape
     161{
     162        btVector3       m_localAabbMin;
     163        btVector3       m_localAabbMax;
     164        bool            m_isLocalAabbValid;
     165       
     166protected:
     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               
     192public:
     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};
    92201
    93202#endif //BT_CONVEX_INTERNAL_SHAPE_H
Note: See TracChangeset for help on using the changeset viewer.