Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2011, 6:58:23 PM (13 years ago)
Author:
rgrieder
Message:

Merged revisions 7978 - 8096 from kicklib to kicklib2.

Location:
code/branches/kicklib2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib2

  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2222
    2323/// The btCylinderShape class implements a cylinder shape primitive, centered around the origin. Its central axis aligned with the Y axis. btCylinderShapeX is aligned with the X axis and btCylinderShapeZ around the Z axis.
    24 class btCylinderShape : public btBoxShape
     24class btCylinderShape : public btConvexInternalShape
    2525
    2626{
     
    3131
    3232public:
     33
     34        btVector3 getHalfExtentsWithMargin() const
     35        {
     36                btVector3 halfExtents = getHalfExtentsWithoutMargin();
     37                btVector3 margin(getMargin(),getMargin(),getMargin());
     38                halfExtents += margin;
     39                return halfExtents;
     40        }
     41       
     42        const btVector3& getHalfExtentsWithoutMargin() const
     43        {
     44                return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
     45        }
     46
    3347        btCylinderShape (const btVector3& halfExtents);
    3448       
    35         ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
    3649        void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
    3750
     51        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
     52
    3853        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
    3954
    4055        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
     56
     57        virtual void setMargin(btScalar collisionMargin)
     58        {
     59                //correct the m_implicitShapeDimensions for the margin
     60                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
     61                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
     62               
     63                btConvexInternalShape::setMargin(collisionMargin);
     64                btVector3 newMargin(getMargin(),getMargin(),getMargin());
     65                m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
     66
     67        }
    4168
    4269        virtual btVector3       localGetSupportingVertex(const btVector3& vec) const
     
    74101        }
    75102
     103        virtual void    setLocalScaling(const btVector3& scaling)
     104        {
     105                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
     106                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
     107                btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;
     108
     109                btConvexInternalShape::setLocalScaling(scaling);
     110
     111                m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
     112
     113        }
     114
    76115        //debugging
    77116        virtual const char*     getName()const
     
    80119        }
    81120
    82 
     121        virtual int     calculateSerializeBufferSize() const;
     122
     123        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     124        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
    83125
    84126};
     
    113155        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
    114156
    115         virtual int     getUpAxis() const
    116         {
    117                 return 2;
    118         }
    119157                //debugging
    120158        virtual const char*     getName()const
     
    130168};
    131169
     170///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     171struct  btCylinderShapeData
     172{
     173        btConvexInternalShapeData       m_convexInternalShapeData;
     174
     175        int     m_upAxis;
     176
     177        char    m_padding[4];
     178};
     179
     180SIMD_FORCE_INLINE       int     btCylinderShape::calculateSerializeBufferSize() const
     181{
     182        return sizeof(btCylinderShapeData);
     183}
     184
     185        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     186SIMD_FORCE_INLINE       const char*     btCylinderShape::serialize(void* dataBuffer, btSerializer* serializer) const
     187{
     188        btCylinderShapeData* shapeData = (btCylinderShapeData*) dataBuffer;
     189       
     190        btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
     191
     192        shapeData->m_upAxis = m_upAxis;
     193       
     194        return "btCylinderShapeData";
     195}
     196
     197
    132198
    133199#endif //CYLINDER_MINKOWSKI_H
Note: See TracChangeset for help on using the changeset viewer.