Skip to content

Commit

Permalink
Fixed #283: Some remaining joint improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jankrassnigg committed Jul 21, 2020
1 parent a863756 commit 84ef0d4
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ EZ_BEGIN_COMPONENT_TYPE(ezPxDynamicActorComponent, 3, ezComponentMode::Dynamic)
EZ_MEMBER_PROPERTY("Density", m_fDensity)->AddAttributes(new ezDefaultValueAttribute(100.0f), new ezSuffixAttribute(" kg/m^3")),
EZ_ACCESSOR_PROPERTY("DisableGravity", GetDisableGravity, SetDisableGravity),
EZ_MEMBER_PROPERTY("LinearDamping", m_fLinearDamping)->AddAttributes(new ezDefaultValueAttribute(0.2f)),
EZ_MEMBER_PROPERTY("AngularDamping", m_fAngularDamping)->AddAttributes(new ezDefaultValueAttribute(0.2f)),
EZ_MEMBER_PROPERTY("AngularDamping", m_fAngularDamping)->AddAttributes(new ezDefaultValueAttribute(1.0f)),
EZ_MEMBER_PROPERTY("MaxContactImpulse", m_fMaxContactImpulse)->AddAttributes(new ezDefaultValueAttribute(100000.0f), new ezClampValueAttribute(0.0f, ezVariant())),
EZ_ACCESSOR_PROPERTY("ContinuousCollisionDetection", GetContinuousCollisionDetection, SetContinuousCollisionDetection)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ EZ_BEGIN_COMPONENT_TYPE(ezPx6DOFJointComponent, 2, ezComponentMode::Static)
{
EZ_BEGIN_PROPERTIES
{
EZ_BITFLAGS_MEMBER_PROPERTY("FreeLinearAxis", ezPxAxis, m_FreeLinearAxis),
EZ_BITFLAGS_ACCESSOR_PROPERTY("FreeLinearAxis", ezPxAxis, GetFreeLinearAxis, SetFreeLinearAxis),
EZ_ENUM_ACCESSOR_PROPERTY("LinearLimitMode", ezPxJointLimitMode, GetLinearLimitMode, SetLinearLimitMode),
EZ_ACCESSOR_PROPERTY("LinearRangeX", GetLinearRangeX, SetLinearRangeX),
EZ_ACCESSOR_PROPERTY("LinearRangeY", GetLinearRangeY, SetLinearRangeY),
EZ_ACCESSOR_PROPERTY("LinearRangeZ", GetLinearRangeZ, SetLinearRangeZ),
EZ_ACCESSOR_PROPERTY("LinearStiffness", GetLinearStiffness, SetLinearStiffness)->AddAttributes(new ezClampValueAttribute(0.0f, ezVariant())),
EZ_ACCESSOR_PROPERTY("LinearDamping", GetLinearDamping, SetLinearDamping)->AddAttributes(new ezClampValueAttribute(0.0f, ezVariant())),
EZ_BITFLAGS_MEMBER_PROPERTY("FreeAngularAxis", ezPxAxis, m_FreeAngularAxis),
EZ_BITFLAGS_ACCESSOR_PROPERTY("FreeAngularAxis", ezPxAxis, GetFreeAngularAxis, SetFreeAngularAxis),
EZ_ENUM_ACCESSOR_PROPERTY("SwingLimitMode", ezPxJointLimitMode, GetSwingLimitMode, SetSwingLimitMode),
EZ_ACCESSOR_PROPERTY("SwingLimit", GetSwingLimit, SetSwingLimit)->AddAttributes(new ezClampValueAttribute(ezAngle(), ezAngle::Degree(175))),
EZ_ACCESSOR_PROPERTY("SwingStiffness", GetSwingStiffness, SetSwingStiffness)->AddAttributes(new ezClampValueAttribute(0.0f, ezVariant())),
Expand All @@ -39,7 +39,7 @@ EZ_BEGIN_COMPONENT_TYPE(ezPx6DOFJointComponent, 2, ezComponentMode::Static)
EZ_END_PROPERTIES;
EZ_BEGIN_ATTRIBUTES
{
new ezDirectionVisualizerAttribute(ezBasisAxis::PositiveX, 0.2, ezColor::LightSkyBlue)
new ezDirectionVisualizerAttribute(ezBasisAxis::PositiveX, 0.2, ezColor::SlateGray)
}
EZ_END_ATTRIBUTES;
}
Expand Down Expand Up @@ -283,6 +283,18 @@ void ezPx6DOFJointComponent::ApplySettings()
//pJoint->setDrive(PxD6Drive::eSLERP, PxD6JointDrive(m_fAngularStiffness, m_fAngularDamping, PX_MAX_F32, true));
}

void ezPx6DOFJointComponent::SetFreeLinearAxis(ezBitflags<ezPxAxis> flags)
{
m_FreeLinearAxis = flags;
QueueApplySettings();
}

void ezPx6DOFJointComponent::SetFreeAngularAxis(ezBitflags<ezPxAxis> flags)
{
m_FreeAngularAxis = flags;
QueueApplySettings();
}

