Add EnableAutoAnchor to Joint for automatic target anchor setup

This commit is contained in:
Wojtek Figat
2021-11-04 12:17:08 +01:00
parent a45ecf7ec3
commit f303b1c061
2 changed files with 39 additions and 11 deletions

View File

@@ -26,7 +26,8 @@ protected:
float _breakTorque;
Vector3 _targetAnchor;
Quaternion _targetAnchorRotation;
bool _enableCollision;
bool _enableCollision = true;
bool _enableAutoAnchor = false;
public:
@@ -78,13 +79,24 @@ public:
/// </summary>
API_PROPERTY() void SetEnableCollision(bool value);
/// <summary>
/// Determines whether use automatic target anchor position and rotation based on the joint world-space frame (computed when creating joint).
/// </summary>
API_PROPERTY(Attributes="EditorOrder(39), DefaultValue(false), EditorDisplay(\"Joint\")")
bool GetEnableAutoAnchor() const;
/// <summary>
/// Determines whether use automatic target anchor position and rotation based on the joint world-space frame (computed when creating joint).
/// </summary>
API_PROPERTY() void SetEnableAutoAnchor(bool value);
/// <summary>
/// Gets the target anchor.
/// </summary>
/// <remarks>
/// This is the relative pose which locates the joint frame relative to the target actor.
/// </remarks>
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(typeof(Vector3), \"0,0,0\"), EditorDisplay(\"Joint\")")
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(typeof(Vector3), \"0,0,0\"), EditorDisplay(\"Joint\"), VisibleIf(nameof(EnableAutoAnchor), true)")
FORCE_INLINE Vector3 GetTargetAnchor() const
{
return _targetAnchor;
@@ -104,7 +116,7 @@ public:
/// <remarks>
/// This is the relative pose rotation which locates the joint frame relative to the target actor.
/// </remarks>
API_PROPERTY(Attributes="EditorOrder(50), DefaultValue(typeof(Quaternion), \"0,0,0,1\"), EditorDisplay(\"Joint\")")
API_PROPERTY(Attributes="EditorOrder(50), DefaultValue(typeof(Quaternion), \"0,0,0,1\"), EditorDisplay(\"Joint\"), VisibleIf(nameof(EnableAutoAnchor), true)")
FORCE_INLINE Quaternion GetTargetAnchorRotation() const
{
return _targetAnchorRotation;