diff --git a/ephysics/body/RigidBody.cpp b/ephysics/body/RigidBody.cpp index 9249550..98625d9 100644 --- a/ephysics/body/RigidBody.cpp +++ b/ephysics/body/RigidBody.cpp @@ -20,13 +20,13 @@ using namespace reactphysics3d; * @param id The ID of the body */ RigidBody::RigidBody(const Transform& transform, CollisionWorld& world, bodyindex id) - : CollisionBody(transform, world, id), mInitMass(float(1.0)), - mCenterOfMassLocal(0, 0, 0), mCenterOfMassWorld(transform.getPosition()), - m_isGravityEnabled(true), mLinearDamping(float(0.0)), mAngularDamping(float(0.0)), + : CollisionBody(transform, world, id), m_initMass(float(1.0)), + m_centerOfMassLocal(0, 0, 0), m_centerOfMassWorld(transform.getPosition()), + m_isGravityEnabled(true), m_linearDamping(float(0.0)), m_angularDamping(float(0.0)), m_jointsList(NULL) { // Compute the inverse mass - m_massInverse = float(1.0) / mInitMass; + m_massInverse = float(1.0) / m_initMass; } // Destructor @@ -60,8 +60,8 @@ void RigidBody::setType(BodyType type) { if (m_type == STATIC) { // Reset the velocity to zero - mLinearVelocity.setToZero(); - mAngularVelocity.setToZero(); + m_linearVelocity.setToZero(); + m_angularVelocity.setToZero(); } // If it is a static or a kinematic body @@ -69,13 +69,13 @@ void RigidBody::setType(BodyType type) { // Reset the inverse mass and inverse inertia tensor to zero m_massInverse = float(0.0); - mInertiaTensorLocal.setToZero(); - mInertiaTensorLocalInverse.setToZero(); + m_inertiaTensorLocal.setToZero(); + m_inertiaTensorLocalInverse.setToZero(); } else { // If it is a dynamic body - m_massInverse = float(1.0) / mInitMass; - mInertiaTensorLocalInverse = mInertiaTensorLocal.getInverse(); + m_massInverse = float(1.0) / m_initMass; + m_inertiaTensorLocalInverse = m_inertiaTensorLocal.getInverse(); } // Awake the body @@ -89,8 +89,8 @@ void RigidBody::setType(BodyType type) { askForBroadPhaseCollisionCheck(); // Reset the force and torque on the body - mExternalForce.setToZero(); - mExternalTorque.setToZero(); + m_externalForce.setToZero(); + m_externalTorque.setToZero(); } // Set the local inertia tensor of the body (in local-space coordinates) @@ -102,10 +102,10 @@ void RigidBody::setInertiaTensorLocal(const Matrix3x3& inertiaTensorLocal) { if (m_type != DYNAMIC) return; - mInertiaTensorLocal = inertiaTensorLocal; + m_inertiaTensorLocal = inertiaTensorLocal; // Compute the inverse local inertia tensor - mInertiaTensorLocalInverse = mInertiaTensorLocal.getInverse(); + m_inertiaTensorLocalInverse = m_inertiaTensorLocal.getInverse(); } // Set the local center of mass of the body (in local-space coordinates) @@ -117,14 +117,14 @@ void RigidBody::setCenterOfMassLocal(const Vector3& centerOfMassLocal) { if (m_type != DYNAMIC) return; - const Vector3 oldCenterOfMass = mCenterOfMassWorld; - mCenterOfMassLocal = centerOfMassLocal; + const Vector3 oldCenterOfMass = m_centerOfMassWorld; + m_centerOfMassLocal = centerOfMassLocal; // Compute the center of mass in world-space coordinates - mCenterOfMassWorld = m_transform * mCenterOfMassLocal; + m_centerOfMassWorld = m_transform * m_centerOfMassLocal; // Update the linear velocity of the center of mass - mLinearVelocity += mAngularVelocity.cross(mCenterOfMassWorld - oldCenterOfMass); + m_linearVelocity += m_angularVelocity.cross(m_centerOfMassWorld - oldCenterOfMass); } // Set the mass of the rigid body @@ -135,13 +135,13 @@ void RigidBody::setMass(float mass) { if (m_type != DYNAMIC) return; - mInitMass = mass; + m_initMass = mass; - if (mInitMass > float(0.0)) { - m_massInverse = float(1.0) / mInitMass; + if (m_initMass > float(0.0)) { + m_massInverse = float(1.0) / m_initMass; } else { - mInitMass = float(1.0); + m_initMass = float(1.0); m_massInverse = float(1.0); } } @@ -253,10 +253,10 @@ void RigidBody::setLinearVelocity(const Vector3& linearVelocity) { if (m_type == STATIC) return; // Update the linear velocity of the current body state - mLinearVelocity = linearVelocity; + m_linearVelocity = linearVelocity; // If the linear velocity is not zero, awake the body - if (mLinearVelocity.lengthSquare() > float(0.0)) { + if (m_linearVelocity.lengthSquare() > float(0.0)) { setIsSleeping(false); } } @@ -271,10 +271,10 @@ void RigidBody::setAngularVelocity(const Vector3& angularVelocity) { if (m_type == STATIC) return; // Set the angular velocity - mAngularVelocity = angularVelocity; + m_angularVelocity = angularVelocity; // If the velocity is not zero, awake the body - if (mAngularVelocity.lengthSquare() > float(0.0)) { + if (m_angularVelocity.lengthSquare() > float(0.0)) { setIsSleeping(false); } } @@ -289,13 +289,13 @@ void RigidBody::setTransform(const Transform& transform) { // Update the transform of the body m_transform = transform; - const Vector3 oldCenterOfMass = mCenterOfMassWorld; + const Vector3 oldCenterOfMass = m_centerOfMassWorld; // Compute the new center of mass in world-space coordinates - mCenterOfMassWorld = m_transform * mCenterOfMassLocal; + m_centerOfMassWorld = m_transform * m_centerOfMassLocal; // Update the linear velocity of the center of mass - mLinearVelocity += mAngularVelocity.cross(mCenterOfMassWorld - oldCenterOfMass); + m_linearVelocity += m_angularVelocity.cross(m_centerOfMassWorld - oldCenterOfMass); // Update the broad-phase state of the body updateBroadPhaseState(); @@ -305,15 +305,15 @@ void RigidBody::setTransform(const Transform& transform) { // the collision shapes attached to the body. void RigidBody::recomputeMassInformation() { - mInitMass = float(0.0); + m_initMass = float(0.0); m_massInverse = float(0.0); - mInertiaTensorLocal.setToZero(); - mInertiaTensorLocalInverse.setToZero(); - mCenterOfMassLocal.setToZero(); + m_inertiaTensorLocal.setToZero(); + m_inertiaTensorLocalInverse.setToZero(); + m_centerOfMassLocal.setToZero(); // If it is STATIC or KINEMATIC body if (m_type == STATIC || m_type == KINEMATIC) { - mCenterOfMassWorld = m_transform.getPosition(); + m_centerOfMassWorld = m_transform.getPosition(); return; } @@ -321,22 +321,22 @@ void RigidBody::recomputeMassInformation() { // Compute the total mass of the body for (ProxyShape* shape = m_proxyCollisionShapes; shape != NULL; shape = shape->m_next) { - mInitMass += shape->getMass(); - mCenterOfMassLocal += shape->getLocalToBodyTransform().getPosition() * shape->getMass(); + m_initMass += shape->getMass(); + m_centerOfMassLocal += shape->getLocalToBodyTransform().getPosition() * shape->getMass(); } - if (mInitMass > float(0.0)) { - m_massInverse = float(1.0) / mInitMass; + if (m_initMass > float(0.0)) { + m_massInverse = float(1.0) / m_initMass; } else { - mInitMass = float(1.0); + m_initMass = float(1.0); m_massInverse = float(1.0); } // Compute the center of mass - const Vector3 oldCenterOfMass = mCenterOfMassWorld; - mCenterOfMassLocal *= m_massInverse; - mCenterOfMassWorld = m_transform * mCenterOfMassLocal; + const Vector3 oldCenterOfMass = m_centerOfMassWorld; + m_centerOfMassLocal *= m_massInverse; + m_centerOfMassWorld = m_transform * m_centerOfMassLocal; // Compute the total mass and inertia tensor using all the collision shapes for (ProxyShape* shape = m_proxyCollisionShapes; shape != NULL; shape = shape->m_next) { @@ -352,7 +352,7 @@ void RigidBody::recomputeMassInformation() { // Use the parallel axis theorem to convert the inertia tensor w.r.t the collision shape // center int32_to a inertia tensor w.r.t to the body origin. - Vector3 offset = shapeTransform.getPosition() - mCenterOfMassLocal; + Vector3 offset = shapeTransform.getPosition() - m_centerOfMassLocal; float offsetSquare = offset.lengthSquare(); Matrix3x3 offsetMatrix; offsetMatrix[0].setAllValues(offsetSquare, float(0.0), float(0.0)); @@ -363,14 +363,14 @@ void RigidBody::recomputeMassInformation() { offsetMatrix[2] += offset * (-offset.z); offsetMatrix *= shape->getMass(); - mInertiaTensorLocal += inertiaTensor + offsetMatrix; + m_inertiaTensorLocal += inertiaTensor + offsetMatrix; } // Compute the local inverse inertia tensor - mInertiaTensorLocalInverse = mInertiaTensorLocal.getInverse(); + m_inertiaTensorLocalInverse = m_inertiaTensorLocal.getInverse(); // Update the linear velocity of the center of mass - mLinearVelocity += mAngularVelocity.cross(mCenterOfMassWorld - oldCenterOfMass); + m_linearVelocity += m_angularVelocity.cross(m_centerOfMassWorld - oldCenterOfMass); } // Update the broad-phase state for this body (because it has moved for instance) @@ -379,7 +379,7 @@ void RigidBody::updateBroadPhaseState() const { PROFILE("RigidBody::updateBroadPhaseState()"); DynamicsWorld& world = static_cast(m_world); - const Vector3 displacement = world.m_timeStep * mLinearVelocity; + const Vector3 displacement = world.m_timeStep * m_linearVelocity; // For all the proxy collision shapes of the body for (ProxyShape* shape = m_proxyCollisionShapes; shape != NULL; shape = shape->m_next) { diff --git a/ephysics/body/RigidBody.h b/ephysics/body/RigidBody.h index bac1dbe..f2071e8 100644 --- a/ephysics/body/RigidBody.h +++ b/ephysics/body/RigidBody.h @@ -34,33 +34,33 @@ class RigidBody : public CollisionBody { // -------------------- Attributes -------------------- // /// Intial mass of the body - float mInitMass; + float m_initMass; /// Center of mass of the body in local-space coordinates. /// The center of mass can therefore be different from the body origin - Vector3 mCenterOfMassLocal; + Vector3 m_centerOfMassLocal; /// Center of mass of the body in world-space coordinates - Vector3 mCenterOfMassWorld; + Vector3 m_centerOfMassWorld; /// Linear velocity of the body - Vector3 mLinearVelocity; + Vector3 m_linearVelocity; /// Angular velocity of the body - Vector3 mAngularVelocity; + Vector3 m_angularVelocity; /// Current external force on the body - Vector3 mExternalForce; + Vector3 m_externalForce; /// Current external torque on the body - Vector3 mExternalTorque; + Vector3 m_externalTorque; /// Local inertia tensor of the body (in local-space) with respect to the /// center of mass of the body - Matrix3x3 mInertiaTensorLocal; + Matrix3x3 m_inertiaTensorLocal; /// Inverse of the inertia tensor of the body - Matrix3x3 mInertiaTensorLocalInverse; + Matrix3x3 m_inertiaTensorLocalInverse; /// Inverse of the mass of the body float m_massInverse; @@ -69,13 +69,13 @@ class RigidBody : public CollisionBody { bool m_isGravityEnabled; /// Material properties of the rigid body - Material mMaterial; + Material m_material; /// Linear velocity damping factor - float mLinearDamping; + float m_linearDamping; /// Angular velocity damping factor - float mAngularDamping; + float m_angularDamping; /// First element of the linked list of joints involving this body JointListElement* m_jointsList; @@ -215,7 +215,7 @@ class RigidBody : public CollisionBody { * @return The mass (in kilograms) of the body */ inline float RigidBody::getMass() const { - return mInitMass; + return m_initMass; } // Return the linear velocity @@ -223,7 +223,7 @@ inline float RigidBody::getMass() const { * @return The linear velocity vector of the body */ inline Vector3 RigidBody::getLinearVelocity() const { - return mLinearVelocity; + return m_linearVelocity; } // Return the angular velocity of the body @@ -231,7 +231,7 @@ inline Vector3 RigidBody::getLinearVelocity() const { * @return The angular velocity vector of the body */ inline Vector3 RigidBody::getAngularVelocity() const { - return mAngularVelocity; + return m_angularVelocity; } // Return the local inertia tensor of the body (in local-space coordinates) @@ -239,7 +239,7 @@ inline Vector3 RigidBody::getAngularVelocity() const { * @return The 3x3 inertia tensor matrix of the body (in local-space coordinates) */ inline const Matrix3x3& RigidBody::getInertiaTensorLocal() const { - return mInertiaTensorLocal; + return m_inertiaTensorLocal; } // Return the inertia tensor in world coordinates. @@ -254,7 +254,7 @@ inline const Matrix3x3& RigidBody::getInertiaTensorLocal() const { inline Matrix3x3 RigidBody::getInertiaTensorWorld() const { // Compute and return the inertia tensor in world coordinates - return m_transform.getOrientation().getMatrix() * mInertiaTensorLocal * + return m_transform.getOrientation().getMatrix() * m_inertiaTensorLocal * m_transform.getOrientation().getMatrix().getTranspose(); } @@ -274,7 +274,7 @@ inline Matrix3x3 RigidBody::getInertiaTensorInverseWorld() const { // INVERSE WORLD TENSOR IN THE CLASS AND UPLDATE IT WHEN THE ORIENTATION OF THE BODY CHANGES // Compute and return the inertia tensor in world coordinates - return m_transform.getOrientation().getMatrix() * mInertiaTensorLocalInverse * + return m_transform.getOrientation().getMatrix() * m_inertiaTensorLocalInverse * m_transform.getOrientation().getMatrix().getTranspose(); } @@ -299,7 +299,7 @@ inline void RigidBody::enableGravity(bool isEnabled) { * @return A reference to the material of the body */ inline Material& RigidBody::getMaterial() { - return mMaterial; + return m_material; } // Set a new material for this rigid body @@ -307,7 +307,7 @@ inline Material& RigidBody::getMaterial() { * @param material The material you want to set to the body */ inline void RigidBody::setMaterial(const Material& material) { - mMaterial = material; + m_material = material; } // Return the linear velocity damping factor @@ -315,7 +315,7 @@ inline void RigidBody::setMaterial(const Material& material) { * @return The linear damping factor of this body */ inline float RigidBody::getLinearDamping() const { - return mLinearDamping; + return m_linearDamping; } // Set the linear damping factor. This is the ratio of the linear velocity @@ -325,7 +325,7 @@ inline float RigidBody::getLinearDamping() const { */ inline void RigidBody::setLinearDamping(float linearDamping) { assert(linearDamping >= float(0.0)); - mLinearDamping = linearDamping; + m_linearDamping = linearDamping; } // Return the angular velocity damping factor @@ -333,7 +333,7 @@ inline void RigidBody::setLinearDamping(float linearDamping) { * @return The angular damping factor of this body */ inline float RigidBody::getAngularDamping() const { - return mAngularDamping; + return m_angularDamping; } // Set the angular damping factor. This is the ratio of the angular velocity @@ -343,7 +343,7 @@ inline float RigidBody::getAngularDamping() const { */ inline void RigidBody::setAngularDamping(float angularDamping) { assert(angularDamping >= float(0.0)); - mAngularDamping = angularDamping; + m_angularDamping = angularDamping; } // Return the first element of the linked list of joints involving this body @@ -366,10 +366,10 @@ inline JointListElement* RigidBody::getJointsList() { inline void RigidBody::setIsSleeping(bool isSleeping) { if (isSleeping) { - mLinearVelocity.setToZero(); - mAngularVelocity.setToZero(); - mExternalForce.setToZero(); - mExternalTorque.setToZero(); + m_linearVelocity.setToZero(); + m_angularVelocity.setToZero(); + m_externalForce.setToZero(); + m_externalTorque.setToZero(); } Body::setIsSleeping(isSleeping); @@ -394,7 +394,7 @@ inline void RigidBody::applyForceToCenterOfMass(const Vector3& force) { } // Add the force - mExternalForce += force; + m_externalForce += force; } // Apply an external force to the body at a given point (in world-space coordinates). @@ -419,8 +419,8 @@ inline void RigidBody::applyForce(const Vector3& force, const Vector3& point) { } // Add the force and torque - mExternalForce += force; - mExternalTorque += (point - mCenterOfMassWorld).cross(force); + m_externalForce += force; + m_externalTorque += (point - m_centerOfMassWorld).cross(force); } // Apply an external torque to the body. @@ -442,14 +442,14 @@ inline void RigidBody::applyTorque(const Vector3& torque) { } // Add the torque - mExternalTorque += torque; + m_externalTorque += torque; } /// Update the transform of the body after a change of the center of mass inline void RigidBody::updateTransformWithCenterOfMass() { // Translate the body according to the translation of the center of mass position - m_transform.setPosition(mCenterOfMassWorld - m_transform.getOrientation() * mCenterOfMassLocal); + m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal); } } diff --git a/ephysics/collision/TriangleMesh.h b/ephysics/collision/TriangleMesh.h index 386433f..3107f5f 100644 --- a/ephysics/collision/TriangleMesh.h +++ b/ephysics/collision/TriangleMesh.h @@ -25,7 +25,7 @@ class TriangleMesh { protected: /// All the triangle arrays of the mesh (one triangle array per part) - std::vector mTriangleArrays; + std::vector m_triangleArrays; public: @@ -47,18 +47,18 @@ class TriangleMesh { // Add a subpart of the mesh inline void TriangleMesh::addSubpart(TriangleVertexArray* triangleVertexArray) { - mTriangleArrays.push_back(triangleVertexArray ); + m_triangleArrays.push_back(triangleVertexArray ); } // Return a pointer to a given subpart (triangle vertex array) of the mesh inline TriangleVertexArray* TriangleMesh::getSubpart(uint32_t indexSubpart) const { - assert(indexSubpart < mTriangleArrays.size()); - return mTriangleArrays[indexSubpart]; + assert(indexSubpart < m_triangleArrays.size()); + return m_triangleArrays[indexSubpart]; } // Return the number of subparts of the mesh inline uint32_t TriangleMesh::getNbSubparts() const { - return mTriangleArrays.size(); + return m_triangleArrays.size(); } } diff --git a/ephysics/collision/TriangleVertexArray.cpp b/ephysics/collision/TriangleVertexArray.cpp index b0fe3be..de94636 100644 --- a/ephysics/collision/TriangleVertexArray.cpp +++ b/ephysics/collision/TriangleVertexArray.cpp @@ -29,11 +29,11 @@ TriangleVertexArray::TriangleVertexArray(uint32_t nbVertices, void* verticesStar m_numberVertices = nbVertices; m_verticesStart = reinterpret_cast(verticesStart); m_verticesStride = verticesStride; - mNbTriangles = nbTriangles; - mIndicesStart = reinterpret_cast(indexesStart); - mIndicesStride = indexesStride; - mVertexDataType = vertexDataType; - mIndexDataType = indexDataType; + m_numberTriangles = nbTriangles; + m_indicesStart = reinterpret_cast(indexesStart); + m_indicesStride = indexesStride; + m_vertexDataType = vertexDataType; + m_indexDataType = indexDataType; } // Destructor diff --git a/ephysics/collision/TriangleVertexArray.h b/ephysics/collision/TriangleVertexArray.h index daf3c4b..e76d42e 100644 --- a/ephysics/collision/TriangleVertexArray.h +++ b/ephysics/collision/TriangleVertexArray.h @@ -43,20 +43,20 @@ class TriangleVertexArray { int32_t m_verticesStride; /// Number of triangles in the array - uint32_t mNbTriangles; + uint32_t m_numberTriangles; /// Pointer to the first vertex index of the array - unsigned char* mIndicesStart; + unsigned char* m_indicesStart; /// Stride (number of bytes) between the beginning of two indices in /// the array - int32_t mIndicesStride; + int32_t m_indicesStride; /// Data type of the vertices in the array - VertexDataType mVertexDataType; + VertexDataType m_vertexDataType; /// Data type of the indices in the array - IndexDataType mIndexDataType; + IndexDataType m_indexDataType; public: @@ -95,12 +95,12 @@ class TriangleVertexArray { // Return the vertex data type inline TriangleVertexArray::VertexDataType TriangleVertexArray::getVertexDataType() const { - return mVertexDataType; + return m_vertexDataType; } // Return the index data type inline TriangleVertexArray::IndexDataType TriangleVertexArray::getIndexDataType() const { - return mIndexDataType; + return m_indexDataType; } // Return the number of vertices @@ -110,7 +110,7 @@ inline uint32_t TriangleVertexArray::getNbVertices() const { // Return the number of triangles inline uint32_t TriangleVertexArray::getNbTriangles() const { - return mNbTriangles; + return m_numberTriangles; } // Return the vertices stride (number of bytes) @@ -120,7 +120,7 @@ inline int32_t TriangleVertexArray::getVerticesStride() const { // Return the indices stride (number of bytes) inline int32_t TriangleVertexArray::getIndicesStride() const { - return mIndicesStride; + return m_indicesStride; } // Return the pointer to the start of the vertices array @@ -130,7 +130,7 @@ inline unsigned char* TriangleVertexArray::getVerticesStart() const { // Return the pointer to the start of the indices array inline unsigned char* TriangleVertexArray::getIndicesStart() const { - return mIndicesStart; + return m_indicesStart; } } diff --git a/ephysics/collision/narrowphase/EPA/TrianglesStore.cpp b/ephysics/collision/narrowphase/EPA/TrianglesStore.cpp index 9c4a1fc..710974f 100644 --- a/ephysics/collision/narrowphase/EPA/TrianglesStore.cpp +++ b/ephysics/collision/narrowphase/EPA/TrianglesStore.cpp @@ -11,7 +11,7 @@ using namespace reactphysics3d; // Constructor -TrianglesStore::TrianglesStore() : mNbTriangles(0) { +TrianglesStore::TrianglesStore() : m_numberTriangles(0) { } diff --git a/ephysics/collision/narrowphase/EPA/TrianglesStore.h b/ephysics/collision/narrowphase/EPA/TrianglesStore.h index 28f4daa..0dd5d1e 100644 --- a/ephysics/collision/narrowphase/EPA/TrianglesStore.h +++ b/ephysics/collision/narrowphase/EPA/TrianglesStore.h @@ -31,7 +31,7 @@ class TrianglesStore { TriangleEPA mTriangles[MAX_TRIANGLES]; /// Number of triangles - int32_t mNbTriangles; + int32_t m_numberTriangles; // -------------------- Methods -------------------- // @@ -72,23 +72,23 @@ class TrianglesStore { // Clear all the storage inline void TrianglesStore::clear() { - mNbTriangles = 0; + m_numberTriangles = 0; } // Return the number of triangles inline int32_t TrianglesStore::getNbTriangles() const { - return mNbTriangles; + return m_numberTriangles; } inline void TrianglesStore::setNbTriangles(int32_t backup) { - mNbTriangles = backup; + m_numberTriangles = backup; } // Return the last triangle inline TriangleEPA& TrianglesStore::last() { - assert(mNbTriangles > 0); - return mTriangles[mNbTriangles - 1]; + assert(m_numberTriangles > 0); + return mTriangles[m_numberTriangles - 1]; } // Create a new triangle @@ -97,11 +97,11 @@ inline TriangleEPA* TrianglesStore::newTriangle(const Vector3* vertices, TriangleEPA* newTriangle = NULL; // If we have not reached the maximum number of triangles - if (mNbTriangles != MAX_TRIANGLES) { - newTriangle = &mTriangles[mNbTriangles++]; + if (m_numberTriangles != MAX_TRIANGLES) { + newTriangle = &mTriangles[m_numberTriangles++]; new (newTriangle) TriangleEPA(v0, v1, v2); if (!newTriangle->computeClosestPoint(vertices)) { - mNbTriangles--; + m_numberTriangles--; newTriangle = NULL; } } diff --git a/ephysics/constraint/BallAndSocketJoint.cpp b/ephysics/constraint/BallAndSocketJoint.cpp index 720659b..4364b8e 100644 --- a/ephysics/constraint/BallAndSocketJoint.cpp +++ b/ephysics/constraint/BallAndSocketJoint.cpp @@ -35,8 +35,8 @@ void BallAndSocketJoint::initBeforeSolve(const ConstraintSolverData& constraintS m_indexBody2 = constraintSolverData.mapBodyToConstrainedVelocityIndex.find(m_body2)->second; // Get the bodies center of mass and orientations - const Vector3& x1 = m_body1->mCenterOfMassWorld; - const Vector3& x2 = m_body2->mCenterOfMassWorld; + const Vector3& x1 = m_body1->m_centerOfMassWorld; + const Vector3& x2 = m_body2->m_centerOfMassWorld; const Quaternion& orientationBody1 = m_body1->getTransform().getOrientation(); const Quaternion& orientationBody2 = m_body2->getTransform().getOrientation(); diff --git a/ephysics/constraint/FixedJoint.cpp b/ephysics/constraint/FixedJoint.cpp index 1aaa4ca..d3be150 100644 --- a/ephysics/constraint/FixedJoint.cpp +++ b/ephysics/constraint/FixedJoint.cpp @@ -43,8 +43,8 @@ void FixedJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat m_indexBody2 = constraintSolverData.mapBodyToConstrainedVelocityIndex.find(m_body2)->second; // Get the bodies positions and orientations - const Vector3& x1 = m_body1->mCenterOfMassWorld; - const Vector3& x2 = m_body2->mCenterOfMassWorld; + const Vector3& x1 = m_body1->m_centerOfMassWorld; + const Vector3& x2 = m_body2->m_centerOfMassWorld; const Quaternion& orientationBody1 = m_body1->getTransform().getOrientation(); const Quaternion& orientationBody2 = m_body2->getTransform().getOrientation(); diff --git a/ephysics/constraint/HingeJoint.cpp b/ephysics/constraint/HingeJoint.cpp index aec4364..a31ffbf 100644 --- a/ephysics/constraint/HingeJoint.cpp +++ b/ephysics/constraint/HingeJoint.cpp @@ -58,8 +58,8 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat m_indexBody2 = constraintSolverData.mapBodyToConstrainedVelocityIndex.find(m_body2)->second; // Get the bodies positions and orientations - const Vector3& x1 = m_body1->mCenterOfMassWorld; - const Vector3& x2 = m_body2->mCenterOfMassWorld; + const Vector3& x1 = m_body1->m_centerOfMassWorld; + const Vector3& x2 = m_body2->m_centerOfMassWorld; const Quaternion& orientationBody1 = m_body1->getTransform().getOrientation(); const Quaternion& orientationBody2 = m_body2->getTransform().getOrientation(); diff --git a/ephysics/constraint/SliderJoint.cpp b/ephysics/constraint/SliderJoint.cpp index f7761b1..ba06f73 100644 --- a/ephysics/constraint/SliderJoint.cpp +++ b/ephysics/constraint/SliderJoint.cpp @@ -57,8 +57,8 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa m_indexBody2 = constraintSolverData.mapBodyToConstrainedVelocityIndex.find(m_body2)->second; // Get the bodies positions and orientations - const Vector3& x1 = m_body1->mCenterOfMassWorld; - const Vector3& x2 = m_body2->mCenterOfMassWorld; + const Vector3& x1 = m_body1->m_centerOfMassWorld; + const Vector3& x2 = m_body2->m_centerOfMassWorld; const Quaternion& orientationBody1 = m_body1->getTransform().getOrientation(); const Quaternion& orientationBody2 = m_body2->getTransform().getOrientation(); diff --git a/ephysics/engine/ContactSolver.cpp b/ephysics/engine/ContactSolver.cpp index ec3a5ec..c396012 100644 --- a/ephysics/engine/ContactSolver.cpp +++ b/ephysics/engine/ContactSolver.cpp @@ -70,8 +70,8 @@ void ContactSolver::initializeForIsland(float dt, Island* island) { assert(body2 != NULL); // Get the position of the two bodies - const Vector3& x1 = body1->mCenterOfMassWorld; - const Vector3& x2 = body2->mCenterOfMassWorld; + const Vector3& x1 = body1->m_centerOfMassWorld; + const Vector3& x2 = body2->m_centerOfMassWorld; // Initialize the int32_ternal contact manifold structure using the external // contact manifold diff --git a/ephysics/engine/DynamicsWorld.cpp b/ephysics/engine/DynamicsWorld.cpp index 7c6f2c8..7aca004 100644 --- a/ephysics/engine/DynamicsWorld.cpp +++ b/ephysics/engine/DynamicsWorld.cpp @@ -180,7 +180,7 @@ void DynamicsWorld::int32_tegrateRigidBodiesPositions() { } // Get current position and orientation of the body - const Vector3& currentPosition = bodies[b]->mCenterOfMassWorld; + const Vector3& currentPosition = bodies[b]->m_centerOfMassWorld; const Quaternion& currentOrientation = bodies[b]->getTransform().getOrientation(); // Update the new constrained position and orientation of the body @@ -208,11 +208,11 @@ void DynamicsWorld::updateBodiesState() { uint32_t index = m_mapBodyToConstrainedVelocityIndex.find(bodies[b])->second; // Update the linear and angular velocity of the body - bodies[b]->mLinearVelocity = m_constrainedLinearVelocities[index]; - bodies[b]->mAngularVelocity = m_constrainedAngularVelocities[index]; + bodies[b]->m_linearVelocity = m_constrainedLinearVelocities[index]; + bodies[b]->m_angularVelocity = m_constrainedAngularVelocities[index]; // Update the position of the center of mass of the body - bodies[b]->mCenterOfMassWorld = m_constrainedPositions[index]; + bodies[b]->m_centerOfMassWorld = m_constrainedPositions[index]; // Update the orientation of the body bodies[b]->m_transform.setOrientation(m_constrainedOrientations[index].getUnit()); @@ -298,10 +298,10 @@ void DynamicsWorld::int32_tegrateRigidBodiesVelocities() { // Integrate the external force to get the new velocity of the body m_constrainedLinearVelocities[indexBody] = bodies[b]->getLinearVelocity() + - m_timeStep * bodies[b]->m_massInverse * bodies[b]->mExternalForce; + m_timeStep * bodies[b]->m_massInverse * bodies[b]->m_externalForce; m_constrainedAngularVelocities[indexBody] = bodies[b]->getAngularVelocity() + m_timeStep * bodies[b]->getInertiaTensorInverseWorld() * - bodies[b]->mExternalTorque; + bodies[b]->m_externalTorque; // If the gravity has to be applied to this rigid body if (bodies[b]->isGravityEnabled() && m_isGravityEnabled) { diff --git a/ephysics/engine/DynamicsWorld.h b/ephysics/engine/DynamicsWorld.h index 63c6293..084d438 100644 --- a/ephysics/engine/DynamicsWorld.h +++ b/ephysics/engine/DynamicsWorld.h @@ -290,8 +290,8 @@ inline void DynamicsWorld::resetBodiesForceAndTorque() { // For each body of the world std::set::iterator it; for (it = m_rigidBodies.begin(); it != m_rigidBodies.end(); ++it) { - (*it)->mExternalForce.setToZero(); - (*it)->mExternalTorque.setToZero(); + (*it)->m_externalForce.setToZero(); + (*it)->m_externalTorque.setToZero(); } } diff --git a/ephysics/engine/Timer.cpp b/ephysics/engine/Timer.cpp index 7b0d1c4..1193e3d 100644 --- a/ephysics/engine/Timer.cpp +++ b/ephysics/engine/Timer.cpp @@ -11,7 +11,7 @@ using namespace reactphysics3d; // Constructor -Timer::Timer(double timeStep) : m_timeStep(timeStep), mIsRunning(false) { +Timer::Timer(double timeStep) : m_timeStep(timeStep), m_isRunning(false) { assert(timeStep > 0.0); } diff --git a/ephysics/engine/Timer.h b/ephysics/engine/Timer.h index 806cf63..d5e7dcc 100644 --- a/ephysics/engine/Timer.h +++ b/ephysics/engine/Timer.h @@ -39,16 +39,16 @@ class Timer { double m_timeStep; /// Last time the timer has been updated - long double mLastUpdateTime; + long double m_lastUpdateTime; /// Time difference between the two last timer update() calls - long double mDeltaTime; + long double m_deltaTime; /// Used to fix the time step and avoid strange time effects - double mAccumulator; + double m_accumulator; /// True if the timer is running - bool mIsRunning; + bool m_isRunning; // -------------------- Methods -------------------- // @@ -115,47 +115,47 @@ inline void Timer::setTimeStep(double timeStep) { // Return the current time inline long double Timer::getPhysicsTime() const { - return mLastUpdateTime; + return m_lastUpdateTime; } // Return if the timer is running inline bool Timer::getIsRunning() const { - return mIsRunning; + return m_isRunning; } // Start the timer inline void Timer::start() { - if (!mIsRunning) { + if (!m_isRunning) { // Get the current system time - mLastUpdateTime = getCurrentSystemTime(); + m_lastUpdateTime = getCurrentSystemTime(); - mAccumulator = 0.0; - mIsRunning = true; + m_accumulator = 0.0; + m_isRunning = true; } } // Stop the timer inline void Timer::stop() { - mIsRunning = false; + m_isRunning = false; } // True if it's possible to take a new step inline bool Timer::isPossibleToTakeStep() const { - return (mAccumulator >= m_timeStep); + return (m_accumulator >= m_timeStep); } // Take a new step => update the timer by adding the timeStep value to the current time inline void Timer::nextStep() { - assert(mIsRunning); + assert(m_isRunning); // Update the accumulator value - mAccumulator -= m_timeStep; + m_accumulator -= m_timeStep; } // Compute the int32_terpolation factor inline float Timer::computeInterpolationFactor() { - return (float(mAccumulator / m_timeStep)); + return (float(m_accumulator / m_timeStep)); } // Compute the time since the last update() call and add it to the accumulator @@ -165,13 +165,13 @@ inline void Timer::update() { long double currentTime = getCurrentSystemTime(); // Compute the delta display time between two display frames - mDeltaTime = currentTime - mLastUpdateTime; + m_deltaTime = currentTime - m_lastUpdateTime; // Update the current display time - mLastUpdateTime = currentTime; + m_lastUpdateTime = currentTime; // Update the accumulator value - mAccumulator += mDeltaTime; + m_accumulator += m_deltaTime; } } diff --git a/ephysics/mathematics/Transform.cpp b/ephysics/mathematics/Transform.cpp index 4bebc5a..b6a01e9 100644 --- a/ephysics/mathematics/Transform.cpp +++ b/ephysics/mathematics/Transform.cpp @@ -11,25 +11,25 @@ using namespace reactphysics3d; // Constructor -Transform::Transform() : mPosition(Vector3(0.0, 0.0, 0.0)), mOrientation(Quaternion::identity()) { +Transform::Transform() : m_position(Vector3(0.0, 0.0, 0.0)), m_orientation(Quaternion::identity()) { } // Constructor Transform::Transform(const Vector3& position, const Matrix3x3& orientation) - : mPosition(position), mOrientation(Quaternion(orientation)) { + : m_position(position), m_orientation(Quaternion(orientation)) { } // Constructor Transform::Transform(const Vector3& position, const Quaternion& orientation) - : mPosition(position), mOrientation(orientation) { + : m_position(position), m_orientation(orientation) { } // Copy-constructor Transform::Transform(const Transform& transform) - : mPosition(transform.mPosition), mOrientation(transform.mOrientation) { + : m_position(transform.m_position), m_orientation(transform.m_orientation) { } diff --git a/ephysics/mathematics/Transform.h b/ephysics/mathematics/Transform.h index 27b58b6..2db3281 100644 --- a/ephysics/mathematics/Transform.h +++ b/ephysics/mathematics/Transform.h @@ -25,10 +25,10 @@ class Transform { // -------------------- Attributes -------------------- // /// Position - Vector3 mPosition; + Vector3 m_position; /// Orientation - Quaternion mOrientation; + Quaternion m_orientation; public : @@ -99,28 +99,28 @@ class Transform { // Return the position of the transform inline const Vector3& Transform::getPosition() const { - return mPosition; + return m_position; } // Set the origin of the transform inline void Transform::setPosition(const Vector3& position) { - mPosition = position; + m_position = position; } // Return the rotation matrix inline const Quaternion& Transform::getOrientation() const { - return mOrientation; + return m_orientation; } // Set the rotation matrix of the transform inline void Transform::setOrientation(const Quaternion& orientation) { - mOrientation = orientation; + m_orientation = orientation; } // Set the transform to the identity transform inline void Transform::setToIdentity() { - mPosition = Vector3(0.0, 0.0, 0.0); - mOrientation = Quaternion::identity(); + m_position = Vector3(0.0, 0.0, 0.0); + m_orientation = Quaternion::identity(); } // Set the transform from an OpenGL transform matrix @@ -128,28 +128,28 @@ inline void Transform::setFromOpenGL(float* openglMatrix) { Matrix3x3 matrix(openglMatrix[0], openglMatrix[4], openglMatrix[8], openglMatrix[1], openglMatrix[5], openglMatrix[9], openglMatrix[2], openglMatrix[6], openglMatrix[10]); - mOrientation = Quaternion(matrix); - mPosition.setAllValues(openglMatrix[12], openglMatrix[13], openglMatrix[14]); + m_orientation = Quaternion(matrix); + m_position.setAllValues(openglMatrix[12], openglMatrix[13], openglMatrix[14]); } // Get the OpenGL matrix of the transform inline void Transform::getOpenGLMatrix(float* openglMatrix) const { - const Matrix3x3& matrix = mOrientation.getMatrix(); + const Matrix3x3& matrix = m_orientation.getMatrix(); openglMatrix[0] = matrix[0][0]; openglMatrix[1] = matrix[1][0]; openglMatrix[2] = matrix[2][0]; openglMatrix[3] = 0.0; openglMatrix[4] = matrix[0][1]; openglMatrix[5] = matrix[1][1]; openglMatrix[6] = matrix[2][1]; openglMatrix[7] = 0.0; openglMatrix[8] = matrix[0][2]; openglMatrix[9] = matrix[1][2]; openglMatrix[10] = matrix[2][2]; openglMatrix[11] = 0.0; - openglMatrix[12] = mPosition.x; openglMatrix[13] = mPosition.y; - openglMatrix[14] = mPosition.z; openglMatrix[15] = 1.0; + openglMatrix[12] = m_position.x; openglMatrix[13] = m_position.y; + openglMatrix[14] = m_position.z; openglMatrix[15] = 1.0; } // Return the inverse of the transform inline Transform Transform::getInverse() const { - const Quaternion& invQuaternion = mOrientation.getInverse(); + const Quaternion& invQuaternion = m_orientation.getInverse(); Matrix3x3 invMatrix = invQuaternion.getMatrix(); - return Transform(invMatrix * (-mPosition), invQuaternion); + return Transform(invMatrix * (-m_position), invQuaternion); } // Return an int32_terpolated transform @@ -157,11 +157,11 @@ inline Transform Transform::int32_terpolateTransforms(const Transform& oldTransf const Transform& newTransform, float int32_terpolationFactor) { - Vector3 int32_terPosition = oldTransform.mPosition * (float(1.0) - int32_terpolationFactor) + - newTransform.mPosition * int32_terpolationFactor; + Vector3 int32_terPosition = oldTransform.m_position * (float(1.0) - int32_terpolationFactor) + + newTransform.m_position * int32_terpolationFactor; - Quaternion int32_terOrientation = Quaternion::slerp(oldTransform.mOrientation, - newTransform.mOrientation, + Quaternion int32_terOrientation = Quaternion::slerp(oldTransform.m_orientation, + newTransform.m_orientation, int32_terpolationFactor); return Transform(int32_terPosition, int32_terOrientation); @@ -174,18 +174,18 @@ inline Transform Transform::identity() { // Return the transformed vector inline Vector3 Transform::operator*(const Vector3& vector) const { - return (mOrientation.getMatrix() * vector) + mPosition; + return (m_orientation.getMatrix() * vector) + m_position; } // Operator of multiplication of a transform with another one inline Transform Transform::operator*(const Transform& transform2) const { - return Transform(mPosition + mOrientation.getMatrix() * transform2.mPosition, - mOrientation * transform2.mOrientation); + return Transform(m_position + m_orientation.getMatrix() * transform2.m_position, + m_orientation * transform2.m_orientation); } // Return true if the two transforms are equal inline bool Transform::operator==(const Transform& transform2) const { - return (mPosition == transform2.mPosition) && (mOrientation == transform2.mOrientation); + return (m_position == transform2.m_position) && (m_orientation == transform2.m_orientation); } // Return true if the two transforms are different @@ -196,8 +196,8 @@ inline bool Transform::operator!=(const Transform& transform2) const { // Assignment operator inline Transform& Transform::operator=(const Transform& transform) { if (&transform != this) { - mPosition = transform.mPosition; - mOrientation = transform.mOrientation; + m_position = transform.m_position; + m_orientation = transform.m_orientation; } return *this; } diff --git a/tools/testbed/src/Timer.cpp b/tools/testbed/src/Timer.cpp index 1ca4b19..8e500bb 100644 --- a/tools/testbed/src/Timer.cpp +++ b/tools/testbed/src/Timer.cpp @@ -28,7 +28,7 @@ // Constructor -Timer::Timer() : mIsRunning(false) { +Timer::Timer() : m_isRunning(false) { } diff --git a/tools/testbed/src/Timer.h b/tools/testbed/src/Timer.h index 05fdbe4..e8c9272 100644 --- a/tools/testbed/src/Timer.h +++ b/tools/testbed/src/Timer.h @@ -53,16 +53,16 @@ class Timer { // -------------------- Attributes -------------------- // /// Last time the timer has been updated - long double mLastUpdateTime; + long double m_lastUpdateTime; /// Time difference between the two last timer update() calls - long double mDeltaTime; + long double m_d*eltaTime; /// Used to fix the time step and avoid strange time effects - double mAccumulator; + double m_accumulator; /// True if the timer is running - bool mIsRunning; + bool m_isRunning; // -------------------- Methods -------------------- // @@ -112,47 +112,47 @@ class Timer { // Return the current time inline long double Timer::getPhysicsTime() const { - return mLastUpdateTime; + return m_lastUpdateTime; } // Return if the timer is running inline bool Timer::isRunning() const { - return mIsRunning; + return m_isRunning; } // Start the timer inline void Timer::start() { - if (!mIsRunning) { + if (!m_isRunning) { // Get the current system time - mLastUpdateTime = getCurrentSystemTime(); + m_lastUpdateTime = getCurrentSystemTime(); - mAccumulator = 0.0; - mIsRunning = true; + m_accumulator = 0.0; + m_isRunning = true; } } // Stop the timer inline void Timer::stop() { - mIsRunning = false; + m_isRunning = false; } // True if it's possible to take a new step inline bool Timer::isPossibleToTakeStep(float timeStep) const { - return (mAccumulator >= timeStep); + return (m_accumulator >= timeStep); } // Take a new step => update the timer by adding the timeStep value to the current time inline void Timer::nextStep(float timeStep) { - assert(mIsRunning); + assert(m_isRunning); // Update the accumulator value - mAccumulator -= timeStep; + m_accumulator -= timeStep; } // Compute the int32_terpolation factor inline float Timer::computeInterpolationFactor(float timeStep) { - return (float(mAccumulator) / timeStep); + return (float(m_accumulator) / timeStep); } // Compute the time since the last update() call and add it to the accumulator @@ -162,13 +162,13 @@ inline void Timer::update() { long double currentTime = getCurrentSystemTime(); // Compute the delta display time between two display frames - mDeltaTime = currentTime - mLastUpdateTime; + m_d*eltaTime = currentTime - m_lastUpdateTime; // Update the current display time - mLastUpdateTime = currentTime; + m_lastUpdateTime = currentTime; // Update the accumulator value - mAccumulator += mDeltaTime; + m_accumulator += m_d*eltaTime; } #endif