void ezPx6DOFJointComponent::SetLinearLimitMode(ezPxJointLimitMode::Enum mode)
{
m_LinearLimitMode = mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ EZ_BEGIN_COMPONENT_TYPE(ezPxDistanceJointComponent, 1, ezComponentMode::Static)
{
EZ_BEGIN_PROPERTIES
{
EZ_MEMBER_PROPERTY("MinDistance", m_fMinDistance),
EZ_MEMBER_PROPERTY("MaxDistance", m_fMaxDistance)->AddAttributes(new ezDefaultValueAttribute(1.0f)),
EZ_MEMBER_PROPERTY("SpringStiffness", m_fSpringStiffness),
EZ_MEMBER_PROPERTY("SpringDamping", m_fSpringDamping)->AddAttributes(new ezDefaultValueAttribute(1.0f)),
EZ_MEMBER_PROPERTY("SpringTolerance", m_fSpringTolerance)->AddAttributes(new ezDefaultValueAttribute(0.05f)),
EZ_ACCESSOR_PROPERTY("MinDistance", GetMinDistance, SetMinDistance),
EZ_ACCESSOR_PROPERTY("MaxDistance", GetMaxDistance, SetMaxDistance)->AddAttributes(new ezDefaultValueAttribute(1.0f)),
EZ_ACCESSOR_PROPERTY("SpringStiffness", GetSpringStiffness, SetSpringStiffness),
EZ_ACCESSOR_PROPERTY("SpringDamping", GetSpringDamping, SetSpringDamping)->AddAttributes(new ezDefaultValueAttribute(1.0f)),
EZ_ACCESSOR_PROPERTY("SpringTolerance", GetSpringTolerance, SetSpringTolerance)->AddAttributes(new ezDefaultValueAttribute(0.05f)),
}
EZ_END_PROPERTIES;
EZ_BEGIN_ATTRIBUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ EZ_BEGIN_COMPONENT_TYPE(ezPxRevoluteJointComponent, 5, ezComponentMode::Static)
EZ_END_PROPERTIES;
EZ_BEGIN_ATTRIBUTES
{
new ezDirectionVisualizerAttribute(ezBasisAxis::PositiveX, 0.2, ezColor::LightSkyBlue)
new ezDirectionVisualizerAttribute(ezBasisAxis::PositiveX, 0.2, ezColor::SlateGray)
}
EZ_END_ATTRIBUTES;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EZ_BEGIN_COMPONENT_TYPE(ezPxSphericalJointComponent, 2, ezComponentMode::Static)
EZ_END_PROPERTIES;
EZ_BEGIN_ATTRIBUTES
{
new ezDirectionVisualizerAttribute(ezBasisAxis::PositiveX, 0.2, ezColor::LightSkyBlue)
new ezDirectionVisualizerAttribute(ezBasisAxis::PositiveX, 0.2, ezColor::SlateGray)
}
EZ_END_ATTRIBUTES;
}
Expand Down
13 changes: 10 additions & 3 deletions Code/EnginePlugins/PhysXPlugin/Joints/Px6DOFJointComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ class EZ_PHYSXPLUGIN_DLL ezPx6DOFJointComponent : public ezPxJointComponent
ezPx6DOFJointComponent();
~ezPx6DOFJointComponent();

ezBitflags<ezPxAxis> m_FreeLinearAxis; // [ property ]
ezBitflags<ezPxAxis> m_FreeAngularAxis; // [ property ]

virtual void ApplySettings() final override;

void SetFreeLinearAxis(ezBitflags<ezPxAxis> flags); // [ property ]
ezBitflags<ezPxAxis> GetFreeLinearAxis() const { return m_FreeLinearAxis; } // [ property ]

void SetFreeAngularAxis(ezBitflags<ezPxAxis> flags); // [ property ]
ezBitflags<ezPxAxis> GetFreeAngularAxis() const { return m_FreeAngularAxis; } // [ property ]

void SetLinearLimitMode(ezPxJointLimitMode::Enum mode); // [ property ]
ezPxJointLimitMode::Enum GetLinearLimitMode() const { return m_LinearLimitMode; } // [ property ]

Expand Down Expand Up @@ -104,6 +107,8 @@ class EZ_PHYSXPLUGIN_DLL ezPx6DOFJointComponent : public ezPxJointComponent
float GetTwistDamping() const { return m_fTwistDamping; } // [ property ]

protected:
ezBitflags<ezPxAxis> m_FreeLinearAxis;

ezEnum<ezPxJointLimitMode> m_LinearLimitMode;

float m_fLinearStiffness = 0.0f;
Expand All @@ -113,6 +118,8 @@ class EZ_PHYSXPLUGIN_DLL ezPx6DOFJointComponent : public ezPxJointComponent
ezVec2 m_vLinearRangeY = ezVec2::ZeroVector();
ezVec2 m_vLinearRangeZ = ezVec2::ZeroVector();

ezBitflags<ezPxAxis> m_FreeAngularAxis;

ezEnum<ezPxJointLimitMode> m_SwingLimitMode;
ezAngle m_SwingLimit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ class EZ_PHYSXPLUGIN_DLL ezPxRevoluteJointComponent : public ezPxJointComponent
float m_fSpringStiffness = 0;
float m_fSpringDamping = 0;
ezEnum<ezPxJointDriveMode> m_DriveMode;
float m_fDriveVelocity = 0; // [ property ]
float m_fMaxDriveTorque = 100; // [ property ]
float m_fDriveVelocity = 0;
float m_fMaxDriveTorque = 100;
};

0 comments on commit 84ef0d4

Please sign in to comment.