Remove setLocalScaling() method from CollisionShape and ProxyShape and use scaling only for HeightFieldShape, ConvexMeshShape and ConcaveMeshShape
This commit is contained in:
parent
1bc50de2c9
commit
71bfa6afce
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user