add version converter for editor transform to handle migration to uniform scale
This commit is contained in:
+22
-2
@@ -170,6 +170,23 @@ namespace AzToolsFramework
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditorTransformDataConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
|
||||||
|
{
|
||||||
|
if (classElement.GetVersion() < 3)
|
||||||
|
{
|
||||||
|
// version 3 replaces vector scale with uniform scale but does not yet delete the legacy scale data
|
||||||
|
// in order to allow for migration
|
||||||
|
AZ::Vector3 vectorScale;
|
||||||
|
if (classElement.FindSubElementAndGetData<AZ::Vector3>(AZ_CRC_CE("Scale"), vectorScale))
|
||||||
|
{
|
||||||
|
const float uniformScale = vectorScale.GetMaxElement();
|
||||||
|
classElement.AddElementWithData(context, "UniformScale", uniformScale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
TransformComponent::TransformComponent()
|
TransformComponent::TransformComponent()
|
||||||
@@ -1123,6 +1140,8 @@ namespace AzToolsFramework
|
|||||||
return AZ::Edit::PropertyRefreshLevels::EntireTree;
|
return AZ::Edit::PropertyRefreshLevels::EntireTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TransformComponent::Reflect(AZ::ReflectContext* context)
|
void TransformComponent::Reflect(AZ::ReflectContext* context)
|
||||||
{
|
{
|
||||||
// reflect data for script, serialization, editing..
|
// reflect data for script, serialization, editing..
|
||||||
@@ -1133,7 +1152,8 @@ namespace AzToolsFramework
|
|||||||
Field("Rotate", &EditorTransform::m_rotate)->
|
Field("Rotate", &EditorTransform::m_rotate)->
|
||||||
Field("Scale", &EditorTransform::m_scale)->
|
Field("Scale", &EditorTransform::m_scale)->
|
||||||
Field("Locked", &EditorTransform::m_locked)->
|
Field("Locked", &EditorTransform::m_locked)->
|
||||||
Version(2);
|
Field("UniformScale", &EditorTransform::m_uniformScale)->
|
||||||
|
Version(3, &Internal::EditorTransformDataConverter);
|
||||||
|
|
||||||
serializeContext->Class<Components::TransformComponent, EditorComponentBase>()->
|
serializeContext->Class<Components::TransformComponent, EditorComponentBase>()->
|
||||||
Field("Parent Entity", &TransformComponent::m_parentEntityId)->
|
Field("Parent Entity", &TransformComponent::m_parentEntityId)->
|
||||||
@@ -1192,7 +1212,7 @@ namespace AzToolsFramework
|
|||||||
Attribute(AZ::Edit::Attributes::Suffix, " deg")->
|
Attribute(AZ::Edit::Attributes::Suffix, " deg")->
|
||||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
||||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
||||||
DataElement(TransformScaleHandler, &EditorTransform::m_scale, "Scale", "Local Scale")->
|
DataElement(AZ::Edit::UIHandlers::Default, &EditorTransform::m_uniformScale, "Uniform Scale", "Local Uniform Scale")->
|
||||||
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
|
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
|
||||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)
|
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)
|
||||||
;
|
;
|
||||||
|
|||||||
+1
@@ -42,6 +42,7 @@ namespace AzToolsFramework
|
|||||||
|
|
||||||
AZ::Vector3 m_translate; //! Translation in engine units (meters)
|
AZ::Vector3 m_translate; //! Translation in engine units (meters)
|
||||||
AZ::Vector3 m_scale;
|
AZ::Vector3 m_scale;
|
||||||
|
float m_uniformScale;
|
||||||
AZ::Vector3 m_rotate; //! Rotation in degrees
|
AZ::Vector3 m_rotate; //! Rotation in degrees
|
||||||
bool m_locked;
|
bool m_locked;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user