Merge branch 'develop' of https://github.com/ColinGilbert/reactphysics3d into ColinGilbert-develop

This commit is contained in:
Daniel Chappuis 2015-08-27 22:32:18 +02:00
commit 16617fef8e
14 changed files with 157 additions and 150 deletions

10
.gitignore vendored
View File

@ -20,4 +20,12 @@
.Trashes
Icon?
ehthumbs.db
Thumbs.db
Thumbs.db
# vim swap files
#####################
*.*sw*
# CMake build directory
#######################
build/*

View File

@ -400,8 +400,8 @@ void RigidBody::updateBroadPhaseState() const {
PROFILE("RigidBody::updateBroadPhaseState()");
DynamicsWorld& world = dynamic_cast<DynamicsWorld&>(mWorld);
const Vector3 displacement = world.mTimeStep* mLinearVelocity;
DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld);
const Vector3 displacement = world.mTimeStep * mLinearVelocity;
// For all the proxy collision shapes of the body
for (ProxyShape* shape = mProxyCollisionShapes; shape != NULL; shape = shape->mNext) {

View File

@ -48,8 +48,8 @@ bool SphereVsSphereAlgorithm::testCollision(ProxyShape* collisionShape1,
// Get the sphere collision shapes
const CollisionShape* shape1 = collisionShape1->getCollisionShape();
const CollisionShape* shape2 = collisionShape2->getCollisionShape();
const SphereShape* sphereShape1 = dynamic_cast<const SphereShape*>(shape1);
const SphereShape* sphereShape2 = dynamic_cast<const SphereShape*>(shape2);
const SphereShape* sphereShape1 = static_cast<const SphereShape*>(shape1);
const SphereShape* sphereShape2 = static_cast<const SphereShape*>(shape2);
// Get the local-space to world-space transforms
const Transform transform1 = collisionShape1->getBody()->getTransform() *

View File

@ -165,7 +165,7 @@ inline Vector3 BoxShape::getLocalSupportPointWithoutMargin(const Vector3& direct
// Test equality between two box shapes
inline bool BoxShape::isEqualTo(const CollisionShape& otherCollisionShape) const {
const BoxShape& otherShape = dynamic_cast<const BoxShape&>(otherCollisionShape);
const BoxShape& otherShape = static_cast<const BoxShape&>(otherCollisionShape);
return (mExtent == otherShape.mExtent);
}

View File

@ -162,7 +162,7 @@ inline void CapsuleShape::getLocalBounds(Vector3& min, Vector3& max) const {
// Test equality between two capsule shapes
inline bool CapsuleShape::isEqualTo(const CollisionShape& otherCollisionShape) const {
const CapsuleShape& otherShape = dynamic_cast<const CapsuleShape&>(otherCollisionShape);
const CapsuleShape& otherShape = static_cast<const CapsuleShape&>(otherCollisionShape);
return (mRadius == otherShape.mRadius && mHalfHeight == otherShape.mHalfHeight);
}

View File

@ -178,7 +178,7 @@ inline void ConeShape::computeLocalInertiaTensor(Matrix3x3& tensor, decimal mass
// Test equality between two cone shapes
inline bool ConeShape::isEqualTo(const CollisionShape& otherCollisionShape) const {
const ConeShape& otherShape = dynamic_cast<const ConeShape&>(otherCollisionShape);
const ConeShape& otherShape = static_cast<const ConeShape&>(otherCollisionShape);
return (mRadius == otherShape.mRadius && mHalfHeight == otherShape.mHalfHeight);
}

View File

@ -211,7 +211,7 @@ void ConvexMeshShape::recalculateBounds() {
// Test equality between two cone shapes
bool ConvexMeshShape::isEqualTo(const CollisionShape& otherCollisionShape) const {
const ConvexMeshShape& otherShape = dynamic_cast<const ConvexMeshShape&>(otherCollisionShape);
const ConvexMeshShape& otherShape = static_cast<const ConvexMeshShape&>(otherCollisionShape);
assert(mNbVertices == mVertices.size());

View File

@ -175,7 +175,7 @@ inline void CylinderShape::computeLocalInertiaTensor(Matrix3x3& tensor, decimal
// Test equality between two cylinder shapes
inline bool CylinderShape::isEqualTo(const CollisionShape& otherCollisionShape) const {
const CylinderShape& otherShape = dynamic_cast<const CylinderShape&>(otherCollisionShape);
const CylinderShape& otherShape = static_cast<const CylinderShape&>(otherCollisionShape);
return (mRadius == otherShape.mRadius && mHalfHeight == otherShape.mHalfHeight);
}

View File

@ -197,7 +197,7 @@ inline void SphereShape::computeAABB(AABB& aabb, const Transform& transform) {
// Test equality between two sphere shapes
inline bool SphereShape::isEqualTo(const CollisionShape& otherCollisionShape) const {
const SphereShape& otherShape = dynamic_cast<const SphereShape&>(otherCollisionShape);
const SphereShape& otherShape = static_cast<const SphereShape&>(otherCollisionShape);
return (mRadius == otherShape.mRadius);
}

View File

@ -83,8 +83,8 @@ void ContactSolver::initializeForIsland(decimal dt, Island* island) {
assert(externalManifold->getNbContactPoints() > 0);
// Get the two bodies of the contact
RigidBody* body1 = dynamic_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody1());
RigidBody* body2 = dynamic_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody2());
RigidBody* body1 = static_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody1());
RigidBody* body2 = static_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody2());
assert(body1 != NULL);
assert(body2 != NULL);

View File

@ -510,7 +510,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
case BALLSOCKETJOINT:
{
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(BallAndSocketJoint));
const BallAndSocketJointInfo& info = dynamic_cast<const BallAndSocketJointInfo&>(
const BallAndSocketJointInfo& info = static_cast<const BallAndSocketJointInfo&>(
jointInfo);
newJoint = new (allocatedMemory) BallAndSocketJoint(info);
break;
@ -520,7 +520,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
case SLIDERJOINT:
{
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(SliderJoint));
const SliderJointInfo& info = dynamic_cast<const SliderJointInfo&>(jointInfo);
const SliderJointInfo& info = static_cast<const SliderJointInfo&>(jointInfo);
newJoint = new (allocatedMemory) SliderJoint(info);
break;
}
@ -529,7 +529,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
case HINGEJOINT:
{
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(HingeJoint));
const HingeJointInfo& info = dynamic_cast<const HingeJointInfo&>(jointInfo);
const HingeJointInfo& info = static_cast<const HingeJointInfo&>(jointInfo);
newJoint = new (allocatedMemory) HingeJoint(info);
break;
}
@ -538,7 +538,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) {
case FIXEDJOINT:
{
void* allocatedMemory = mMemoryAllocator.allocate(sizeof(FixedJoint));
const FixedJointInfo& info = dynamic_cast<const FixedJointInfo&>(jointInfo);
const FixedJointInfo& info = static_cast<const FixedJointInfo&>(jointInfo);
newJoint = new (allocatedMemory) FixedJoint(info);
break;
}
@ -727,8 +727,8 @@ void DynamicsWorld::computeIslands() {
contactManifold->mIsAlreadyInIsland = true;
// Get the other body of the contact manifold
RigidBody* body1 = dynamic_cast<RigidBody*>(contactManifold->getBody1());
RigidBody* body2 = dynamic_cast<RigidBody*>(contactManifold->getBody2());
RigidBody* body1 = static_cast<RigidBody*>(contactManifold->getBody1());
RigidBody* body2 = static_cast<RigidBody*>(contactManifold->getBody2());
RigidBody* otherBody = (body1->getID() == bodyToVisit->getID()) ? body2 : body1;
// Check if the other body has already been added to the island
@ -755,8 +755,8 @@ void DynamicsWorld::computeIslands() {
joint->mIsAlreadyInIsland = true;
// Get the other body of the contact manifold
RigidBody* body1 = dynamic_cast<RigidBody*>(joint->getBody1());
RigidBody* body2 = dynamic_cast<RigidBody*>(joint->getBody2());
RigidBody* body1 = static_cast<RigidBody*>(joint->getBody1());
RigidBody* body2 = static_cast<RigidBody*>(joint->getBody2());
RigidBody* otherBody = (body1->getID() == bodyToVisit->getID()) ? body2 : body1;
// Check if the other body has already been added to the island

View File

@ -1,27 +1,27 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* 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. *
* *
********************************************************************************/
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* 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 BOX_H
#define BOX_H
@ -34,67 +34,67 @@
// Class Box
class Box : public openglframework::Object3D, public PhysicsObject {
private :
private :
// -------------------- Attributes -------------------- //
// -------------------- Attributes -------------------- //
/// Size of each side of the box
float mSize[3];
/// Size of each side of the box
float mSize[3];
/// Scaling matrix (applied to a cube to obtain the correct box dimensions)
openglframework::Matrix4 mScalingMatrix;
/// Scaling matrix (applied to a cube to obtain the correct box dimensions)
openglframework::Matrix4 mScalingMatrix;
/// Vertex Buffer Object for the vertices data used to render the box with OpenGL
static openglframework::VertexBufferObject mVBOVertices;
/// Vertex Buffer Object for the vertices data used to render the box with OpenGL
static openglframework::VertexBufferObject mVBOVertices;
/// Vertex Buffer Object for the normales used to render the box with OpenGL
static openglframework::VertexBufferObject mVBONormals;
/// Vertex Buffer Object for the normales used to render the box with OpenGL
static openglframework::VertexBufferObject mVBONormals;
/// Vertex Array Object for the vertex data
static openglframework::VertexArrayObject mVAO;
/// Vertex Array Object for the vertex data
static openglframework::VertexArrayObject mVAO;
/// Vertices coordinates of the triangles of the box
static GLfloat mCubeVertices[108];
/// Vertices coordinates of the triangles of the box
static GLfloat mCubeVertices[108];
/// Vertices normals of the triangles of the box
static GLfloat mCubeNormals[108];
/// Vertices normals of the triangles of the box
static GLfloat mCubeNormals[108];
/// Total number of boxes created
static int totalNbBoxes;
/// Total number of boxes created
static int totalNbBoxes;
// -------------------- Methods -------------------- //
// -------------------- Methods -------------------- //
/// Create a the VAO and VBOs to render to box with OpenGL
static void createVBOAndVAO();
/// Create a the VAO and VBOs to render to box with OpenGL
static void createVBOAndVAO();
public :
public :
// -------------------- Methods -------------------- //
// -------------------- Methods -------------------- //
/// Constructor
Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
reactphysics3d::CollisionWorld* world);
/// Constructor
Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
reactphysics3d::CollisionWorld* world);
/// Constructor
Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
float mass, reactphysics3d::DynamicsWorld *world);
/// Constructor
Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
float mass, reactphysics3d::DynamicsWorld *world);
/// Destructor
~Box();
/// Destructor
~Box();
/// Render the cube at the correct position and with the correct orientation
void render(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix);
/// Render the cube at the correct position and with the correct orientation
void render(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix);
/// Set the position of the box
void resetTransform(const rp3d::Transform& transform);
/// Set the position of the box
void resetTransform(const rp3d::Transform& transform);
/// Update the transform matrix of the object
virtual void updateTransform(float interpolationFactor);
/// Update the transform matrix of the object
virtual void updateTransform(float interpolationFactor);
};
// Update the transform matrix of the object
inline void Box::updateTransform(float interpolationFactor) {
mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix);
mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix);
}

