Integrating latest 47acbe8
This commit is contained in:
+6
@@ -217,10 +217,16 @@ namespace AzToolsFramework
|
||||
ComponentEntityEditorRequestBus::Event(descendant, &ComponentEntityEditorRequestBus::Events::RefreshVisibilityAndLock);
|
||||
}
|
||||
}
|
||||
|
||||
AzToolsFramework::Layers::EditorLayerComponentNotificationBus::Broadcast(
|
||||
&AzToolsFramework::Layers::EditorLayerComponentNotifications::OnLayerComponentActivated, GetEntityId());
|
||||
}
|
||||
|
||||
void EditorLayerComponent::Deactivate()
|
||||
{
|
||||
AzToolsFramework::Layers::EditorLayerComponentNotificationBus::Broadcast(
|
||||
&AzToolsFramework::Layers::EditorLayerComponentNotifications::OnLayerComponentDeactivated, GetEntityId());
|
||||
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -207,5 +207,28 @@ namespace AzToolsFramework
|
||||
virtual void OnNewLayerEntity(const AZ::EntityId& entityId, AZStd::vector<AZ::Component*>& componentsToAdd) = 0;
|
||||
};
|
||||
using EditorLayerCreationBus = AZ::EBus<EditorLayerCreationNotification>;
|
||||
|
||||
/**
|
||||
* This is a single bus with multiple listeners, for allowing systems to listen when specific layer component events occur.
|
||||
*/
|
||||
class EditorLayerComponentNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; // multi listener
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; //single bus
|
||||
|
||||
/**
|
||||
* Called when a layer component is activated on a layer entity
|
||||
* \param entityId The id of the entity whose layer component has been activated.
|
||||
*/
|
||||
virtual void OnLayerComponentActivated(AZ::EntityId entityId) = 0;
|
||||
/**
|
||||
* Called when a layer component is deactivated on a layer entity
|
||||
* \param entityId The id of the entity whose layer component has been deactivated.
|
||||
*/
|
||||
virtual void OnLayerComponentDeactivated(AZ::EntityId entityId) = 0;
|
||||
};
|
||||
using EditorLayerComponentNotificationBus = AZ::EBus<EditorLayerComponentNotifications>;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-7
@@ -13,6 +13,7 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzFramework/Components/NonUniformScaleComponent.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -43,6 +44,7 @@ namespace AzToolsFramework
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &EditorNonUniformScaleComponent::m_scale, "Non-uniform Scale",
|
||||
"Non-uniform scale for this entity only (does not propagate through hierarchy)")
|
||||
->Attribute(AZ::Edit::Attributes::Min, AZ::MinNonUniformScale)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorNonUniformScaleComponent::OnScaleChanged)
|
||||
;
|
||||
}
|
||||
@@ -56,7 +58,6 @@ namespace AzToolsFramework
|
||||
|
||||
void EditorNonUniformScaleComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC_CE("SkyCloudService"));
|
||||
incompatible.push_back(AZ_CRC_CE("DebugDrawObbService"));
|
||||
incompatible.push_back(AZ_CRC_CE("DebugDrawService"));
|
||||
incompatible.push_back(AZ_CRC_CE("EMotionFXActorService"));
|
||||
@@ -72,8 +73,6 @@ namespace AzToolsFramework
|
||||
incompatible.push_back(AZ_CRC_CE("PhysXShapeColliderService"));
|
||||
incompatible.push_back(AZ_CRC_CE("PhysXCharacterControllerService"));
|
||||
incompatible.push_back(AZ_CRC_CE("PhysXRagdollService"));
|
||||
incompatible.push_back(AZ_CRC_CE("TouchBendingPhysicsService"));
|
||||
incompatible.push_back(AZ_CRC_CE("WaterVolumeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("WhiteBoxService"));
|
||||
incompatible.push_back(AZ_CRC_CE("NavigationAreaService"));
|
||||
incompatible.push_back(AZ_CRC_CE("GeometryService"));
|
||||
@@ -81,12 +80,9 @@ namespace AzToolsFramework
|
||||
incompatible.push_back(AZ_CRC_CE("CompoundShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("CylinderShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("DiskShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("FixedVertexContainerService"));
|
||||
incompatible.push_back(AZ_CRC_CE("PolygonPrismShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("SphereShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("SplineService"));
|
||||
incompatible.push_back(AZ_CRC_CE("TubeShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("VariableVertexContainerService"));
|
||||
}
|
||||
|
||||
void EditorNonUniformScaleComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
@@ -113,7 +109,18 @@ namespace AzToolsFramework
|
||||
|
||||
void EditorNonUniformScaleComponent::SetScale(const AZ::Vector3& scale)
|
||||
{
|
||||
m_scale = scale;
|
||||
if (scale.GetMinElement() >= AZ::MinNonUniformScale)
|
||||
{
|
||||
m_scale = scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::Vector3 clampedScale = scale.GetMax(AZ::Vector3(AZ::MinNonUniformScale));
|
||||
AZ_Warning("Editor Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s",
|
||||
AZ::ToString(scale).c_str(), AZ::ToString(clampedScale).c_str(), GetEntity()->GetName().c_str());
|
||||
m_scale = clampedScale;
|
||||
}
|
||||
m_scaleChangedEvent.Signal(m_scale);
|
||||
}
|
||||
|
||||
void EditorNonUniformScaleComponent::RegisterScaleChangedEvent(AZ::NonUniformScaleChangedEvent::Handler& handler)
|
||||
|
||||
+23
-13
@@ -27,6 +27,7 @@
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
@@ -163,7 +164,6 @@ namespace AzToolsFramework
|
||||
, m_parentActivationTransformMode(AZ::TransformConfig::ParentActivationTransformMode::MaintainOriginalRelativeTransform)
|
||||
, m_cachedWorldTransform(AZ::Transform::Identity())
|
||||
, m_suppressTransformChangedEvent(false)
|
||||
, m_netSyncEnabled(false)
|
||||
, m_interpolatePosition(AZ::InterpolationMode::NoInterpolation)
|
||||
, m_interpolateRotation(AZ::InterpolationMode::NoInterpolation)
|
||||
{
|
||||
@@ -221,6 +221,26 @@ namespace AzToolsFramework
|
||||
EditorComponentBase::Deactivate();
|
||||
}
|
||||
|
||||
void TransformComponent::BindTransformChangedEventHandler(AZ::TransformChangedEvent::Handler& handler)
|
||||
{
|
||||
handler.Connect(m_transformChangedEvent);
|
||||
}
|
||||
|
||||
void TransformComponent::BindParentChangedEventHandler(AZ::ParentChangedEvent::Handler& handler)
|
||||
{
|
||||
handler.Connect(m_parentChangedEvent);
|
||||
}
|
||||
|
||||
void TransformComponent::BindChildChangedEventHandler(AZ::ChildChangedEvent::Handler& handler)
|
||||
{
|
||||
handler.Connect(m_childChangedEvent);
|
||||
}
|
||||
|
||||
void TransformComponent::NotifyChildChangedEvent(AZ::ChildChangeType changeType, AZ::EntityId entityId)
|
||||
{
|
||||
m_childChangedEvent.Signal(changeType, entityId);
|
||||
}
|
||||
|
||||
// This is called when our transform changes directly, or our parent's has changed.
|
||||
void TransformComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
@@ -278,16 +298,6 @@ namespace AzToolsFramework
|
||||
m_cachedWorldTransformParent = AZ::EntityId();
|
||||
}
|
||||
|
||||
bool TransformComponent::IsPositionInterpolated()
|
||||
{
|
||||
return m_interpolatePosition != AZ::InterpolationMode::NoInterpolation;
|
||||
}
|
||||
|
||||
bool TransformComponent::IsRotationInterpolated()
|
||||
{
|
||||
return m_interpolateRotation != AZ::InterpolationMode::NoInterpolation;
|
||||
}
|
||||
|
||||
void TransformComponent::CheckApplyCachedWorldTransform(const AZ::Transform& parentWorld)
|
||||
{
|
||||
if (m_parentEntityId != m_cachedWorldTransformParent)
|
||||
@@ -835,6 +845,7 @@ namespace AzToolsFramework
|
||||
// This is for Create Entity as child / Drag+drop parent update / add component
|
||||
EBUS_EVENT(AzToolsFramework::ToolsApplicationEvents::Bus, EntityParentChanged, GetEntityId(), parentId, oldParentId);
|
||||
EBUS_EVENT_ID(GetEntityId(), AZ::TransformNotificationBus, OnParentChanged, oldParentId, parentId);
|
||||
m_parentChangedEvent.Signal(oldParentId, parentId);
|
||||
|
||||
TransformChanged();
|
||||
}
|
||||
@@ -1136,7 +1147,6 @@ namespace AzToolsFramework
|
||||
{
|
||||
AZ::TransformConfig configuration;
|
||||
configuration.m_parentId = m_parentEntityId;
|
||||
configuration.m_netSyncEnabled = m_netSyncEnabled;
|
||||
configuration.m_worldTransform = GetWorldTM();
|
||||
configuration.m_localTransform = GetLocalTM();
|
||||
configuration.m_parentActivationTransformMode = m_parentActivationTransformMode;
|
||||
@@ -1241,7 +1251,7 @@ namespace AzToolsFramework
|
||||
Attribute(AZ::Edit::Attributes::Suffix, " deg")->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)->
|
||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &EditorTransform::m_scale, "Scale", "Local Scale")->
|
||||
DataElement(TransformScaleHandler, &EditorTransform::m_scale, "Scale", "Local Scale")->
|
||||
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
|
||||
Attribute(AZ::Edit::Attributes::Min, 0.01f)->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)
|
||||
|
||||
+16
-12
@@ -62,6 +62,10 @@ namespace AzToolsFramework
|
||||
void OnEntityDeactivated(const AZ::EntityId& parentEntityId) override;
|
||||
|
||||
// AZ::TransformBus
|
||||
void BindTransformChangedEventHandler(AZ::TransformChangedEvent::Handler& handler) override;
|
||||
void BindParentChangedEventHandler(AZ::ParentChangedEvent::Handler& handler) override;
|
||||
void BindChildChangedEventHandler(AZ::ChildChangedEvent::Handler& handler) override;
|
||||
void NotifyChildChangedEvent(AZ::ChildChangeType changeType, AZ::EntityId entityId) override;
|
||||
const AZ::Transform& GetLocalTM() override;
|
||||
void SetLocalTM(const AZ::Transform& tm) override;
|
||||
const AZ::Transform& GetWorldTM() override;
|
||||
@@ -185,9 +189,6 @@ namespace AzToolsFramework
|
||||
void UpdateCachedWorldTransform();
|
||||
void ClearCachedWorldTransform();
|
||||
|
||||
bool IsPositionInterpolated() override;
|
||||
bool IsRotationInterpolated() override;
|
||||
|
||||
// SliceEntityHierarchyRequestBus
|
||||
AZ::EntityId GetSliceEntityParentId() override;
|
||||
AZStd::vector<AZ::EntityId> GetSliceEntityChildren() override;
|
||||
@@ -227,20 +228,19 @@ namespace AzToolsFramework
|
||||
|
||||
void CheckApplyCachedWorldTransform(const AZ::Transform& parentWorld);
|
||||
|
||||
bool m_isStatic;
|
||||
// Drives transform behavior when parent activates. See AZ::TransformConfig::ParentActivationTransformMode for details.
|
||||
AZ::TransformConfig::ParentActivationTransformMode m_parentActivationTransformMode;
|
||||
|
||||
AZ::EntityId m_parentEntityId;
|
||||
AZ::EntityId m_previousParentEntityId;
|
||||
AZ::TransformChangedEvent m_transformChangedEvent; ///< Event used to signal when a transform changes.
|
||||
AZ::ParentChangedEvent m_parentChangedEvent; ///< Event used to signal when a transforms parent changes.
|
||||
AZ::ChildChangedEvent m_childChangedEvent; ///< Event used to signal when a transform has a child entity added or removed.
|
||||
|
||||
EditorTransform m_editorTransform;
|
||||
|
||||
//these are only used to hold onto the references returned by GetLocalTM and GetWorldTM
|
||||
// These are only used to hold onto the references returned by GetLocalTM and GetWorldTM
|
||||
AZ::Transform m_localTransformCache;
|
||||
AZ::Transform m_worldTransformCache;
|
||||
|
||||
// Drives transform behavior when parent activates. See AZ::TransformConfig::ParentActivationTransformMode for details.
|
||||
AZ::TransformConfig::ParentActivationTransformMode m_parentActivationTransformMode;
|
||||
|
||||
// Keeping a world transform along with a parent Id at the time of capture.
|
||||
// This is required for dealing with external changes to parent assignment (i.e. slice propagation).
|
||||
// A local transform alone isn't enough, since we may have serialized a parent-relative local transform,
|
||||
@@ -249,17 +249,21 @@ namespace AzToolsFramework
|
||||
AZ::Transform m_cachedWorldTransform;
|
||||
AZ::EntityId m_cachedWorldTransformParent;
|
||||
|
||||
AZ::EntityId m_parentEntityId;
|
||||
AZ::EntityId m_previousParentEntityId;
|
||||
|
||||
EntityIdList m_childrenEntityIds;
|
||||
|
||||
bool m_suppressTransformChangedEvent;
|
||||
|
||||
bool m_localTransformDirty = true;
|
||||
bool m_worldTransformDirty = true;
|
||||
bool m_isStatic = false;
|
||||
|
||||
// Used to serialize data required for NetBindable
|
||||
bool m_netSyncEnabled;
|
||||
// Deprecated
|
||||
AZ::InterpolationMode m_interpolatePosition;
|
||||
AZ::InterpolationMode m_interpolateRotation;
|
||||
bool m_netSyncEnabled = false;
|
||||
};
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AzToolsFramework_precompiled.h"
|
||||
#include <ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void RegisterTransformScaleHandler()
|
||||
{
|
||||
PropertyTypeRegistrationMessages::Bus::Broadcast(&PropertyTypeRegistrationMessages::RegisterPropertyType, aznew Components::TransformScalePropertyHandler());
|
||||
}
|
||||
|
||||
namespace Components
|
||||
{
|
||||
AZ::u32 TransformScalePropertyHandler::GetHandlerName(void) const
|
||||
{
|
||||
return TransformScaleHandler;
|
||||
}
|
||||
|
||||
QWidget* TransformScalePropertyHandler::CreateGUI(QWidget* parent)
|
||||
{
|
||||
AzQtComponents::DoubleSpinBox* newCtrl = new AzQtComponents::DoubleSpinBox(parent);
|
||||
connect(newCtrl, QOverload<double>::of(&AzQtComponents::DoubleSpinBox::valueChanged), newCtrl, [newCtrl]()
|
||||
{
|
||||
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, newCtrl);
|
||||
});
|
||||
|
||||
newCtrl->setMinimum(0.01f);
|
||||
newCtrl->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
return newCtrl;
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, [[maybe_unused]] const char* debugName)
|
||||
{
|
||||
if (attrib == AZ::Edit::Attributes::Suffix)
|
||||
{
|
||||
AZStd::string label;
|
||||
if (attrValue->Read<AZStd::string>(label))
|
||||
{
|
||||
GUI->setSuffix(label.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransformScalePropertyHandler::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
const float value = aznumeric_cast<float>(GUI->value());
|
||||
const float currentMaxElement = instance.GetMaxElement();
|
||||
if (currentMaxElement != 0.0f)
|
||||
{
|
||||
instance *= value / currentMaxElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = AZ::Vector3(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool TransformScalePropertyHandler::ReadValuesIntoGUI([[maybe_unused]] size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node)
|
||||
{
|
||||
QSignalBlocker signalBlocker(GUI);
|
||||
GUI->setValue(instance.GetMaxElement());
|
||||
return true;
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzQtComponents/Components/Widgets/SpinBox.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#endif
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
static const AZ::Crc32 TransformScaleHandler = AZ_CRC_CE("TransformScale");
|
||||
|
||||
//! Handler to allow the scale field inside the Transform Component to be represented as a single value in
|
||||
//! the editor, but stored internally as a Vector3.
|
||||
//! The purpose for this is to prevent any new entities being created with non-uniform scale on the Transform
|
||||
//! Component, but preserve the data required for migrating any existing entities to use the Non-Uniform Scale
|
||||
//! Component, until all migration work is completed.
|
||||
//! The value shown in the editor will be the maximum value from the scale vector, and changing the value in
|
||||
//! the editor will update the vector so that its maximum value matches the newly edited value, but its
|
||||
//! components retain their existing proportion.
|
||||
//! For example, if the current vector scale is (2, 3, 4), the value in the editor will appear as 4. If the value
|
||||
//! in the editor is updated to 2, then the vector scale will update to (1, 1.5, 2), keeping the same proportion
|
||||
//! between the x, y and z components.
|
||||
class TransformScalePropertyHandler
|
||||
: public QObject
|
||||
, public AzToolsFramework::PropertyHandler<AZ::Vector3, AzQtComponents::DoubleSpinBox>
|
||||
{
|
||||
Q_OBJECT //AUTOMOC
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(TransformScalePropertyHandler, AZ::SystemAllocator, 0);
|
||||
|
||||
AZ::u32 GetHandlerName(void) const override;
|
||||
QWidget* CreateGUI(QWidget* parent) override;
|
||||
void ConsumeAttribute(AzQtComponents::DoubleSpinBox* GUI, AZ::u32 attrib,
|
||||
AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
|
||||
void WriteGUIValuesIntoProperty(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
bool ReadValuesIntoGUI(size_t index, AzQtComponents::DoubleSpinBox* GUI,
|
||||
const AZ::Vector3& instance, AzToolsFramework::InstanceDataNode* node) override;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
Reference in New Issue
Block a user