added first draft of C-API, btConvexHullShape takes float* instead of btPoint*, added getGravity to btRigidBody
This commit is contained in:
@@ -18,7 +18,8 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btQuaternion.h"
|
||||
|
||||
|
||||
btConvexHullShape ::btConvexHullShape (btPoint3* points,int numPoints,int stride)
|
||||
|
||||
btConvexHullShape ::btConvexHullShape (const float* points,int numPoints,int stride)
|
||||
{
|
||||
m_points.resize(numPoints);
|
||||
unsigned char* pointsBaseAddress = (unsigned char*)points;
|
||||
|
||||
@@ -30,7 +30,10 @@ class btConvexHullShape : public btPolyhedralConvexShape
|
||||
std::vector<btPoint3> m_points;
|
||||
|
||||
public:
|
||||
btConvexHullShape(btPoint3* points,int numPoints, int stride=sizeof(btPoint3));
|
||||
///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive float (x,y,z), the striding defines the number of bytes between each point, in memory.
|
||||
///It is easier to not pass any points in the constructor, and just add one point at a time, using addPoint.
|
||||
///btConvexHullShape make an internal copy of the points.
|
||||
btConvexHullShape(const float* points=0,int numPoints=0, int stride=sizeof(btPoint3));
|
||||
|
||||
void addPoint(const btPoint3& point)
|
||||
{
|
||||
|
||||
@@ -191,6 +191,12 @@ void btDiscreteDynamicsWorld::setGravity(const btVector3& gravity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void btDiscreteDynamicsWorld::removeRigidBody(btRigidBody* body)
|
||||
{
|
||||
removeCollisionObject(body);
|
||||
}
|
||||
|
||||
void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
{
|
||||
body->setGravity(m_gravity);
|
||||
|
||||
@@ -126,6 +126,8 @@ public:
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body);
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body);
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_DISCRETE_DYNAMICS_WORLD_H
|
||||
|
||||
@@ -56,6 +56,8 @@ class btDynamicsWorld : public btCollisionWorld
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body) = 0;
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_DYNAMICS_WORLD_H
|
||||
|
||||
@@ -88,7 +88,12 @@ public:
|
||||
void applyForces(btScalar step);
|
||||
|
||||
void setGravity(const btVector3& acceleration);
|
||||
|
||||
|
||||
const btVector3& getGravity() const
|
||||
{
|
||||
return m_gravity;
|
||||
}
|
||||
|
||||
void setDamping(btScalar lin_damping, btScalar ang_damping);
|
||||
|
||||
inline const btCollisionShape* getCollisionShape() const {
|
||||
|
||||
@@ -89,6 +89,11 @@ void btSimpleDynamicsWorld::setGravity(const btVector3& gravity)
|
||||
}
|
||||
}
|
||||
|
||||
void btSimpleDynamicsWorld::removeRigidBody(btRigidBody* body)
|
||||
{
|
||||
removeCollisionObject(body);
|
||||
}
|
||||
|
||||
void btSimpleDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
{
|
||||
body->setGravity(m_gravity);
|
||||
|
||||
@@ -70,6 +70,8 @@ public:
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body);
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body);
|
||||
|
||||
virtual void updateAabbs();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user