first pass of changing transform to use float for scale internally rather than Vector3
This commit is contained in:
@@ -82,9 +82,7 @@ namespace AzToolsFramework
|
||||
|
||||
m_uniformScaleManipulator->SetVisualOrientationOverride(
|
||||
QuaternionFromTransformNoScaling(localTransform));
|
||||
m_uniformScaleManipulator->SetLocalTransform(
|
||||
AZ::Transform::CreateTranslation(localTransform.GetTranslation()) *
|
||||
AZ::Transform::CreateScale(localTransform.GetScale()));
|
||||
m_uniformScaleManipulator->SetLocalOrientation(AZ::Quaternion::CreateIdentity());
|
||||
}
|
||||
|
||||
void ScaleManipulators::SetLocalPositionImpl(const AZ::Vector3& localPosition)
|
||||
|
||||
@@ -1475,10 +1475,8 @@ namespace AzToolsFramework
|
||||
// to avoid pushing them to the slice.
|
||||
// Only scale is preserved on the root entity of a slice.
|
||||
transformComponent->SetParent(AZ::EntityId());
|
||||
AZ::Vector3 scale = transformComponent->GetLocalScale();
|
||||
transformComponent->SetWorldTranslation(AZ::Vector3::CreateZero());
|
||||
transformComponent->SetLocalRotation(AZ::Vector3::CreateZero());
|
||||
transformComponent->SetLocalScale(scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-13
@@ -46,9 +46,9 @@ namespace AzToolsFramework
|
||||
const AZ::u32 ParentEntityCRC = AZ_CRC("Parent Entity", 0x5b1b276c);
|
||||
|
||||
// Decompose a transform into euler angles in degrees, scale (along basis, any shear will be dropped), and translation.
|
||||
void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, AZ::Vector3& scale)
|
||||
void DecomposeTransform(const AZ::Transform& transform, AZ::Vector3& translation, AZ::Vector3& rotation, float& scale)
|
||||
{
|
||||
scale = transform.GetScale();
|
||||
scale = transform.GetUniformScale();
|
||||
translation = transform.GetTranslation();
|
||||
rotation = transform.GetRotation().GetEulerDegrees();
|
||||
}
|
||||
@@ -323,7 +323,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Transform TransformComponent::GetLocalScaleTM() const
|
||||
{
|
||||
return AZ::Transform::CreateScale(m_editorTransform.m_scale);
|
||||
return AZ::Transform::CreateUniformScale(m_editorTransform.m_scale);
|
||||
}
|
||||
|
||||
const AZ::Transform& TransformComponent::GetLocalTM()
|
||||
@@ -340,7 +340,8 @@ namespace AzToolsFramework
|
||||
// given a local transform, update local transform.
|
||||
void TransformComponent::SetLocalTM(const AZ::Transform& finalTx)
|
||||
{
|
||||
AZ::Vector3 tx, rot, scale;
|
||||
AZ::Vector3 tx, rot;
|
||||
float scale;
|
||||
Internal::DecomposeTransform(finalTx, tx, rot, scale);
|
||||
|
||||
m_editorTransform.m_translate = tx;
|
||||
@@ -645,13 +646,13 @@ namespace AzToolsFramework
|
||||
|
||||
void TransformComponent::SetLocalScale(const AZ::Vector3& scale)
|
||||
{
|
||||
m_editorTransform.m_scale = scale;
|
||||
m_editorTransform.m_scale = scale.GetMaxElement();
|
||||
TransformChanged();
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetLocalScale()
|
||||
{
|
||||
return m_editorTransform.m_scale;
|
||||
return AZ::Vector3(m_editorTransform.m_scale);
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformComponent::GetWorldScale()
|
||||
@@ -659,6 +660,22 @@ namespace AzToolsFramework
|
||||
return GetWorldTM().GetScale();
|
||||
}
|
||||
|
||||
void TransformComponent::SetLocalUniformScale(float scale)
|
||||
{
|
||||
m_editorTransform.m_scale = scale;
|
||||
TransformChanged();
|
||||
}
|
||||
|
||||
float TransformComponent::GetLocalUniformScale()
|
||||
{
|
||||
return m_editorTransform.m_scale;
|
||||
}
|
||||
|
||||
float TransformComponent::GetWorldUniformScale()
|
||||
{
|
||||
return GetWorldTM().GetUniformScale();
|
||||
}
|
||||
|
||||
const AZ::Transform& TransformComponent::GetParentWorldTM() const
|
||||
{
|
||||
auto parent = GetParentTransformComponent();
|
||||
@@ -1062,12 +1079,6 @@ namespace AzToolsFramework
|
||||
ModifyEditorTransform(m_editorTransform.m_rotate, data, parent);
|
||||
}
|
||||
|
||||
void TransformComponent::ScaleBy(const AZ::Vector3& data)
|
||||
{
|
||||
//scale is always local
|
||||
ModifyEditorTransform(m_editorTransform.m_scale, data, AZ::Transform::Identity());
|
||||
}
|
||||
|
||||
AZ::EntityId TransformComponent::GetSliceEntityParentId()
|
||||
{
|
||||
return GetParentId();
|
||||
@@ -1214,7 +1225,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
AzToolsFramework::ScopedUndoBatch undo("Reset transform values");
|
||||
m_editorTransform.m_translate = AZ::Vector3::CreateZero();
|
||||
m_editorTransform.m_scale = AZ::Vector3::CreateOne();
|
||||
m_editorTransform.m_scale = 1.0f;
|
||||
m_editorTransform.m_rotate = AZ::Vector3::CreateZero();
|
||||
OnTransformChanged();
|
||||
SetDirty();
|
||||
|
||||
+4
-2
@@ -130,10 +130,13 @@ namespace AzToolsFramework
|
||||
|
||||
// Scale Modifiers
|
||||
void SetLocalScale(const AZ::Vector3& scale) override;
|
||||
|
||||
AZ::Vector3 GetLocalScale() override;
|
||||
AZ::Vector3 GetWorldScale() override;
|
||||
|
||||
void SetLocalUniformScale(float scale) override;
|
||||
float GetLocalUniformScale() override;
|
||||
float GetWorldUniformScale() override;
|
||||
|
||||
AZ::EntityId GetParentId() override;
|
||||
AZ::TransformInterface* GetParent() override;
|
||||
void SetParent(AZ::EntityId parentId) override;
|
||||
@@ -147,7 +150,6 @@ namespace AzToolsFramework
|
||||
// TransformComponentMessages::Bus
|
||||
void TranslateBy(const AZ::Vector3&) override;
|
||||
void RotateBy(const AZ::Vector3&) override; // euler in degrees
|
||||
void ScaleBy(const AZ::Vector3&) override;
|
||||
const EditorTransform& GetLocalEditorTransform() override;
|
||||
void SetLocalEditorTransform(const EditorTransform& dest) override;
|
||||
bool IsTransformLocked() override;
|
||||
|
||||
+2
-3
@@ -30,7 +30,7 @@ namespace AzToolsFramework
|
||||
EditorTransform()
|
||||
{
|
||||
m_translate = AZ::Vector3::CreateZero();
|
||||
m_scale = AZ::Vector3::CreateOne();
|
||||
m_scale = 1.0f;
|
||||
m_rotate = AZ::Vector3::CreateZero();
|
||||
m_locked = false;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
AZ::Vector3 m_translate; //! Translation in engine units (meters)
|
||||
AZ::Vector3 m_scale;
|
||||
float m_scale;
|
||||
AZ::Vector3 m_rotate; //! Rotation in degrees
|
||||
bool m_locked;
|
||||
};
|
||||
@@ -65,7 +65,6 @@ namespace AzToolsFramework
|
||||
|
||||
virtual void TranslateBy(const AZ::Vector3&) = 0;
|
||||
virtual void RotateBy(const AZ::Vector3&) = 0;
|
||||
virtual void ScaleBy(const AZ::Vector3&) = 0;
|
||||
|
||||
virtual bool IsTransformLocked() = 0;
|
||||
};
|
||||
|
||||
+18
-19
@@ -1472,7 +1472,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
const AZ::Quaternion rotation = entityIdLookupIt->second.m_initial.GetRotation().GetNormalized();
|
||||
const AZ::Vector3 position = entityIdLookupIt->second.m_initial.GetTranslation();
|
||||
const AZ::Vector3 scale = entityIdLookupIt->second.m_initial.GetScale();
|
||||
const float scale = entityIdLookupIt->second.m_initial.GetUniformScale();
|
||||
|
||||
const AZ::Vector3 centerOffset = CalculateCenterOffset(entityId, m_pivotMode);
|
||||
|
||||
@@ -1483,7 +1483,7 @@ namespace AzToolsFramework
|
||||
AZ::Transform::CreateFromQuaternion(rotation) *
|
||||
AZ::Transform::CreateTranslation(centerOffset) * offsetRotation *
|
||||
AZ::Transform::CreateTranslation(-centerOffset) *
|
||||
AZ::Transform::CreateScale(scale));
|
||||
AZ::Transform::CreateUniformScale(scale));
|
||||
}
|
||||
break;
|
||||
case ReferenceFrame::Parent:
|
||||
@@ -1595,16 +1595,15 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
const AZ::Transform initial = entityIdLookupIt->second.m_initial;
|
||||
const AZ::Vector3 initialScale = initial.GetScale();
|
||||
const float initialScale = initial.GetUniformScale();
|
||||
|
||||
const auto sumVectorElements = [](const AZ::Vector3& vec) {
|
||||
return vec.GetX() + vec.GetY() + vec.GetZ();
|
||||
};
|
||||
|
||||
const AZ::Vector3 uniformScale = AZ::Vector3(action.m_start.m_sign * sumVectorElements(action.LocalScaleOffset()));
|
||||
const AZ::Vector3 scale = (AZ::Vector3::CreateOne() +
|
||||
(uniformScale / initialScale)).GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
|
||||
const AZ::Transform scaleTransform = AZ::Transform::CreateScale(scale);
|
||||
const float uniformScale = action.m_start.m_sign * sumVectorElements(action.LocalScaleOffset());
|
||||
const float scale = AZ::GetClamp(1.0f + uniformScale / initialScale, AZ::MinTransformScale, AZ::MaxTransformScale);
|
||||
const AZ::Transform scaleTransform = AZ::Transform::CreateUniformScale(scale);
|
||||
|
||||
if (action.m_modifiers.Alt())
|
||||
{
|
||||
@@ -1866,7 +1865,7 @@ namespace AzToolsFramework
|
||||
CopyOrientationToSelectedEntitiesGroup(QuaternionFromTransformNoScaling(worldFromLocal));
|
||||
break;
|
||||
case Mode::Scale:
|
||||
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetScale());
|
||||
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetUniformScale());
|
||||
break;
|
||||
case Mode::Translation:
|
||||
CopyTranslationToSelectedEntitiesGroup(worldFromLocal.GetTranslation());
|
||||
@@ -1895,7 +1894,7 @@ namespace AzToolsFramework
|
||||
CopyOrientationToSelectedEntitiesIndividual(QuaternionFromTransformNoScaling(worldFromLocal));
|
||||
break;
|
||||
case Mode::Scale:
|
||||
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetScale());
|
||||
CopyScaleToSelectedEntitiesIndividualWorld(worldFromLocal.GetUniformScale());
|
||||
break;
|
||||
case Mode::Translation:
|
||||
CopyTranslationToSelectedEntitiesIndividual(worldFromLocal.GetTranslation());
|
||||
@@ -2388,7 +2387,7 @@ namespace AzToolsFramework
|
||||
ResetOrientationForSelectedEntitiesLocal();
|
||||
break;
|
||||
case Mode::Scale:
|
||||
CopyScaleToSelectedEntitiesIndividualLocal(AZ::Vector3::CreateOne());
|
||||
CopyScaleToSelectedEntitiesIndividualLocal(1.0f);
|
||||
break;
|
||||
case Mode::Translation:
|
||||
ResetTranslationForSelectedEntitiesLocal();
|
||||
@@ -2414,7 +2413,7 @@ namespace AzToolsFramework
|
||||
ResetOrientationForSelectedEntitiesLocal();
|
||||
break;
|
||||
case Mode::Scale:
|
||||
CopyScaleToSelectedEntitiesIndividualWorld(AZ::Vector3::CreateOne());
|
||||
CopyScaleToSelectedEntitiesIndividualWorld(1.0f);
|
||||
break;
|
||||
case Mode::Translation:
|
||||
// do nothing
|
||||
@@ -2934,7 +2933,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualWorld(const AZ::Vector3& scale)
|
||||
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualWorld(float scale)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
@@ -2949,7 +2948,7 @@ namespace AzToolsFramework
|
||||
const auto transformsBefore = RecordTransformsBefore(manipulatorEntityIds.m_entityIds);
|
||||
|
||||
// update scale relative to initial
|
||||
const AZ::Transform scaleTransform = AZ::Transform::CreateScale(scale);
|
||||
const AZ::Transform scaleTransform = AZ::Transform::CreateUniformScale(scale);
|
||||
for (AZ::EntityId entityId : manipulatorEntityIds.m_entityIds)
|
||||
{
|
||||
ScopedUndoBatch::MarkEntityDirty(entityId);
|
||||
@@ -2968,7 +2967,7 @@ namespace AzToolsFramework
|
||||
RefreshUiAfterChange(manipulatorEntityIds.m_entityIds);
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualLocal(const AZ::Vector3& scale)
|
||||
void EditorTransformComponentSelection::CopyScaleToSelectedEntitiesIndividualLocal(float scale)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
|
||||
|
||||
@@ -3014,9 +3013,9 @@ namespace AzToolsFramework
|
||||
if (transformIt != transformsBefore.end())
|
||||
{
|
||||
AZ::Transform newWorldFromLocal = transformIt->second;
|
||||
const AZ::Vector3 scale = newWorldFromLocal.GetScale();
|
||||
const float scale = newWorldFromLocal.GetUniformScale();
|
||||
newWorldFromLocal.SetRotation(orientation);
|
||||
newWorldFromLocal *= AZ::Transform::CreateScale(scale);
|
||||
newWorldFromLocal *= AZ::Transform::CreateUniformScale(scale);
|
||||
|
||||
SetEntityWorldTransform(entityId, newWorldFromLocal);
|
||||
}
|
||||
@@ -3661,7 +3660,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::SetEntityLocalScale(
|
||||
const AZ::EntityId entityId, const AZ::Vector3& localScale)
|
||||
const AZ::EntityId entityId, const float localScale)
|
||||
{
|
||||
ETCS::SetEntityLocalScale(entityId, localScale, m_transformChangedInternally);
|
||||
}
|
||||
@@ -3714,11 +3713,11 @@ namespace AzToolsFramework
|
||||
entityId, &AZ::TransformBus::Events::SetWorldTM, worldTransform);
|
||||
}
|
||||
|
||||
void SetEntityLocalScale(AZ::EntityId entityId, const AZ::Vector3& localScale, bool& internal)
|
||||
void SetEntityLocalScale(AZ::EntityId entityId, float localScale, bool& internal)
|
||||
{
|
||||
ScopeSwitch sw(internal);
|
||||
AZ::TransformBus::Event(
|
||||
entityId, &AZ::TransformBus::Events::SetLocalScale, localScale);
|
||||
entityId, &AZ::TransformBus::Events::SetLocalUniformScale, localScale);
|
||||
}
|
||||
|
||||
void SetEntityLocalRotation(AZ::EntityId entityId, const AZ::Vector3& localRotation, bool& internal)
|
||||
|
||||
+4
-4
@@ -212,8 +212,8 @@ namespace AzToolsFramework
|
||||
void CopyOrientationToSelectedEntitiesIndividual(const AZ::Quaternion& orientation);
|
||||
void CopyOrientationToSelectedEntitiesGroup(const AZ::Quaternion& orientation);
|
||||
void ResetOrientationForSelectedEntitiesLocal();
|
||||
void CopyScaleToSelectedEntitiesIndividualLocal(const AZ::Vector3& scale);
|
||||
void CopyScaleToSelectedEntitiesIndividualWorld(const AZ::Vector3& scale);
|
||||
void CopyScaleToSelectedEntitiesIndividualLocal(float scale);
|
||||
void CopyScaleToSelectedEntitiesIndividualWorld(float scale);
|
||||
|
||||
// EditorManipulatorCommandUndoRedoRequestBus ...
|
||||
void UndoRedoEntityManipulatorCommand(
|
||||
@@ -248,7 +248,7 @@ namespace AzToolsFramework
|
||||
void SetEntityWorldTranslation(AZ::EntityId entityId, const AZ::Vector3& worldTranslation);
|
||||
void SetEntityLocalTranslation(AZ::EntityId entityId, const AZ::Vector3& localTranslation);
|
||||
void SetEntityWorldTransform(AZ::EntityId entityId, const AZ::Transform& worldTransform);
|
||||
void SetEntityLocalScale(AZ::EntityId entityId, const AZ::Vector3& localScale);
|
||||
void SetEntityLocalScale(AZ::EntityId entityId, float localScale);
|
||||
void SetEntityLocalRotation(AZ::EntityId entityId, const AZ::Vector3& localRotation);
|
||||
|
||||
AZ::EntityId m_hoveredEntityId; ///< What EntityId is the mouse currently hovering over (if any).
|
||||
@@ -316,7 +316,7 @@ namespace AzToolsFramework
|
||||
void SetEntityWorldTranslation(AZ::EntityId entityId, const AZ::Vector3& worldTranslation, bool& internal);
|
||||
void SetEntityLocalTranslation(AZ::EntityId entityId, const AZ::Vector3& localTranslation, bool& internal);
|
||||
void SetEntityWorldTransform(AZ::EntityId entityId, const AZ::Transform& worldTransform, bool& internal);
|
||||
void SetEntityLocalScale(AZ::EntityId entityId, const AZ::Vector3& localScale, bool& internal);
|
||||
void SetEntityLocalScale(AZ::EntityId entityId, float localScale, bool& internal);
|
||||
void SetEntityLocalRotation(AZ::EntityId entityId, const AZ::Vector3& localRotation, bool& internal);
|
||||
} // namespace ETCS
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+2
-2
@@ -101,10 +101,10 @@ namespace AzToolsFramework
|
||||
virtual void ResetOrientationForSelectedEntitiesLocal() = 0;
|
||||
|
||||
/// Copy scale to each individual entity in local space without moving position.
|
||||
virtual void CopyScaleToSelectedEntitiesIndividualLocal(const AZ::Vector3& scale) = 0;
|
||||
virtual void CopyScaleToSelectedEntitiesIndividualLocal(float scale) = 0;
|
||||
|
||||
/// Copy scale to to each individual entity in world (absolute) space.
|
||||
virtual void CopyScaleToSelectedEntitiesIndividualWorld(const AZ::Vector3& scale) = 0;
|
||||
virtual void CopyScaleToSelectedEntitiesIndividualWorld(float scale) = 0;
|
||||
|
||||
protected:
|
||||
~EditorTransformComponentSelectionRequests() = default;
|
||||
|
||||
Reference in New Issue
Block a user