Defaulting the joint setup display to ON instead of OFF (#5696)

Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
monroegm-disable-blank-issue-2
amzn-sean 4 years ago committed by GitHub
parent b533a9566a
commit cf540b6f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,6 +11,7 @@
#include <Editor/EditorJointConfiguration.h>
#include <Source/EditorColliderComponent.h>
#include <Source/EditorRigidBodyComponent.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
namespace
{
@ -213,7 +214,7 @@ namespace PhysX
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorJointConfig>()
->Version(4, &EditorJointConfig::VersionConverter)
->Version(5, &EditorJointConfig::VersionConverter)
->Field("Local Position", &EditorJointConfig::m_localPosition)
->Field("Local Rotation", &EditorJointConfig::m_localRotation)
->Field("Parent Entity", &EditorJointConfig::m_leadEntity)
@ -228,6 +229,12 @@ namespace PhysX
if (auto* editContext = serializeContext->GetEditContext())
{
editContext->Enum<EditorJointConfig::DisplaySetupState>("Joint Display Setup State", "Options for displaying joint setup.")
->Value("Never", EditorJointConfig::DisplaySetupState::Never)
->Value("Selected", EditorJointConfig::DisplaySetupState::Selected)
->Value("Always", EditorJointConfig::DisplaySetupState::Always)
;
editContext->Class<PhysX::EditorJointConfig>(
"PhysX Joint Configuration", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
@ -244,8 +251,11 @@ namespace PhysX
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorJointConfig::ValidateLeadEntityId)
->DataElement(0, &PhysX::EditorJointConfig::m_selfCollide, "Lead-Follower Collide"
, "When active, the lead and follower pair will collide with each other.")
->DataElement(0, &PhysX::EditorJointConfig::m_displayJointSetup, "Display Setup in Viewport"
, "Display joint setup in the viewport.")
->DataElement(
AZ::Edit::UIHandlers::ComboBox, &PhysX::EditorJointConfig::m_displayJointSetup, "Display Setup in Viewport"
, "Never = Not shown."
"Select = Show setup display when entity is selected."
"Always = Always show setup display.")
->Attribute(AZ::Edit::Attributes::ReadOnly, &EditorJointConfig::IsInComponentMode)
->DataElement(0, &PhysX::EditorJointConfig::m_selectLeadOnSnap, "Select Lead on Snap"
, "Select lead entity on snap to position in component mode.")
@ -306,6 +316,23 @@ namespace PhysX
m_followerEntity);
}
bool EditorJointConfig::ShowSetupDisplay() const
{
switch(m_displayJointSetup)
{
case DisplaySetupState::Always:
return true;
case DisplaySetupState::Selected:
{
bool showSetup = false;
AzToolsFramework::EditorEntityInfoRequestBus::EventResult(
showSetup, m_followerEntity, &AzToolsFramework::EditorEntityInfoRequests::IsSelected);
return showSetup;
}
}
return false;
}
bool EditorJointConfig::IsInComponentMode() const
{
return m_inComponentMode;
@ -343,6 +370,31 @@ namespace PhysX
}
}
// convert m_displayJointSetup from a bool to the enum with the option Never,Selected,Always show joint setup helpers.
if (classElement.GetVersion() <= 4)
{
// get the current bool setting and remove it.
bool oldSetting = false;
const int displayJointSetupIndex = classElement.FindElement(AZ_CRC_CE("Display Debug"));
if (displayJointSetupIndex >= 0)
{
AZ::SerializeContext::DataElementNode& elementNode = classElement.GetSubElement(displayJointSetupIndex);
elementNode.GetData<bool>(oldSetting);
classElement.RemoveElement(displayJointSetupIndex);
}
//if the old setting was on set it to 'Selected'. otherwise 'Never'
if (oldSetting)
{
classElement.AddElementWithData(context, "Display Debug", EditorJointConfig::DisplaySetupState::Selected);
}
else
{
classElement.AddElementWithData(context, "Display Debug", EditorJointConfig::DisplaySetupState::Never);
}
}
return result;
}

@ -100,12 +100,21 @@ namespace PhysX
AZ_TYPE_INFO(EditorJointConfig, "{8A966D65-CA97-4786-A13C-ACAA519D97EA}");
static void Reflect(AZ::ReflectContext* context);
enum class DisplaySetupState : AZ::u8
{
Never = 0,
Selected,
Always
};
void SetLeadEntityId(AZ::EntityId leadEntityId);
JointGenericProperties ToGenericProperties() const;
JointComponentConfiguration ToGameTimeConfig() const;
bool ShowSetupDisplay() const;
bool m_breakable = false;
bool m_displayJointSetup = false;
DisplaySetupState m_displayJointSetup = DisplaySetupState::Selected;
bool m_inComponentMode = false;
bool m_selectLeadOnSnap = true;
bool m_selfCollide = false;
@ -129,3 +138,8 @@ namespace PhysX
};
} // namespace PhysX
namespace AZ
{
AZ_TYPE_INFO_SPECIALIZE(PhysX::EditorJointConfig::DisplaySetupState, "{17EBE6BD-289A-4326-8A24-DCE3B7FEC51E}");
} // namespace AZ

@ -215,7 +215,7 @@ namespace PhysX
{
EditorJointComponent::DisplayEntityViewport(viewportInfo, debugDisplay);
if (!m_config.m_displayJointSetup &&
if (!m_config.ShowSetupDisplay() &&
!m_config.m_inComponentMode)
{
return;

@ -211,7 +211,7 @@ namespace PhysX
{
EditorJointComponent::DisplayEntityViewport(viewportInfo, debugDisplay);
if (!m_config.m_displayJointSetup &&
if (!m_config.ShowSetupDisplay() &&
!m_config.m_inComponentMode)
{
return;

Loading…
Cancel
Save