From 1468f8f13cd135b6aed191d0a30dc5b625af6911 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 24 Aug 2015 13:36:30 -0600 Subject: [PATCH 1/4] Replace dynamic_cast with static_cast --- .gitignore | 6 +++++- CMakeLists.txt | 4 ++-- examples/common/Box.h | 2 +- examples/common/Capsule.h | 2 +- examples/common/Cone.h | 2 +- examples/common/Sphere.h | 2 +- src/body/RigidBody.cpp | 2 +- .../narrowphase/SphereVsSphereAlgorithm.cpp | 4 ++-- src/collision/shapes/BoxShape.h | 2 +- src/collision/shapes/CapsuleShape.h | 2 +- src/collision/shapes/ConeShape.h | 2 +- src/collision/shapes/ConvexMeshShape.cpp | 2 +- src/collision/shapes/CylinderShape.h | 2 +- src/collision/shapes/SphereShape.h | 2 +- src/engine/ContactSolver.cpp | 4 ++-- src/engine/DynamicsWorld.cpp | 16 ++++++++-------- 16 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 9030fae6..ccb0c7fc 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,8 @@ .Trashes Icon? ehthumbs.db -Thumbs.db \ No newline at end of file +Thumbs.db + +# vim swap files +##################### +*.*sw* diff --git a/CMakeLists.txt b/CMakeLists.txt index 75592736..2b2035c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ SET(OUR_EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") ENABLE_TESTING() # Options -OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" OFF) -OPTION(COMPILE_TESTS "Select this if you want to build the tests" OFF) +OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" ON) +OPTION(COMPILE_TESTS "Select this if you want to build the tests" ON) OPTION(PROFILING_ENABLED "Select this if you want to compile with enabled profiling" OFF) OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating values" OFF) diff --git a/examples/common/Box.h b/examples/common/Box.h index 2cc333d8..ee0fb85d 100644 --- a/examples/common/Box.h +++ b/examples/common/Box.h @@ -120,7 +120,7 @@ inline rp3d::CollisionBody* Box::getCollisionBody() { // Return a pointer to the rigid body of the box inline rp3d::RigidBody* Box::getRigidBody() { - return dynamic_cast(mRigidBody); + return static_cast(mRigidBody); } // Set the color of the box diff --git a/examples/common/Capsule.h b/examples/common/Capsule.h index 2ce438d1..6dbf0181 100644 --- a/examples/common/Capsule.h +++ b/examples/common/Capsule.h @@ -88,7 +88,7 @@ inline rp3d::CollisionBody* Capsule::getCollisionBody() { // Return a pointer to the rigid body of the box inline rp3d::RigidBody* Capsule::getRigidBody() { - return dynamic_cast(mRigidBody); + return static_cast(mRigidBody); } #endif diff --git a/examples/common/Cone.h b/examples/common/Cone.h index d3002eab..6368ec2b 100644 --- a/examples/common/Cone.h +++ b/examples/common/Cone.h @@ -87,7 +87,7 @@ inline rp3d::CollisionBody* Cone::getCollisionBody() { // Return a pointer to the rigid body of the box inline rp3d::RigidBody* Cone::getRigidBody() { - return dynamic_cast(mRigidBody); + return static_cast(mRigidBody); } #endif diff --git a/examples/common/Sphere.h b/examples/common/Sphere.h index 08a335f7..0401d52c 100644 --- a/examples/common/Sphere.h +++ b/examples/common/Sphere.h @@ -84,7 +84,7 @@ inline rp3d::CollisionBody* Sphere::getCollisionBody() { // Return a pointer to the rigid body of the box inline rp3d::RigidBody* Sphere::getRigidBody() { - return dynamic_cast(mRigidBody); + return static_cast(mRigidBody); } #endif diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 3ba985b6..a2a70f74 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -342,7 +342,7 @@ void RigidBody::updateBroadPhaseState() const { PROFILE("RigidBody::updateBroadPhaseState()"); - DynamicsWorld& world = dynamic_cast(mWorld); + DynamicsWorld& world = static_cast(mWorld); const Vector3 displacement = world.mTimer.getTimeStep() * mLinearVelocity; // For all the proxy collision shapes of the body diff --git a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp index ceeb528a..5570c985 100644 --- a/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp +++ b/src/collision/narrowphase/SphereVsSphereAlgorithm.cpp @@ -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(shape1); - const SphereShape* sphereShape2 = dynamic_cast(shape2); + const SphereShape* sphereShape1 = static_cast(shape1); + const SphereShape* sphereShape2 = static_cast(shape2); // Get the local-space to world-space transforms const Transform transform1 = collisionShape1->getBody()->getTransform() * diff --git a/src/collision/shapes/BoxShape.h b/src/collision/shapes/BoxShape.h index 9f7e49ec..f46b9d94 100644 --- a/src/collision/shapes/BoxShape.h +++ b/src/collision/shapes/BoxShape.h @@ -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(otherCollisionShape); + const BoxShape& otherShape = static_cast(otherCollisionShape); return (mExtent == otherShape.mExtent); } diff --git a/src/collision/shapes/CapsuleShape.h b/src/collision/shapes/CapsuleShape.h index 240f73cb..e3c410ef 100644 --- a/src/collision/shapes/CapsuleShape.h +++ b/src/collision/shapes/CapsuleShape.h @@ -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(otherCollisionShape); + const CapsuleShape& otherShape = static_cast(otherCollisionShape); return (mRadius == otherShape.mRadius && mHalfHeight == otherShape.mHalfHeight); } diff --git a/src/collision/shapes/ConeShape.h b/src/collision/shapes/ConeShape.h index f7aec26e..63a0a5c2 100644 --- a/src/collision/shapes/ConeShape.h +++ b/src/collision/shapes/ConeShape.h @@ -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(otherCollisionShape); + const ConeShape& otherShape = static_cast(otherCollisionShape); return (mRadius == otherShape.mRadius && mHalfHeight == otherShape.mHalfHeight); } diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index aa4cf81e..4546f881 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -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(otherCollisionShape); + const ConvexMeshShape& otherShape = static_cast(otherCollisionShape); assert(mNbVertices == mVertices.size()); diff --git a/src/collision/shapes/CylinderShape.h b/src/collision/shapes/CylinderShape.h index 5b381296..e48b8637 100644 --- a/src/collision/shapes/CylinderShape.h +++ b/src/collision/shapes/CylinderShape.h @@ -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(otherCollisionShape); + const CylinderShape& otherShape = static_cast(otherCollisionShape); return (mRadius == otherShape.mRadius && mHalfHeight == otherShape.mHalfHeight); } diff --git a/src/collision/shapes/SphereShape.h b/src/collision/shapes/SphereShape.h index d49db1ef..996df8bb 100644 --- a/src/collision/shapes/SphereShape.h +++ b/src/collision/shapes/SphereShape.h @@ -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(otherCollisionShape); + const SphereShape& otherShape = static_cast(otherCollisionShape); return (mRadius == otherShape.mRadius); } diff --git a/src/engine/ContactSolver.cpp b/src/engine/ContactSolver.cpp index bb32bf85..18036138 100644 --- a/src/engine/ContactSolver.cpp +++ b/src/engine/ContactSolver.cpp @@ -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(externalManifold->getContactPoint(0)->getBody1()); - RigidBody* body2 = dynamic_cast(externalManifold->getContactPoint(0)->getBody2()); + RigidBody* body1 = static_cast(externalManifold->getContactPoint(0)->getBody1()); + RigidBody* body2 = static_cast(externalManifold->getContactPoint(0)->getBody2()); assert(body1 != NULL); assert(body2 != NULL); diff --git a/src/engine/DynamicsWorld.cpp b/src/engine/DynamicsWorld.cpp index f5637077..159f84cf 100644 --- a/src/engine/DynamicsWorld.cpp +++ b/src/engine/DynamicsWorld.cpp @@ -529,7 +529,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) { case BALLSOCKETJOINT: { void* allocatedMemory = mMemoryAllocator.allocate(sizeof(BallAndSocketJoint)); - const BallAndSocketJointInfo& info = dynamic_cast( + const BallAndSocketJointInfo& info = static_cast( jointInfo); newJoint = new (allocatedMemory) BallAndSocketJoint(info); break; @@ -539,7 +539,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) { case SLIDERJOINT: { void* allocatedMemory = mMemoryAllocator.allocate(sizeof(SliderJoint)); - const SliderJointInfo& info = dynamic_cast(jointInfo); + const SliderJointInfo& info = static_cast(jointInfo); newJoint = new (allocatedMemory) SliderJoint(info); break; } @@ -548,7 +548,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) { case HINGEJOINT: { void* allocatedMemory = mMemoryAllocator.allocate(sizeof(HingeJoint)); - const HingeJointInfo& info = dynamic_cast(jointInfo); + const HingeJointInfo& info = static_cast(jointInfo); newJoint = new (allocatedMemory) HingeJoint(info); break; } @@ -557,7 +557,7 @@ Joint* DynamicsWorld::createJoint(const JointInfo& jointInfo) { case FIXEDJOINT: { void* allocatedMemory = mMemoryAllocator.allocate(sizeof(FixedJoint)); - const FixedJointInfo& info = dynamic_cast(jointInfo); + const FixedJointInfo& info = static_cast(jointInfo); newJoint = new (allocatedMemory) FixedJoint(info); break; } @@ -746,8 +746,8 @@ void DynamicsWorld::computeIslands() { contactManifold->mIsAlreadyInIsland = true; // Get the other body of the contact manifold - RigidBody* body1 = dynamic_cast(contactManifold->getBody1()); - RigidBody* body2 = dynamic_cast(contactManifold->getBody2()); + RigidBody* body1 = static_cast(contactManifold->getBody1()); + RigidBody* body2 = static_cast(contactManifold->getBody2()); RigidBody* otherBody = (body1->getID() == bodyToVisit->getID()) ? body2 : body1; // Check if the other body has already been added to the island @@ -774,8 +774,8 @@ void DynamicsWorld::computeIslands() { joint->mIsAlreadyInIsland = true; // Get the other body of the contact manifold - RigidBody* body1 = dynamic_cast(joint->getBody1()); - RigidBody* body2 = dynamic_cast(joint->getBody2()); + RigidBody* body1 = static_cast(joint->getBody1()); + RigidBody* body2 = static_cast(joint->getBody2()); RigidBody* otherBody = (body1->getID() == bodyToVisit->getID()) ? body2 : body1; // Check if the other body has already been added to the island From 3fdc056a1eaf2ad5e758effe9e4a8447a4525ada Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 24 Aug 2015 13:43:57 -0600 Subject: [PATCH 2/4] Fix oops for CI --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b2035c2..75592736 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ SET(OUR_EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") ENABLE_TESTING() # Options -OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" ON) -OPTION(COMPILE_TESTS "Select this if you want to build the tests" ON) +OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" OFF) +OPTION(COMPILE_TESTS "Select this if you want to build the tests" OFF) OPTION(PROFILING_ENABLED "Select this if you want to compile with enabled profiling" OFF) OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating values" OFF) From 494f8663576550f23c18686f89427e581a09c7f2 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 26 Aug 2015 04:23:44 -0600 Subject: [PATCH 3/4] Fix merge mess --- .gitignore | 4 ++ src/body/RigidBody.cpp | 7 +- testbed/common/Box.h | 128 +++++++++++++++++------------------ testbed/common/Capsule.h | 140 +++++++++++++++++++-------------------- testbed/common/Cone.h | 7 -- testbed/common/Sphere.h | 6 -- 6 files changed, 133 insertions(+), 159 deletions(-) diff --git a/.gitignore b/.gitignore index ccb0c7fc..5100f153 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,7 @@ Thumbs.db # vim swap files ##################### *.*sw* + +# CMake build directory +####################### +build/* diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index a057ef08..64153937 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -400,13 +400,8 @@ void RigidBody::updateBroadPhaseState() const { PROFILE("RigidBody::updateBroadPhaseState()"); -<<<<<<< HEAD DynamicsWorld& world = static_cast(mWorld); - const Vector3 displacement = world.mTimer.getTimeStep() * mLinearVelocity; -======= - DynamicsWorld& world = dynamic_cast(mWorld); - const Vector3 displacement = world.mTimeStep* mLinearVelocity; ->>>>>>> 1bde11f245806de07a12b1cf6c33cdb83046b882 + const Vector3 displacement = world.mTimer.getTimeStep() * mLinearVelocity; // For all the proxy collision shapes of the body for (ProxyShape* shape = mProxyCollisionShapes; shape != NULL; shape = shape->mNext) { diff --git a/testbed/common/Box.h b/testbed/common/Box.h index d2d13c30..3170abce 100644 --- a/testbed/common/Box.h +++ b/testbed/common/Box.h @@ -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,73 +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); }; -<<<<<<< HEAD:examples/common/Box.h -// Return a pointer to the rigid body of the box -inline rp3d::RigidBody* Box::getRigidBody() { - return static_cast(mRigidBody); -======= // Update the transform matrix of the object inline void Box::updateTransform(float interpolationFactor) { - mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix); ->>>>>>> 1bde11f245806de07a12b1cf6c33cdb83046b882:testbed/common/Box.h + mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix); } diff --git a/testbed/common/Capsule.h b/testbed/common/Capsule.h index 91d05861..7bb934b0 100644 --- a/testbed/common/Capsule.h +++ b/testbed/common/Capsule.h @@ -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,81 +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); }; -<<<<<<< HEAD:examples/common/Capsule.h -// Return a pointer to the rigid body of the box -inline rp3d::RigidBody* Capsule::getRigidBody() { - return static_cast(mRigidBody); -======= // Update the transform matrix of the object inline void Capsule::updateTransform(float interpolationFactor) { - mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix); ->>>>>>> 1bde11f245806de07a12b1cf6c33cdb83046b882:testbed/common/Capsule.h + mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix); } #endif diff --git a/testbed/common/Cone.h b/testbed/common/Cone.h index 28998d41..74355140 100644 --- a/testbed/common/Cone.h +++ b/testbed/common/Cone.h @@ -99,15 +99,8 @@ class Cone : public openglframework::Mesh, public PhysicsObject { virtual void updateTransform(float interpolationFactor); }; -<<<<<<< HEAD:examples/common/Cone.h -// Return a pointer to the rigid body of the box -inline rp3d::RigidBody* Cone::getRigidBody() { - return static_cast(mRigidBody); -======= -// Update the transform matrix of the object inline void Cone::updateTransform(float interpolationFactor) { mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix); ->>>>>>> 1bde11f245806de07a12b1cf6c33cdb83046b882:testbed/common/Cone.h } #endif diff --git a/testbed/common/Sphere.h b/testbed/common/Sphere.h index 41d159e3..99a27ecc 100644 --- a/testbed/common/Sphere.h +++ b/testbed/common/Sphere.h @@ -96,15 +96,9 @@ class Sphere : public openglframework::Mesh, public PhysicsObject { virtual void updateTransform(float interpolationFactor); }; -<<<<<<< HEAD:examples/common/Sphere.h -// Return a pointer to the rigid body of the box -inline rp3d::RigidBody* Sphere::getRigidBody() { - return static_cast(mRigidBody); -======= // Update the transform matrix of the object inline void Sphere::updateTransform(float interpolationFactor) { mTransformMatrix = computeTransform(interpolationFactor, mScalingMatrix); ->>>>>>> 1bde11f245806de07a12b1cf6c33cdb83046b882:testbed/common/Sphere.h } #endif From 22d90659bbc5119f49a4c81239f16d250da8d108 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 26 Aug 2015 04:30:07 -0600 Subject: [PATCH 4/4] Final fix :) --- src/body/RigidBody.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 64153937..364a7592 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -401,7 +401,7 @@ void RigidBody::updateBroadPhaseState() const { PROFILE("RigidBody::updateBroadPhaseState()"); DynamicsWorld& world = static_cast(mWorld); - const Vector3 displacement = world.mTimer.getTimeStep() * mLinearVelocity; + const Vector3 displacement = world.mTimeStep * mLinearVelocity; // For all the proxy collision shapes of the body for (ProxyShape* shape = mProxyCollisionShapes; shape != NULL; shape = shape->mNext) {