renamed ConcaveShape to btConcaveShape
added btHeightfieldTerrainShape (not done yet)
This commit is contained in:
@@ -165,7 +165,7 @@ void OGL_displaylist_register_shape(btCollisionShape * shape)
|
|||||||
|
|
||||||
if (shape->isConcave())
|
if (shape->isConcave())
|
||||||
{
|
{
|
||||||
ConcaveShape* concaveMesh = (ConcaveShape*) shape;
|
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
||||||
//todo pass camera, for some culling
|
//todo pass camera, for some culling
|
||||||
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||||
}
|
}
|
||||||
@@ -470,7 +470,7 @@ void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const b
|
|||||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
||||||
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
ConcaveShape* concaveMesh = (btTriangleMeshShape*) shape;
|
btConcaveShape* concaveMesh = (btTriangleMeshShape*) shape;
|
||||||
//btVector3 aabbMax(1e30f,1e30f,1e30f);
|
//btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||||
//btVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f);
|
//btVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f);
|
||||||
|
|
||||||
|
|||||||
@@ -332,8 +332,8 @@ void bt_concave_concave_collision(btConcaveConcaveCollisionAlgorithm * algorithm
|
|||||||
btCollisionObject* tribody1,
|
btCollisionObject* tribody1,
|
||||||
btManifoldResult* resultOut)
|
btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
ConcaveShape* tri0b = static_cast<ConcaveShape*>( tribody0->getCollisionShape());
|
btConcaveShape* tri0b = static_cast<btConcaveShape*>( tribody0->getCollisionShape());
|
||||||
ConcaveShape* tri1b = static_cast<ConcaveShape*>( tribody1->getCollisionShape());
|
btConcaveShape* tri1b = static_cast<btConcaveShape*>( tribody1->getCollisionShape());
|
||||||
|
|
||||||
//Get First AABB
|
//Get First AABB
|
||||||
btVector3 aabbMin0,aabbMax0;
|
btVector3 aabbMin0,aabbMax0;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
///Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
|
///Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
|
||||||
class btGIMPACTMeshShape : public ConcaveShape
|
class btGIMPACTMeshShape : public btConcaveShape
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
btGIMPACTMeshData * m_meshdata;
|
btGIMPACTMeshData * m_meshdata;
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ CONCAVE_SHAPES_START_HERE,
|
|||||||
TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||||
///used for demo integration FAST/Swift collision library and Bullet
|
///used for demo integration FAST/Swift collision library and Bullet
|
||||||
FAST_CONCAVE_MESH_PROXYTYPE,
|
FAST_CONCAVE_MESH_PROXYTYPE,
|
||||||
|
//terrain
|
||||||
|
TERRAIN_SHAPE_PROXYTYPE,
|
||||||
///Used for GIMPACT Trimesh integration
|
///Used for GIMPACT Trimesh integration
|
||||||
GIMPACT_SHAPE_PROXYTYPE,
|
GIMPACT_SHAPE_PROXYTYPE,
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* bod
|
|||||||
|
|
||||||
|
|
||||||
btCollisionObject* triOb = triBody;
|
btCollisionObject* triOb = triBody;
|
||||||
ConcaveShape* concaveShape = static_cast<ConcaveShape*>( triOb->getCollisionShape());
|
btConcaveShape* concaveShape = static_cast<btConcaveShape*>( triOb->getCollisionShape());
|
||||||
|
|
||||||
if (convexBody->getCollisionShape()->isConvex())
|
if (convexBody->getCollisionShape()->isConvex())
|
||||||
{
|
{
|
||||||
@@ -288,7 +288,7 @@ float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject
|
|||||||
|
|
||||||
btCollisionObject* concavebody = triBody;
|
btCollisionObject* concavebody = triBody;
|
||||||
|
|
||||||
ConcaveShape* triangleMesh = (ConcaveShape*) concavebody->getCollisionShape();
|
btConcaveShape* triangleMesh = (btConcaveShape*) concavebody->getCollisionShape();
|
||||||
|
|
||||||
if (triangleMesh)
|
if (triangleMesh)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "btConcaveShape.h"
|
#include "btConcaveShape.h"
|
||||||
|
|
||||||
ConcaveShape::ConcaveShape() : m_collisionMargin(0.f)
|
btConcaveShape::btConcaveShape() : m_collisionMargin(0.f)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConcaveShape::~ConcaveShape()
|
btConcaveShape::~btConcaveShape()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
///Concave shape proves an interface concave shapes that can produce triangles that overlapping a given AABB.
|
///Concave shape proves an interface concave shapes that can produce triangles that overlapping a given AABB.
|
||||||
///Static triangle mesh, infinite plane, height field/landscapes are example that implement this interface.
|
///Static triangle mesh, infinite plane, height field/landscapes are example that implement this interface.
|
||||||
class ConcaveShape : public btCollisionShape
|
class btConcaveShape : public btCollisionShape
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float m_collisionMargin;
|
float m_collisionMargin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConcaveShape();
|
btConcaveShape();
|
||||||
|
|
||||||
virtual ~ConcaveShape();
|
virtual ~btConcaveShape();
|
||||||
|
|
||||||
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0;
|
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
/// btEmptyShape is a collision shape without actual collision detection.
|
/// btEmptyShape is a collision shape without actual collision detection.
|
||||||
///It can be replaced by another shape during runtime
|
///It can be replaced by another shape during runtime
|
||||||
class btEmptyShape : public ConcaveShape
|
class btEmptyShape : public btConcaveShape
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
btEmptyShape();
|
btEmptyShape();
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "btHeightfieldTerrainShape.h"
|
||||||
|
|
||||||
|
#include "LinearMath/btTransformUtil.h"
|
||||||
|
|
||||||
|
|
||||||
|
btHeightfieldTerrainShape::btHeightfieldTerrainShape()
|
||||||
|
:m_localScaling(0.f,0.f,0.f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
btHeightfieldTerrainShape::~btHeightfieldTerrainShape()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
|
||||||
|
{
|
||||||
|
aabbMin.setValue(-1e30f,-1e30f,-1e30f);
|
||||||
|
aabbMax.setValue(1e30f,1e30f,1e30f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
||||||
|
{
|
||||||
|
|
||||||
|
btVector3 halfExtents = (aabbMax - aabbMin) * 0.5f;
|
||||||
|
btScalar radius = halfExtents.length();
|
||||||
|
btVector3 center = (aabbMax + aabbMin) * 0.5f;
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
//this is where the triangles are generated, given AABB and plane equation (normal/constant)
|
||||||
|
/*
|
||||||
|
btVector3 tangentDir0,tangentDir1;
|
||||||
|
|
||||||
|
//tangentDir0/tangentDir1 can be precalculated
|
||||||
|
btPlaneSpace1(m_planeNormal,tangentDir0,tangentDir1);
|
||||||
|
|
||||||
|
btVector3 supVertex0,supVertex1;
|
||||||
|
|
||||||
|
btVector3 projectedCenter = center - (m_planeNormal.dot(center) - m_planeConstant)*m_planeNormal;
|
||||||
|
|
||||||
|
btVector3 triangle[3];
|
||||||
|
triangle[0] = projectedCenter + tangentDir0*radius + tangentDir1*radius;
|
||||||
|
triangle[1] = projectedCenter + tangentDir0*radius - tangentDir1*radius;
|
||||||
|
triangle[2] = projectedCenter - tangentDir0*radius - tangentDir1*radius;
|
||||||
|
|
||||||
|
callback->processTriangle(triangle,0,0);
|
||||||
|
|
||||||
|
triangle[0] = projectedCenter - tangentDir0*radius - tangentDir1*radius;
|
||||||
|
triangle[1] = projectedCenter - tangentDir0*radius + tangentDir1*radius;
|
||||||
|
triangle[2] = projectedCenter + tangentDir0*radius + tangentDir1*radius;
|
||||||
|
|
||||||
|
callback->processTriangle(triangle,0,1);
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void btHeightfieldTerrainShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||||
|
{
|
||||||
|
//moving concave objects not supported
|
||||||
|
|
||||||
|
inertia.setValue(0.f,0.f,0.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void btHeightfieldTerrainShape::setLocalScaling(const btVector3& scaling)
|
||||||
|
{
|
||||||
|
m_localScaling = scaling;
|
||||||
|
}
|
||||||
|
const btVector3& btHeightfieldTerrainShape::getLocalScaling() const
|
||||||
|
{
|
||||||
|
return m_localScaling;
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
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 HEIGHTFIELD_TERRAIN_SHAPE_H
|
||||||
|
#define HEIGHTFIELD_TERRAIN_SHAPE_H
|
||||||
|
|
||||||
|
#include "BulletCollision/CollisionShapes/btConcaveShape.h"
|
||||||
|
|
||||||
|
///btHeightfieldTerrainShape simulates a 2D heightfield terrain
|
||||||
|
class btHeightfieldTerrainShape : public btConcaveShape
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
btVector3 m_localAabbMin;
|
||||||
|
btVector3 m_localAabbMax;
|
||||||
|
|
||||||
|
//todo: terrain data
|
||||||
|
|
||||||
|
btVector3 m_localScaling;
|
||||||
|
|
||||||
|
public:
|
||||||
|
btHeightfieldTerrainShape();
|
||||||
|
|
||||||
|
virtual ~btHeightfieldTerrainShape();
|
||||||
|
|
||||||
|
|
||||||
|
virtual int getShapeType() const
|
||||||
|
{
|
||||||
|
return TERRAIN_SHAPE_PROXYTYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
||||||
|
|
||||||
|
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||||
|
|
||||||
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia);
|
||||||
|
|
||||||
|
virtual void setLocalScaling(const btVector3& scaling);
|
||||||
|
|
||||||
|
virtual const btVector3& getLocalScaling() const;
|
||||||
|
|
||||||
|
//debugging
|
||||||
|
virtual char* getName()const {return "HEIGHTFIELD";}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //HEIGHTFIELD_TERRAIN_SHAPE_H
|
||||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
///StaticPlaneShape simulates an 'infinite' plane by dynamically reporting triangles approximated by intersection of the plane with the AABB.
|
///StaticPlaneShape simulates an 'infinite' plane by dynamically reporting triangles approximated by intersection of the plane with the AABB.
|
||||||
///Assumed is that the other objects is not also infinite, so a reasonable sized AABB.
|
///Assumed is that the other objects is not also infinite, so a reasonable sized AABB.
|
||||||
class btStaticPlaneShape : public ConcaveShape
|
class btStaticPlaneShape : public btConcaveShape
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
btVector3 m_localAabbMin;
|
btVector3 m_localAabbMin;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
///Concave triangle mesh. Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
|
///Concave triangle mesh. Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
|
||||||
class btTriangleMeshShape : public ConcaveShape
|
class btTriangleMeshShape : public btConcaveShape
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
btStridingMeshInterface* m_meshInterface;
|
btStridingMeshInterface* m_meshInterface;
|
||||||
|
|||||||
Reference in New Issue
Block a user