diff --git a/src/collision/ProxyShape.h b/src/collision/ProxyShape.h index 61118d45..9e4ea298 100644 --- a/src/collision/ProxyShape.h +++ b/src/collision/ProxyShape.h @@ -175,12 +175,6 @@ class ProxyShape { /// Return the next proxy shape in the linked list of proxy shapes const ProxyShape* getNext() const; - /// Return the local scaling vector of the collision shape - Vector3 getLocalScaling() const; - - /// Set the local scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling); - /// Return the broad-phase id int getBroadPhaseId() const; @@ -361,35 +355,6 @@ inline void ProxyShape::setCollideWithMaskBits(unsigned short collideWithMaskBit std::to_string(mCollideWithMaskBits)); } -// Return the local scaling vector of the collision shape -/** - * @return The local scaling vector - */ -inline Vector3 ProxyShape::getLocalScaling() const { - return mCollisionShape->getLocalScaling(); -} - -// Set the local scaling vector of the collision shape -/** - * @param scaling The new local scaling vector - */ -inline void ProxyShape::setLocalScaling(const Vector3& scaling) { - - // TODO : Do not use a local of the collision shape in case of shared collision shapes - - // Set the local scaling of the collision shape - mCollisionShape->setLocalScaling(scaling); - - mBody->setIsSleeping(false); - - // Notify the body that the proxy shape has to be updated in the broad-phase - mBody->updateProxyShapeInBroadPhase(this, true); - - RP3D_LOG(mLogger, Logger::Level::Information, Logger::Category::ProxyShape, - "ProxyShape " + std::to_string(mBroadPhaseID) + ": Set localScaling=" + - mCollisionShape->getLocalScaling().to_string()); -} - // Return the broad-phase id inline int ProxyShape::getBroadPhaseId() const { return mBroadPhaseID; diff --git a/src/collision/shapes/BoxShape.h b/src/collision/shapes/BoxShape.h index 0c261a6f..b1128582 100644 --- a/src/collision/shapes/BoxShape.h +++ b/src/collision/shapes/BoxShape.h @@ -88,9 +88,6 @@ class BoxShape : public ConvexPolyhedronShape { /// Return the extents of the box Vector3 getExtent() const; - /// Set the scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; - /// Return the local bounds of the shape in x, y and z directions virtual void getLocalBounds(Vector3& min, Vector3& max) const override; @@ -136,14 +133,6 @@ inline Vector3 BoxShape::getExtent() const { return mExtent; } -// Set the scaling vector of the collision shape -inline void BoxShape::setLocalScaling(const Vector3& scaling) { - - mExtent = (mExtent / mScaling) * scaling; - - CollisionShape::setLocalScaling(scaling); -} - // Return the local bounds of the shape in x, y and z directions /// This method is used to compute the AABB of the box /** diff --git a/src/collision/shapes/CapsuleShape.h b/src/collision/shapes/CapsuleShape.h index 6a58f115..decf6474 100644 --- a/src/collision/shapes/CapsuleShape.h +++ b/src/collision/shapes/CapsuleShape.h @@ -94,9 +94,6 @@ class CapsuleShape : public ConvexShape { /// Return the height of the capsule decimal getHeight() const; - /// Set the scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; - /// Return the local bounds of the shape in x, y and z directions virtual void getLocalBounds(Vector3& min, Vector3& max) const override; @@ -126,15 +123,6 @@ inline decimal CapsuleShape::getHeight() const { return mHalfHeight + mHalfHeight; } -// Set the scaling vector of the collision shape -inline void CapsuleShape::setLocalScaling(const Vector3& scaling) { - - mHalfHeight = (mHalfHeight / mScaling.y) * scaling.y; - mMargin = (mMargin / mScaling.x) * scaling.x; - - CollisionShape::setLocalScaling(scaling); -} - // Return the number of bytes used by the collision shape inline size_t CapsuleShape::getSizeInBytes() const { return sizeof(CapsuleShape); diff --git a/src/collision/shapes/CollisionShape.cpp b/src/collision/shapes/CollisionShape.cpp index 976c7a51..4e6e4b9b 100644 --- a/src/collision/shapes/CollisionShape.cpp +++ b/src/collision/shapes/CollisionShape.cpp @@ -33,7 +33,7 @@ using namespace reactphysics3d; // Constructor CollisionShape::CollisionShape(CollisionShapeName name, CollisionShapeType type) - : mType(type), mName(name), mScaling(1.0, 1.0, 1.0), mId(0) { + : mType(type), mName(name), mId(0) { } diff --git a/src/collision/shapes/CollisionShape.h b/src/collision/shapes/CollisionShape.h index a7b07fc3..990ef33f 100644 --- a/src/collision/shapes/CollisionShape.h +++ b/src/collision/shapes/CollisionShape.h @@ -68,9 +68,6 @@ class CollisionShape { /// Name of the colision shape CollisionShapeName mName; - /// Scaling vector of the collision shape - Vector3 mScaling; - /// Unique identifier of the shape inside an overlapping pair uint mId; @@ -126,9 +123,6 @@ class CollisionShape { /// Return the scaling vector of the collision shape Vector3 getLocalScaling() const; - /// Set the local scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling); - /// Return the id of the shape uint getId() const; @@ -170,16 +164,6 @@ inline CollisionShapeType CollisionShape::getType() const { return mType; } -// Return the scaling vector of the collision shape -inline Vector3 CollisionShape::getLocalScaling() const { - return mScaling; -} - -// Set the scaling vector of the collision shape -inline void CollisionShape::setLocalScaling(const Vector3& scaling) { - mScaling = scaling; -} - // Return the id of the shape inline uint CollisionShape::getId() const { return mId; diff --git a/src/collision/shapes/ConcaveMeshShape.cpp b/src/collision/shapes/ConcaveMeshShape.cpp index bde756e4..a6cfcb9c 100644 --- a/src/collision/shapes/ConcaveMeshShape.cpp +++ b/src/collision/shapes/ConcaveMeshShape.cpp @@ -30,8 +30,9 @@ using namespace reactphysics3d; // Constructor -ConcaveMeshShape::ConcaveMeshShape(TriangleMesh* triangleMesh) - : ConcaveShape(CollisionShapeName::TRIANGLE_MESH), mDynamicAABBTree(MemoryManager::getBaseAllocator()) { +ConcaveMeshShape::ConcaveMeshShape(TriangleMesh* triangleMesh, const Vector3& scaling) + : ConcaveShape(CollisionShapeName::TRIANGLE_MESH), mDynamicAABBTree(MemoryManager::getBaseAllocator()), + mScaling(scaling) { mTriangleMesh = triangleMesh; mRaycastTestType = TriangleRaycastSide::FRONT; diff --git a/src/collision/shapes/ConcaveMeshShape.h b/src/collision/shapes/ConcaveMeshShape.h index ccafbba9..e8ad78e5 100644 --- a/src/collision/shapes/ConcaveMeshShape.h +++ b/src/collision/shapes/ConcaveMeshShape.h @@ -140,6 +140,9 @@ class ConcaveMeshShape : public ConcaveShape { /// if the user did not provide its own vertices normals) Vector3** mComputedVerticesNormals; + /// Scaling + const Vector3 mScaling; + // -------------------- Methods -------------------- // /// Raycast method with feedback information @@ -163,7 +166,7 @@ class ConcaveMeshShape : public ConcaveShape { public: /// Constructor - ConcaveMeshShape(TriangleMesh* triangleMesh); + ConcaveMeshShape(TriangleMesh* triangleMesh, const Vector3& scaling = Vector3(1, 1, 1)); /// Destructor virtual ~ConcaveMeshShape() = default; @@ -174,12 +177,12 @@ class ConcaveMeshShape : public ConcaveShape { /// Deleted assignment operator ConcaveMeshShape& operator=(const ConcaveMeshShape& shape) = delete; + /// Return the scaling vector + const Vector3& getScaling() const; + /// Return the local bounds of the shape in x, y and z directions. virtual void getLocalBounds(Vector3& min, Vector3& max) const override; - /// Set the local scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; - /// Return the local inertia tensor of the collision shape virtual void computeLocalInertiaTensor(Matrix3x3& tensor, decimal mass) const override; @@ -207,6 +210,11 @@ inline size_t ConcaveMeshShape::getSizeInBytes() const { return sizeof(ConcaveMeshShape); } +// Return the scaling vector +inline const Vector3& ConcaveMeshShape::getScaling() const { + return mScaling; +} + // Return the local bounds of the shape in x, y and z directions. // This method is used to compute the AABB of the box /** @@ -222,18 +230,6 @@ inline void ConcaveMeshShape::getLocalBounds(Vector3& min, Vector3& max) const { max = treeAABB.getMax(); } -// Set the local scaling vector of the collision shape -inline void ConcaveMeshShape::setLocalScaling(const Vector3& scaling) { - - CollisionShape::setLocalScaling(scaling); - - // Reset the Dynamic AABB Tree - mDynamicAABBTree.reset(); - - // Rebuild Dynamic AABB Tree here - initBVHTree(); -} - // Return the local inertia tensor of the shape /** * @param[out] tensor The 3x3 inertia tensor matrix of the shape in local-space diff --git a/src/collision/shapes/ConvexMeshShape.cpp b/src/collision/shapes/ConvexMeshShape.cpp index 1c47b4d9..3dadfee4 100644 --- a/src/collision/shapes/ConvexMeshShape.cpp +++ b/src/collision/shapes/ConvexMeshShape.cpp @@ -38,8 +38,9 @@ using namespace reactphysics3d; * @param stride Stride between the beginning of two elements in the vertices array * @param margin Collision margin (in meters) around the collision shape */ -ConvexMeshShape::ConvexMeshShape(PolyhedronMesh* polyhedronMesh) - : ConvexPolyhedronShape(CollisionShapeName::CONVEX_MESH), mPolyhedronMesh(polyhedronMesh), mMinBounds(0, 0, 0), mMaxBounds(0, 0, 0) { +ConvexMeshShape::ConvexMeshShape(PolyhedronMesh* polyhedronMesh, const Vector3& scaling) + : ConvexPolyhedronShape(CollisionShapeName::CONVEX_MESH), mPolyhedronMesh(polyhedronMesh), + mMinBounds(0, 0, 0), mMaxBounds(0, 0, 0), mScaling(scaling) { // Recalculate the bounds of the mesh recalculateBounds(); diff --git a/src/collision/shapes/ConvexMeshShape.h b/src/collision/shapes/ConvexMeshShape.h index ebec6a09..5ce02b19 100644 --- a/src/collision/shapes/ConvexMeshShape.h +++ b/src/collision/shapes/ConvexMeshShape.h @@ -30,7 +30,7 @@ #include "ConvexPolyhedronShape.h" #include "engine/CollisionWorld.h" #include "mathematics/mathematics.h" -#include "collision/TriangleMesh.h" + #include "collision/PolyhedronMesh.h" #include "collision/narrowphase/GJK/GJKAlgorithm.h" @@ -62,6 +62,9 @@ class ConvexMeshShape : public ConvexPolyhedronShape { /// Mesh maximum bounds in the three local x, y and z directions Vector3 mMaxBounds; + /// Local scaling + const Vector3 mScaling; + // -------------------- Methods -------------------- // /// Recompute the bounds of the mesh @@ -84,7 +87,7 @@ class ConvexMeshShape : public ConvexPolyhedronShape { // -------------------- Methods -------------------- // /// Constructor - ConvexMeshShape(PolyhedronMesh* polyhedronMesh); + ConvexMeshShape(PolyhedronMesh* polyhedronMesh, const Vector3& scaling = Vector3(1,1,1)); /// Destructor virtual ~ConvexMeshShape() override = default; @@ -95,8 +98,8 @@ class ConvexMeshShape : public ConvexPolyhedronShape { /// Deleted assignment operator ConvexMeshShape& operator=(const ConvexMeshShape& shape) = delete; - /// Set the scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; + /// Return the scaling vector + const Vector3& getScaling() const; /// Return the local bounds of the shape in x, y and z directions virtual void getLocalBounds(Vector3& min, Vector3& max) const override; @@ -135,17 +138,16 @@ class ConvexMeshShape : public ConvexPolyhedronShape { virtual std::string to_string() const override; }; -/// Set the scaling vector of the collision shape -inline void ConvexMeshShape::setLocalScaling(const Vector3& scaling) { - ConvexShape::setLocalScaling(scaling); - recalculateBounds(); -} - // Return the number of bytes used by the collision shape inline size_t ConvexMeshShape::getSizeInBytes() const { return sizeof(ConvexMeshShape); } +// Return the scaling vector +inline const Vector3& ConvexMeshShape::getScaling() const { + return mScaling; +} + // Return the local bounds of the shape in x, y and z directions /** * @param min The minimum bounds of the shape in local-space coordinates diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index 0b3a4044..0136c881 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -41,11 +41,11 @@ using namespace reactphysics3d; */ HeightFieldShape::HeightFieldShape(int nbGridColumns, int nbGridRows, decimal minHeight, decimal maxHeight, const void* heightFieldData, HeightDataType dataType, int upAxis, - decimal integerHeightScale) + decimal integerHeightScale, const Vector3& scaling) : ConcaveShape(CollisionShapeName::HEIGHTFIELD), mNbColumns(nbGridColumns), mNbRows(nbGridRows), mWidth(nbGridColumns - 1), mLength(nbGridRows - 1), mMinHeight(minHeight), mMaxHeight(maxHeight), mUpAxis(upAxis), mIntegerHeightScale(integerHeightScale), - mHeightDataType(dataType) { + mHeightDataType(dataType), mScaling(scaling) { assert(nbGridColumns >= 2); assert(nbGridRows >= 2); diff --git a/src/collision/shapes/HeightFieldShape.h b/src/collision/shapes/HeightFieldShape.h index e796e208..8d4574d2 100644 --- a/src/collision/shapes/HeightFieldShape.h +++ b/src/collision/shapes/HeightFieldShape.h @@ -141,6 +141,9 @@ class HeightFieldShape : public ConcaveShape { /// Local AABB of the height field (without scaling) AABB mAABB; + /// Scaling vector + const Vector3 mScaling; + // -------------------- Methods -------------------- // /// Raycast method with feedback information @@ -177,7 +180,8 @@ class HeightFieldShape : public ConcaveShape { /// Constructor HeightFieldShape(int nbGridColumns, int nbGridRows, decimal minHeight, decimal maxHeight, const void* heightFieldData, HeightDataType dataType, - int upAxis = 1, decimal integerHeightScale = 1.0f); + int upAxis = 1, decimal integerHeightScale = 1.0f, + const Vector3& scaling = Vector3(1,1,1)); /// Destructor virtual ~HeightFieldShape() override = default; @@ -188,6 +192,9 @@ class HeightFieldShape : public ConcaveShape { /// Deleted assignment operator HeightFieldShape& operator=(const HeightFieldShape& shape) = delete; + /// Return the scaling factor + const Vector3& getScaling() const; + /// Return the number of rows in the height field int getNbRows() const; @@ -200,9 +207,6 @@ class HeightFieldShape : public ConcaveShape { /// Return the local bounds of the shape in x, y and z directions. virtual void getLocalBounds(Vector3& min, Vector3& max) const override; - /// Set the local scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; - /// Return the local inertia tensor of the collision shape virtual void computeLocalInertiaTensor(Matrix3x3& tensor, decimal mass) const override; @@ -218,6 +222,11 @@ class HeightFieldShape : public ConcaveShape { friend class ConcaveMeshRaycastCallback; }; +// Return the scaling factor +inline const Vector3& HeightFieldShape::getScaling() const { + return mScaling; +} + // Return the number of rows in the height field inline int HeightFieldShape::getNbRows() const { return mNbRows; @@ -238,11 +247,6 @@ inline size_t HeightFieldShape::getSizeInBytes() const { return sizeof(HeightFieldShape); } -// Set the local scaling vector of the collision shape -inline void HeightFieldShape::setLocalScaling(const Vector3& scaling) { - CollisionShape::setLocalScaling(scaling); -} - // Return the height of a given (x,y) point in the height field inline decimal HeightFieldShape::getHeightAt(int x, int y) const { diff --git a/src/collision/shapes/SphereShape.h b/src/collision/shapes/SphereShape.h index a0010b06..01e2001e 100644 --- a/src/collision/shapes/SphereShape.h +++ b/src/collision/shapes/SphereShape.h @@ -82,9 +82,6 @@ class SphereShape : public ConvexShape { /// Return true if the collision shape is a polyhedron virtual bool isPolyhedron() const override; - /// Set the scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; - /// Return the local bounds of the shape in x, y and z directions. virtual void getLocalBounds(Vector3& min, Vector3& max) const override; @@ -111,14 +108,6 @@ inline bool SphereShape::isPolyhedron() const { return false; } -// Set the scaling vector of the collision shape -inline void SphereShape::setLocalScaling(const Vector3& scaling) { - - mMargin = (mMargin / mScaling.x) * scaling.x; - - CollisionShape::setLocalScaling(scaling); -} - // Return the number of bytes used by the collision shape inline size_t SphereShape::getSizeInBytes() const { return sizeof(SphereShape); diff --git a/src/collision/shapes/TriangleShape.h b/src/collision/shapes/TriangleShape.h index 5a5a49b2..23a55c38 100644 --- a/src/collision/shapes/TriangleShape.h +++ b/src/collision/shapes/TriangleShape.h @@ -127,9 +127,6 @@ class TriangleShape : public ConvexPolyhedronShape { /// Return the local bounds of the shape in x, y and z directions. virtual void getLocalBounds(Vector3& min, Vector3& max) const override; - /// Set the local scaling vector of the collision shape - virtual void setLocalScaling(const Vector3& scaling) override; - /// Return the local inertia tensor of the collision shape virtual void computeLocalInertiaTensor(Matrix3x3& tensor, decimal mass) const override; @@ -214,16 +211,6 @@ inline void TriangleShape::getLocalBounds(Vector3& min, Vector3& max) const { max += Vector3(mMargin, mMargin, mMargin); } -// Set the local scaling vector of the collision shape -inline void TriangleShape::setLocalScaling(const Vector3& scaling) { - - mPoints[0] = (mPoints[0] / mScaling) * scaling; - mPoints[1] = (mPoints[1] / mScaling) * scaling; - mPoints[2] = (mPoints[2] / mScaling) * scaling; - - CollisionShape::setLocalScaling(scaling); -} - // Return the local inertia tensor of the triangle shape /** * @param[out] tensor The 3x3 inertia tensor matrix of the shape in local-space diff --git a/test/tests/collision/TestRaycast.h b/test/tests/collision/TestRaycast.h index 7714264a..70397ed0 100644 --- a/test/tests/collision/TestRaycast.h +++ b/test/tests/collision/TestRaycast.h @@ -1303,7 +1303,6 @@ class TestRaycast : public Test { Vector3 point2 = mLocalShapeToWorld * Vector3(1, 2, -4); Ray ray(point1, point2); Vector3 hitPoint = mLocalShapeToWorld * Vector3(1, 2, 4); - Transform inverse = mLocalShapeToWorld.getInverse(); mCallback.shapeToTest = mConvexMeshProxyShape; diff --git a/testbed/common/Box.cpp b/testbed/common/Box.cpp index 508fa516..6d685086 100644 --- a/testbed/common/Box.cpp +++ b/testbed/common/Box.cpp @@ -255,16 +255,3 @@ void Box::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void Box::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z)); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(mSize[0] * scaling.x, 0, 0, 0, - 0, mSize[1] * scaling.y, 0, 0, - 0, 0, mSize[2] * scaling.z, 0, - 0, 0, 0, 1); -} diff --git a/testbed/common/Box.h b/testbed/common/Box.h index 42d234f9..21fe0ed1 100644 --- a/testbed/common/Box.h +++ b/testbed/common/Box.h @@ -88,9 +88,6 @@ class Box : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object diff --git a/testbed/common/Capsule.cpp b/testbed/common/Capsule.cpp index b48baf69..160030b7 100644 --- a/testbed/common/Capsule.cpp +++ b/testbed/common/Capsule.cpp @@ -235,16 +235,3 @@ void Capsule::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void Capsule::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z)); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(mRadius * scaling.x, 0, 0, 0, - 0, (mHeight * scaling.y + 2.0f * mRadius * scaling.x) / 3, 0,0, - 0, 0, mRadius * scaling.x, 0, - 0, 0, 0, 1.0f); -} diff --git a/testbed/common/Capsule.h b/testbed/common/Capsule.h index d0e74436..1591f247 100644 --- a/testbed/common/Capsule.h +++ b/testbed/common/Capsule.h @@ -96,9 +96,6 @@ class Capsule : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object diff --git a/testbed/common/ConcaveMesh.cpp b/testbed/common/ConcaveMesh.cpp index f6b04b9c..553a83ca 100644 --- a/testbed/common/ConcaveMesh.cpp +++ b/testbed/common/ConcaveMesh.cpp @@ -244,17 +244,3 @@ void ConcaveMesh::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void ConcaveMesh::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z)); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0, - 0, scaling.y, 0,0, - 0, 0, scaling.z, 0, - 0, 0, 0, 1.0f); -} - diff --git a/testbed/common/ConcaveMesh.h b/testbed/common/ConcaveMesh.h index 17755352..21d40082 100644 --- a/testbed/common/ConcaveMesh.h +++ b/testbed/common/ConcaveMesh.h @@ -90,9 +90,6 @@ class ConcaveMesh : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object diff --git a/testbed/common/ConvexMesh.cpp b/testbed/common/ConvexMesh.cpp index a59c2f3d..95e41dd1 100644 --- a/testbed/common/ConvexMesh.cpp +++ b/testbed/common/ConvexMesh.cpp @@ -254,16 +254,3 @@ void ConvexMesh::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void ConvexMesh::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z)); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0, - 0, scaling.y, 0, 0, - 0, 0, scaling.z, 0, - 0, 0, 0, 1); -} diff --git a/testbed/common/ConvexMesh.h b/testbed/common/ConvexMesh.h index 865921ca..cc8c1599 100644 --- a/testbed/common/ConvexMesh.h +++ b/testbed/common/ConvexMesh.h @@ -92,9 +92,6 @@ class ConvexMesh : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object diff --git a/testbed/common/Dumbbell.cpp b/testbed/common/Dumbbell.cpp index f90f0cc9..866c35b1 100644 --- a/testbed/common/Dumbbell.cpp +++ b/testbed/common/Dumbbell.cpp @@ -272,30 +272,3 @@ void Dumbbell::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void Dumbbell::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - rp3d::Vector3 newScaling(scaling.x, scaling.y, scaling.z); - mProxyShapeCapsule->setLocalScaling(newScaling); - mProxyShapeSphere1->setLocalScaling(newScaling); - mProxyShapeSphere2->setLocalScaling(newScaling); - - mDistanceBetweenSphere = (mDistanceBetweenSphere / mScalingMatrix.getValue(1, 1)) * scaling.y; - - // Initial transform of the first sphere collision shape of the dumbbell (in local-space) - rp3d::Transform transformSphereShape1(rp3d::Vector3(0, mDistanceBetweenSphere / 2.0f, 0), rp3d::Quaternion::identity()); - - // Initial transform of the second sphere collision shape of the dumbell (in local-space) - rp3d::Transform transformSphereShape2(rp3d::Vector3(0, -mDistanceBetweenSphere / 2.0f, 0), rp3d::Quaternion::identity()); - - mProxyShapeSphere1->setLocalToBodyTransform(transformSphereShape1); - mProxyShapeSphere2->setLocalToBodyTransform(transformSphereShape2); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0, - 0, scaling.y, 0, 0, - 0, 0, scaling.z, 0, - 0, 0, 0, 1); -} diff --git a/testbed/common/Dumbbell.h b/testbed/common/Dumbbell.h index 135beabc..8044e434 100644 --- a/testbed/common/Dumbbell.h +++ b/testbed/common/Dumbbell.h @@ -95,9 +95,6 @@ class Dumbbell : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object diff --git a/testbed/common/HeightField.cpp b/testbed/common/HeightField.cpp index e979936d..b1077fad 100644 --- a/testbed/common/HeightField.cpp +++ b/testbed/common/HeightField.cpp @@ -303,16 +303,3 @@ void HeightField::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void HeightField::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z)); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(scaling.x, 0, 0, 0, - 0, scaling.y, 0,0, - 0, 0, scaling.z, 0, - 0, 0, 0, 1.0f); -} diff --git a/testbed/common/HeightField.h b/testbed/common/HeightField.h index 1ff390ee..e68c8388 100644 --- a/testbed/common/HeightField.h +++ b/testbed/common/HeightField.h @@ -103,9 +103,6 @@ class HeightField : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object diff --git a/testbed/common/PhysicsObject.h b/testbed/common/PhysicsObject.h index e1714048..31e01c4f 100644 --- a/testbed/common/PhysicsObject.h +++ b/testbed/common/PhysicsObject.h @@ -82,9 +82,6 @@ class PhysicsObject : public openglframework::Mesh { /// Return a pointer to the rigid body of the box reactphysics3d::RigidBody* getRigidBody(); - - /// Set the scaling of the object - virtual void setScaling(const openglframework::Vector3& scaling)=0; }; // Set the color of the box diff --git a/testbed/common/Sphere.cpp b/testbed/common/Sphere.cpp index f7c53579..15375e05 100644 --- a/testbed/common/Sphere.cpp +++ b/testbed/common/Sphere.cpp @@ -234,16 +234,3 @@ void Sphere::createVBOAndVAO() { // Unbind the VAO mVAO.unbind(); } - -// Set the scaling of the object -void Sphere::setScaling(const openglframework::Vector3& scaling) { - - // Scale the collision shape - mProxyShape->setLocalScaling(rp3d::Vector3(scaling.x, scaling.y, scaling.z)); - - // Scale the graphics object - mScalingMatrix = openglframework::Matrix4(mRadius * scaling.x, 0, 0, 0, - 0, mRadius * scaling.y, 0, 0, - 0, 0, mRadius * scaling.z, 0, - 0, 0, 0, 1); -} diff --git a/testbed/common/Sphere.h b/testbed/common/Sphere.h index fe2b3f83..e1ba6ed6 100644 --- a/testbed/common/Sphere.h +++ b/testbed/common/Sphere.h @@ -92,9 +92,6 @@ class Sphere : public PhysicsObject { /// Update the transform matrix of the object virtual void updateTransform(float interpolationFactor) override; - - /// Set the scaling of the object - void setScaling(const openglframework::Vector3& scaling) override; }; // Update the transform matrix of the object