2017-08-01 14:30:58 +02:00
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
|
|
|
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
subject to the following restrictions:
|
|
|
|
|
|
|
|
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.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H
|
|
|
|
#define BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H
|
|
|
|
|
|
|
|
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
|
|
|
|
|
|
|
///The btScaledBvhTriangleMeshShape allows to instance a scaled version of an existing btBvhTriangleMeshShape.
|
|
|
|
///Note that each btBvhTriangleMeshShape still can have its own local scaling, independent from this btScaledBvhTriangleMeshShape 'localScaling'
|
2019-01-03 14:26:51 +01:00
|
|
|
ATTRIBUTE_ALIGNED16(class)
|
|
|
|
btScaledBvhTriangleMeshShape : public btConcaveShape
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
btVector3 m_localScaling;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
btBvhTriangleMeshShape* m_bvhTriMeshShape;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
btScaledBvhTriangleMeshShape(btBvhTriangleMeshShape * childShape, const btVector3& localScaling);
|
2017-08-01 14:30:58 +02:00
|
|
|
|
|
|
|
virtual ~btScaledBvhTriangleMeshShape();
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const;
|
|
|
|
virtual void setLocalScaling(const btVector3& scaling);
|
2017-08-01 14:30:58 +02:00
|
|
|
virtual const btVector3& getLocalScaling() const;
|
2019-01-03 14:26:51 +01:00
|
|
|
virtual void calculateLocalInertia(btScalar mass, btVector3 & inertia) const;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
virtual void processAllTriangles(btTriangleCallback * callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
btBvhTriangleMeshShape* getChildShape()
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
return m_bvhTriMeshShape;
|
|
|
|
}
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
const btBvhTriangleMeshShape* getChildShape() const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
return m_bvhTriMeshShape;
|
|
|
|
}
|
|
|
|
|
|
|
|
//debugging
|
2019-01-03 14:26:51 +01:00
|
|
|
virtual const char* getName() const { return "SCALEDBVHTRIANGLEMESH"; }
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
virtual int calculateSerializeBufferSize() const;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
|
|
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
2019-01-03 14:26:51 +01:00
|
|
|
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
2017-08-01 14:30:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
|
2019-01-03 14:26:51 +01:00
|
|
|
struct btScaledTriangleMeshShapeData
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
btTriangleMeshShapeData m_trimeshShapeData;
|
2017-08-01 14:30:58 +02:00
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
btVector3FloatData m_localScaling;
|
2017-08-01 14:30:58 +02:00
|
|
|
};
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
SIMD_FORCE_INLINE int btScaledBvhTriangleMeshShape::calculateSerializeBufferSize() const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
return sizeof(btScaledTriangleMeshShapeData);
|
|
|
|
}
|
|
|
|
|
|
|
|
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
2019-01-03 14:26:51 +01:00
|
|
|
SIMD_FORCE_INLINE const char* btScaledBvhTriangleMeshShape::serialize(void* dataBuffer, btSerializer* serializer) const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
btScaledTriangleMeshShapeData* scaledMeshData = (btScaledTriangleMeshShapeData*)dataBuffer;
|
|
|
|
m_bvhTriMeshShape->serialize(&scaledMeshData->m_trimeshShapeData, serializer);
|
2017-08-01 14:30:58 +02:00
|
|
|
scaledMeshData->m_trimeshShapeData.m_collisionShapeData.m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE;
|
|
|
|
m_localScaling.serializeFloat(scaledMeshData->m_localScaling);
|
|
|
|
return "btScaledTriangleMeshShapeData";
|
|
|
|
}
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
#endif //BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H
|