Fix joints properties ranges validation
This commit is contained in:
@@ -45,6 +45,7 @@ void D6Joint::SetDrive(const D6JointDriveType index, const D6JointDrive& value)
|
|||||||
drive.stiffness = value.Stiffness;
|
drive.stiffness = value.Stiffness;
|
||||||
drive.damping = value.Damping;
|
drive.damping = value.Damping;
|
||||||
drive.forceLimit = value.ForceLimit;
|
drive.forceLimit = value.ForceLimit;
|
||||||
|
ASSERT_LOW_LAYER(drive.isValid());
|
||||||
joint->setDrive(static_cast<PxD6Drive::Enum>(index), drive);
|
joint->setDrive(static_cast<PxD6Drive::Enum>(index), drive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,11 +60,12 @@ void D6Joint::SetLimitLinear(const LimitLinear& value)
|
|||||||
if (_joint)
|
if (_joint)
|
||||||
{
|
{
|
||||||
auto joint = static_cast<PxD6Joint*>(_joint);
|
auto joint = static_cast<PxD6Joint*>(_joint);
|
||||||
PxJointLinearLimit pxLimit(*Physics::GetTolerancesScale(), value.Extent, value.ContactDist);
|
PxJointLinearLimit limit(*Physics::GetTolerancesScale(), Math::Max(value.Extent, ZeroTolerance), value.ContactDist);
|
||||||
pxLimit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
pxLimit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
pxLimit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
joint->setLinearLimit(pxLimit);
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
|
joint->setLinearLimit(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +79,12 @@ void D6Joint::SetLimitTwist(const LimitAngularRange& value)
|
|||||||
if (_joint)
|
if (_joint)
|
||||||
{
|
{
|
||||||
auto joint = static_cast<PxD6Joint*>(_joint);
|
auto joint = static_cast<PxD6Joint*>(_joint);
|
||||||
PxJointAngularLimitPair pxLimit(value.Lower * DegreesToRadians, value.Upper * DegreesToRadians, value.ContactDist);
|
PxJointAngularLimitPair limit(value.Lower * DegreesToRadians, Math::Max(value.Upper, value.Lower) * DegreesToRadians, value.ContactDist);
|
||||||
pxLimit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
pxLimit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
pxLimit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
joint->setTwistLimit(pxLimit);
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
|
joint->setTwistLimit(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,11 +98,12 @@ void D6Joint::SetLimitSwing(const LimitConeRange& value)
|
|||||||
if (_joint)
|
if (_joint)
|
||||||
{
|
{
|
||||||
auto joint = static_cast<PxD6Joint*>(_joint);
|
auto joint = static_cast<PxD6Joint*>(_joint);
|
||||||
PxJointLimitCone pxLimit(value.YLimitAngle * DegreesToRadians, value.ZLimitAngle * DegreesToRadians, value.ContactDist);
|
PxJointLimitCone limit(Math::Clamp(value.YLimitAngle * DegreesToRadians, ZeroTolerance, PI), Math::Clamp(value.ZLimitAngle * DegreesToRadians, ZeroTolerance, PI), value.ContactDist);
|
||||||
pxLimit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
pxLimit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
pxLimit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
joint->setSwingLimit(pxLimit);
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
|
joint->setSwingLimit(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,34 +432,38 @@ PxJoint* D6Joint::CreateJoint(JointData& data)
|
|||||||
drive.stiffness = value.Stiffness;
|
drive.stiffness = value.Stiffness;
|
||||||
drive.damping = value.Damping;
|
drive.damping = value.Damping;
|
||||||
drive.forceLimit = value.ForceLimit;
|
drive.forceLimit = value.ForceLimit;
|
||||||
|
ASSERT_LOW_LAYER(drive.isValid());
|
||||||
joint->setDrive(static_cast<PxD6Drive::Enum>(i), drive);
|
joint->setDrive(static_cast<PxD6Drive::Enum>(i), drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto& value = _limitLinear;
|
const auto& value = _limitLinear;
|
||||||
PxJointLinearLimit pxLimit(*Physics::GetTolerancesScale(), Math::Max(value.Extent, 0.01f), value.ContactDist);
|
PxJointLinearLimit limit(*Physics::GetTolerancesScale(), Math::Max(value.Extent, ZeroTolerance), value.ContactDist);
|
||||||
pxLimit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
pxLimit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
pxLimit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
joint->setDistanceLimit(pxLimit);
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
|
joint->setDistanceLimit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto& value = _limitTwist;
|
const auto& value = _limitTwist;
|
||||||
PxJointAngularLimitPair pxLimit(value.Lower * DegreesToRadians, value.Upper * DegreesToRadians, value.ContactDist);
|
PxJointAngularLimitPair limit(value.Lower * DegreesToRadians, Math::Max(value.Upper, value.Lower) * DegreesToRadians, value.ContactDist);
|
||||||
pxLimit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
pxLimit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
pxLimit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
joint->setTwistLimit(pxLimit);
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
|
joint->setTwistLimit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto& value = _limitSwing;
|
const auto& value = _limitSwing;
|
||||||
PxJointLimitCone pxLimit(value.YLimitAngle * DegreesToRadians, value.ZLimitAngle * DegreesToRadians, value.ContactDist);
|
PxJointLimitCone limit(Math::Clamp(value.YLimitAngle * DegreesToRadians, ZeroTolerance, PI), Math::Clamp(value.ZLimitAngle * DegreesToRadians, ZeroTolerance, PI), value.ContactDist);
|
||||||
pxLimit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
pxLimit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
pxLimit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
joint->setSwingLimit(pxLimit);
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
|
joint->setSwingLimit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return joint;
|
return joint;
|
||||||
|
|||||||
@@ -38,10 +38,11 @@ void HingeJoint::SetLimit(const LimitAngularRange& value)
|
|||||||
if (_joint)
|
if (_joint)
|
||||||
{
|
{
|
||||||
auto joint = static_cast<PxRevoluteJoint*>(_joint);
|
auto joint = static_cast<PxRevoluteJoint*>(_joint);
|
||||||
PxJointAngularLimitPair limit(value.Lower * DegreesToRadians, value.Upper * DegreesToRadians, value.ContactDist);
|
PxJointAngularLimitPair limit(value.Lower * DegreesToRadians, Math::Max(value.Upper, value.Lower) * DegreesToRadians, value.ContactDist);
|
||||||
limit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
limit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
limit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
joint->setLimit(limit);
|
joint->setLimit(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,10 +163,11 @@ PxJoint* HingeJoint::CreateJoint(JointData& data)
|
|||||||
joint->setDriveVelocity(_drive.Velocity);
|
joint->setDriveVelocity(_drive.Velocity);
|
||||||
joint->setDriveForceLimit(_drive.ForceLimit);
|
joint->setDriveForceLimit(_drive.ForceLimit);
|
||||||
joint->setDriveGearRatio(_drive.GearRatio);
|
joint->setDriveGearRatio(_drive.GearRatio);
|
||||||
PxJointAngularLimitPair limit(_limit.Lower * DegreesToRadians, _limit.Upper * DegreesToRadians, _limit.ContactDist);
|
PxJointAngularLimitPair limit(_limit.Lower * DegreesToRadians, Math::Max(_limit.Upper, _limit.Lower) * DegreesToRadians, _limit.ContactDist);
|
||||||
limit.stiffness = _limit.Spring.Stiffness;
|
limit.stiffness = _limit.Spring.Stiffness;
|
||||||
limit.damping = _limit.Spring.Damping;
|
limit.damping = _limit.Spring.Damping;
|
||||||
limit.restitution = _limit.Restitution;
|
limit.restitution = _limit.Restitution;
|
||||||
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
joint->setLimit(limit);
|
joint->setLimit(limit);
|
||||||
|
|
||||||
return joint;
|
return joint;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ void SliderJoint::SetLimit(const LimitLinearRange& value)
|
|||||||
limit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
limit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
limit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
joint->setLimit(limit);
|
joint->setLimit(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ void SphericalJoint::SetLimit(const LimitConeRange& value)
|
|||||||
if (_joint)
|
if (_joint)
|
||||||
{
|
{
|
||||||
auto joint = static_cast<PxSphericalJoint*>(_joint);
|
auto joint = static_cast<PxSphericalJoint*>(_joint);
|
||||||
PxJointLimitCone limit(value.YLimitAngle * DegreesToRadians, value.ZLimitAngle * DegreesToRadians, value.ContactDist);
|
PxJointLimitCone limit(Math::Clamp(value.YLimitAngle * DegreesToRadians, ZeroTolerance, PI), Math::Clamp(value.ZLimitAngle * DegreesToRadians, ZeroTolerance, PI), value.ContactDist);
|
||||||
limit.stiffness = value.Spring.Stiffness;
|
limit.stiffness = value.Spring.Stiffness;
|
||||||
limit.damping = value.Spring.Damping;
|
limit.damping = value.Spring.Damping;
|
||||||
limit.restitution = value.Restitution;
|
limit.restitution = value.Restitution;
|
||||||
|
ASSERT_LOW_LAYER(limit.isValid());
|
||||||
joint->setLimitCone(limit);
|
joint->setLimitCone(limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +111,7 @@ PxJoint* SphericalJoint::CreateJoint(JointData& data)
|
|||||||
if (_flags & SphericalJointFlag::Limit)
|
if (_flags & SphericalJointFlag::Limit)
|
||||||
flags |= PxSphericalJointFlag::eLIMIT_ENABLED;
|
flags |= PxSphericalJointFlag::eLIMIT_ENABLED;
|
||||||
joint->setSphericalJointFlags(static_cast<PxSphericalJointFlag::Enum>(flags));
|
joint->setSphericalJointFlags(static_cast<PxSphericalJointFlag::Enum>(flags));
|
||||||
PxJointLimitCone limit(_limit.YLimitAngle * DegreesToRadians, _limit.ZLimitAngle * DegreesToRadians, _limit.ContactDist);
|
PxJointLimitCone limit(Math::Clamp(_limit.YLimitAngle * DegreesToRadians, ZeroTolerance, PI), Math::Clamp(_limit.ZLimitAngle * DegreesToRadians, ZeroTolerance, PI), _limit.ContactDist);
|
||||||
limit.stiffness = _limit.Spring.Stiffness;
|
limit.stiffness = _limit.Spring.Stiffness;
|
||||||
limit.damping = _limit.Spring.Damping;
|
limit.damping = _limit.Spring.Damping;
|
||||||
limit.restitution = _limit.Restitution;
|
limit.restitution = _limit.Restitution;
|
||||||
|
|||||||
Reference in New Issue
Block a user