View File

@ -1,27 +1,27 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* 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. *
* *
********************************************************************************/
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* 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 CAPSULE_H
#define CAPSULE_H
@ -34,75 +34,75 @@
// Class Sphere
class Capsule : public openglframework::Mesh, public PhysicsObject {
private :
private :
// -------------------- Attributes -------------------- //
// -------------------- Attributes -------------------- //
/// Radius of the capsule
float mRadius;
/// Radius of the capsule
float mRadius;
/// Height of the capsule
float mHeight;
/// Height of the capsule
float mHeight;
/// Scaling matrix (applied to a sphere to obtain the correct sphere dimensions)
openglframework::Matrix4 mScalingMatrix;
/// Scaling matrix (applied to a sphere to obtain the correct sphere dimensions)
openglframework::Matrix4 mScalingMatrix;
/// Previous transform (for interpolation)
rp3d::Transform mPreviousTransform;
/// Previous transform (for interpolation)
rp3d::Transform mPreviousTransform;
/// Vertex Buffer Object for the vertices data
static openglframework::VertexBufferObject mVBOVertices;
/// Vertex Buffer Object for the vertices data
static openglframework::VertexBufferObject mVBOVertices;
/// Vertex Buffer Object for the normals data
static openglframework::VertexBufferObject mVBONormals;
/// Vertex Buffer Object for the normals data
static openglframework::VertexBufferObject mVBONormals;
/// Vertex Buffer Object for the texture coords
static openglframework::VertexBufferObject mVBOTextureCoords;
/// Vertex Buffer Object for the texture coords
static openglframework::VertexBufferObject mVBOTextureCoords;
/// Vertex Buffer Object for the indices
static openglframework::VertexBufferObject mVBOIndices;
/// Vertex Buffer Object for the indices
static openglframework::VertexBufferObject mVBOIndices;
/// Vertex Array Object for the vertex data
static openglframework::VertexArrayObject mVAO;
/// Vertex Array Object for the vertex data
static openglframework::VertexArrayObject mVAO;
// Total number of capsules created
static int totalNbCapsules;
// Total number of capsules created
static int totalNbCapsules;
// -------------------- Methods -------------------- //
// -------------------- Methods -------------------- //
// Create the Vertex Buffer Objects used to render with OpenGL.
void createVBOAndVAO();
// Create the Vertex Buffer Objects used to render with OpenGL.
void createVBOAndVAO();
public :
public :
// -------------------- Methods -------------------- //
// -------------------- Methods -------------------- //
/// Constructor
Capsule(float radius, float height, const openglframework::Vector3& position,
reactphysics3d::CollisionWorld* world, const std::string& meshFolderPath);
/// Constructor
Capsule(float radius, float height, const openglframework::Vector3& position,
reactphysics3d::CollisionWorld* world, const std::string& meshFolderPath);
/// Constructor
Capsule(float radius, float height, const openglframework::Vector3& position,
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
const std::string& meshFolderPath);
/// Constructor
Capsule(float radius, float height, const openglframework::Vector3& position,
float mass, reactphysics3d::DynamicsWorld* dynamicsWorld,
const std::string& meshFolderPath);
/// Destructor
~Capsule();
/// Destructor
~Capsule();
/// Render the sphere at the correct position and with the correct orientation
void render(openglframework::Shader& shader,
const openglframework::Matrix4& worldToCameraMatrix);
/// Render the sphere at the correct position and with the correct orientation
void render(openglframework::Shader& shader,
const openglframework::Matrix4& worldToCameraMatrix);
/// Set the position of the box
void resetTransform(const rp3d::Transform& transform);
/// Set the position of the box
void resetTransform(const rp3d::Transform& transform);
/// Update the transform matrix of the object
virtual void updateTransform(float interpolationFactor);
/// Update the transform matrix of the object
virtual void updateTransform(float interpolationFactor);
};
// Update the transform matrix of the object
inline void Capsule::updateTransform(float interpolationFactor) {
mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix);
mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix);
}
#endif

View File

@ -99,7 +99,6 @@ class Cone : public openglframework::Mesh, public PhysicsObject {
virtual void updateTransform(float interpolationFactor);
};
// Update the transform matrix of the object
inline void Cone::updateTransform(float interpolationFactor) {
mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix);
}