mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
few more tweaks
check for mass first in joltBody so that we set dynamic early
This commit is contained in:
parent
174e4d3329
commit
c81a809444
3 changed files with 12 additions and 11 deletions
|
|
@ -70,16 +70,18 @@ bool JoltBody::init(PhysicsCollision* shape, F32 mass, U32 bodyFlags, SceneObjec
|
||||||
JPH::EMotionType motionType = JPH::EMotionType::Static;
|
JPH::EMotionType motionType = JPH::EMotionType::Static;
|
||||||
JPH::ObjectLayer layer = Layers::NON_MOVING;
|
JPH::ObjectLayer layer = Layers::NON_MOVING;
|
||||||
|
|
||||||
if (bodyFlags & BF_KINEMATIC)
|
if (mass > 0.0f)
|
||||||
{
|
|
||||||
motionType = JPH::EMotionType::Kinematic;
|
|
||||||
layer = Layers::MOVING;
|
|
||||||
}
|
|
||||||
else if (mass > 0.0f)
|
|
||||||
{
|
{
|
||||||
motionType = JPH::EMotionType::Dynamic;
|
motionType = JPH::EMotionType::Dynamic;
|
||||||
layer = Layers::MOVING;
|
layer = Layers::MOVING;
|
||||||
}
|
}
|
||||||
|
else if (bodyFlags & BF_KINEMATIC)
|
||||||
|
{
|
||||||
|
motionType = JPH::EMotionType::Kinematic;
|
||||||
|
layer = Layers::MOVING;
|
||||||
|
}
|
||||||
|
|
||||||
|
mMass = mass;
|
||||||
|
|
||||||
MatrixF objXfm = obj->getTransform();
|
MatrixF objXfm = obj->getTransform();
|
||||||
|
|
||||||
|
|
@ -101,7 +103,6 @@ bool JoltBody::init(PhysicsCollision* shape, F32 mass, U32 bodyFlags, SceneObjec
|
||||||
settings.mOverrideMassProperties = JPH::EOverrideMassProperties::CalculateInertia;
|
settings.mOverrideMassProperties = JPH::EOverrideMassProperties::CalculateInertia;
|
||||||
settings.mMassPropertiesOverride.mMass = mass;
|
settings.mMassPropertiesOverride.mMass = mass;
|
||||||
settings.mMaxLinearVelocity = 1000.0f; // stops an assert, this is torques upper limit, jolts is 500.0f by default.
|
settings.mMaxLinearVelocity = 1000.0f; // stops an assert, this is torques upper limit, jolts is 500.0f by default.
|
||||||
mMass = mass; // FIX: was never stored, getMass() always returned 0
|
|
||||||
mIsDynamic = true;
|
mIsDynamic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ void JoltCollision::addPlane(const PlaneF& plane)
|
||||||
void JoltCollision::addBox(const Point3F& halfWidth, const MatrixF& localXfm)
|
void JoltCollision::addBox(const Point3F& halfWidth, const MatrixF& localXfm)
|
||||||
{
|
{
|
||||||
JPH::BoxShapeSettings boxSettings(JPH::Vec3(halfWidth.x, halfWidth.y, halfWidth.z));
|
JPH::BoxShapeSettings boxSettings(JPH::Vec3(halfWidth.x, halfWidth.y, halfWidth.z));
|
||||||
|
boxSettings.mConvexRadius = 0.01f;
|
||||||
|
|
||||||
auto result = boxSettings.Create();
|
auto result = boxSettings.Create();
|
||||||
if (result.HasError())
|
if (result.HasError())
|
||||||
|
|
@ -329,6 +330,9 @@ bool JoltCollision::addHeightfield(
|
||||||
|
|
||||||
void JoltCollision::rebuildCompound()
|
void JoltCollision::rebuildCompound()
|
||||||
{
|
{
|
||||||
|
// clear
|
||||||
|
mCompundShape = nullptr;
|
||||||
|
|
||||||
if (mChildren.empty())
|
if (mChildren.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,6 @@ public:
|
||||||
|
|
||||||
Point3F move(const VectorF& displacement, CollisionList& outCol) override;
|
Point3F move(const VectorF& displacement, CollisionList& outCol) override;
|
||||||
|
|
||||||
bool _recoverFromPenetration(JPH::RVec3& inOutPos);
|
|
||||||
bool _sweep(JPH::RVec3& inOutPos, const JPH::Vec3& disp, CollisionList* outCol);
|
|
||||||
void _stepForward(JPH::RVec3& inOutPos, const JPH::Vec3& displacement, CollisionList* outCol);
|
|
||||||
|
|
||||||
void findContact(SceneObject** contactObject, VectorF* contactNormal, Vector<SceneObject*>* outOverlapObjects) const override;
|
void findContact(SceneObject** contactObject, VectorF* contactNormal, Vector<SceneObject*>* outOverlapObjects) const override;
|
||||||
bool testSpacials(const Point3F& nPos, const Point3F& nSize) const override;
|
bool testSpacials(const Point3F& nPos, const Point3F& nSize) const override;
|
||||||
void setSpacials(const Point3F& nPos, const Point3F& nSize) override;
|
void setSpacials(const Point3F& nPos, const Point3F& nSize) override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue