merge from main
This commit is contained in:
+33
-8
@@ -16,7 +16,7 @@
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
|
||||
#include <AzFramework/Scene/Scene.h>
|
||||
#include <AzFramework/Scene/SceneSystemBus.h>
|
||||
#include <AzFramework/Scene/SceneSystemInterface.h>
|
||||
|
||||
#include <AzToolsFramework/Editor/EditorSettingsAPIBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextComponent.h>
|
||||
@@ -56,22 +56,47 @@ namespace AzToolsFramework
|
||||
|
||||
void AzToolsFrameworkConfigurationSystemComponent::Activate()
|
||||
{
|
||||
// Associate the EditorEntityContext with the default scene.
|
||||
// Create the editor specific child scene to the main scene and add the editor entity context to it.
|
||||
AzFramework::EntityContextId editorEntityContextId;
|
||||
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
|
||||
AzFramework::Scene* defaultScene = nullptr;
|
||||
AzFramework::SceneSystemRequestBus::BroadcastResult(defaultScene, &AzFramework::SceneSystemRequests::GetScene, "default");
|
||||
|
||||
if (!editorEntityContextId.IsNull() && defaultScene)
|
||||
if (!editorEntityContextId.IsNull())
|
||||
{
|
||||
bool success = false;
|
||||
AzFramework::SceneSystemRequestBus::BroadcastResult(success, &AzFramework::SceneSystemRequests::SetSceneForEntityContextId, editorEntityContextId, defaultScene);
|
||||
auto sceneSystem = AzFramework::SceneSystemInterface::Get();
|
||||
AZ_Assert(sceneSystem, "Scene system not available to create the editor scene.");
|
||||
AZStd::shared_ptr<AzFramework::Scene> mainScene = sceneSystem->GetScene(AzFramework::Scene::MainSceneName);
|
||||
if (mainScene)
|
||||
{
|
||||
AZ::Outcome<AZStd::shared_ptr<AzFramework::Scene>, AZStd::string> editorScene =
|
||||
sceneSystem->CreateSceneWithParent(AzFramework::Scene::EditorMainSceneName, mainScene);
|
||||
if (editorScene.IsSuccess())
|
||||
{
|
||||
AzFramework::EntityContext* editorEntityContext = nullptr;
|
||||
EditorEntityContextRequestBus::BroadcastResult(
|
||||
editorEntityContext, &EditorEntityContextRequests::GetEditorEntityContextInstance);
|
||||
if (editorEntityContext != nullptr)
|
||||
{
|
||||
[[maybe_unused]] bool contextAdded =
|
||||
editorScene.GetValue()->SetSubsystem<AzFramework::EntityContext::SceneStorageType&>(editorEntityContext);
|
||||
AZ_Assert(contextAdded, "Unable to add editor entity context to scene.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Failed to create editor scene because: %s", editorScene.GetError().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "No main scene to parent the editor scene under.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AzToolsFrameworkConfigurationSystemComponent::Deactivate()
|
||||
{
|
||||
[[maybe_unused]] bool success = AzFramework::SceneSystemInterface::Get()->RemoveScene(AzFramework::Scene::EditorMainSceneName);
|
||||
AZ_Assert(success, "Unable to remove the main editor scene.");
|
||||
}
|
||||
|
||||
void AzToolsFrameworkConfigurationSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
|
||||
+1
-1
@@ -37,4 +37,4 @@ namespace AzToolsFramework
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
};
|
||||
} // AzToolsFramework
|
||||
} // AzToolsFramework
|
||||
|
||||
+1
-1
@@ -189,4 +189,4 @@ namespace AzToolsFramework
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
clipboard->setMimeData(mimeData.release());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,4 +69,4 @@ namespace AzToolsFramework
|
||||
private:
|
||||
ComponentDataContainer m_components;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,4 +28,4 @@ namespace AzToolsFramework
|
||||
->Field("CurrentAssetID", &AssetReferenceBase::m_currentID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,4 +43,4 @@ namespace AzToolsFramework
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ namespace AzToolsFramework
|
||||
};
|
||||
|
||||
using EditorDisabledCompositionRequestBus = AZ::EBus<EditorDisabledCompositionRequests>;
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -112,4 +112,4 @@ namespace AzToolsFramework
|
||||
EditorComponentBase::Deactivate();
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -49,4 +49,4 @@ namespace AzToolsFramework
|
||||
AZStd::vector<AZ::Component*> m_disabledComponents;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -71,4 +71,4 @@ namespace AzToolsFramework
|
||||
};
|
||||
|
||||
using EditorEntityIconComponentNotificationBus = AZ::EBus<EditorEntityIconComponentNotifications>;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -103,4 +103,4 @@ namespace AzToolsFramework
|
||||
bool m_componentOrderIsDirty = true; ///< This flag indicates our stored serialization order data is out of date and must be rebuilt before serialization occurs
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -50,4 +50,4 @@ namespace AzToolsFramework
|
||||
};
|
||||
|
||||
using EditorInspectorComponentNotificationBus = AZ::EBus<EditorInspectorComponentNotifications>;
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+2
-2
@@ -101,8 +101,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
editContext->Class<EditorLayerComponent>("Layer", "The layer component allows entities to be saved to different files on disk.")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Layers.svg")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Layers.svg")
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Layers.svg")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Layers.svg")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Layer", 0xe4db211a))
|
||||
->Attribute(AZ::Edit::Attributes::AddableByUser, false)
|
||||
->Attribute(AZ::Edit::Attributes::RemoveableByUser, false)
|
||||
|
||||
+34
-43
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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/ToolsComponents/EditorNonUniformScaleComponent.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzFramework/Components/NonUniformScaleComponent.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/ToString.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -32,16 +32,18 @@ namespace AzToolsFramework
|
||||
serializeContext->Class<EditorNonUniformScaleComponent, EditorComponentBase>()
|
||||
->Version(1)
|
||||
->Field("NonUniformScale", &EditorNonUniformScaleComponent::m_scale)
|
||||
;
|
||||
->Field("ComponentMode", &EditorNonUniformScaleComponent::m_componentModeDelegate);
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorNonUniformScaleComponent>("Non-uniform Scale",
|
||||
"Non-uniform scale for this entity only (does not propagate through hierarchy)")
|
||||
editContext
|
||||
->Class<EditorNonUniformScaleComponent>(
|
||||
"Non-uniform Scale", "Non-uniform scale for this entity only (does not propagate through hierarchy)")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Category, "Non-uniform Scale")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->Attribute(AZ::Edit::Attributes::FixedComponentListIndex, 1)
|
||||
->Attribute(AZ::Edit::Attributes::RemoveableByUser, true)
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/NonUniformScale.svg")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/NonUniformScale.svg")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &EditorNonUniformScaleComponent::m_scale, "Non-uniform Scale",
|
||||
"Non-uniform scale for this entity only (does not propagate through hierarchy)")
|
||||
@@ -49,7 +51,10 @@ namespace AzToolsFramework
|
||||
->Attribute(AZ::Edit::Attributes::Max, AZ::MaxTransformScale)
|
||||
->Attribute(AZ::Edit::Attributes::Step, 0.1f)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorNonUniformScaleComponent::OnScaleChanged)
|
||||
;
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &EditorNonUniformScaleComponent::m_componentModeDelegate, "Component Mode",
|
||||
"Non-uniform Scale Component Mode")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,28 +66,7 @@ namespace AzToolsFramework
|
||||
|
||||
void EditorNonUniformScaleComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC_CE("DebugDrawObbService"));
|
||||
incompatible.push_back(AZ_CRC_CE("DebugDrawService"));
|
||||
incompatible.push_back(AZ_CRC_CE("EMotionFXActorService"));
|
||||
incompatible.push_back(AZ_CRC_CE("EMotionFXSimpleMotionService"));
|
||||
incompatible.push_back(AZ_CRC_CE("GradientTransformService"));
|
||||
incompatible.push_back(AZ_CRC_CE("LegacyMeshService"));
|
||||
incompatible.push_back(AZ_CRC_CE("LookAtService"));
|
||||
incompatible.push_back(AZ_CRC_CE("SequenceService"));
|
||||
incompatible.push_back(AZ_CRC_CE("ClothMeshService"));
|
||||
incompatible.push_back(AZ_CRC_CE("PhysXJointService"));
|
||||
incompatible.push_back(AZ_CRC_CE("PhysXCharacterControllerService"));
|
||||
incompatible.push_back(AZ_CRC_CE("PhysXRagdollService"));
|
||||
incompatible.push_back(AZ_CRC_CE("WhiteBoxService"));
|
||||
incompatible.push_back(AZ_CRC_CE("NavigationAreaService"));
|
||||
incompatible.push_back(AZ_CRC_CE("GeometryService"));
|
||||
incompatible.push_back(AZ_CRC_CE("CapsuleShapeService"));
|
||||
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("SphereShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("SplineService"));
|
||||
incompatible.push_back(AZ_CRC_CE("TubeShapeService"));
|
||||
incompatible.push_back(AZ_CRC_CE("NonUniformScaleService"));
|
||||
}
|
||||
|
||||
void EditorNonUniformScaleComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
@@ -94,10 +78,16 @@ namespace AzToolsFramework
|
||||
void EditorNonUniformScaleComponent::Activate()
|
||||
{
|
||||
AZ::NonUniformScaleRequestBus::Handler::BusConnect(GetEntityId());
|
||||
|
||||
// ComponentMode
|
||||
m_componentModeDelegate.ConnectWithSingleComponentMode<EditorNonUniformScaleComponent, NonUniformScaleComponentMode>(
|
||||
AZ::EntityComponentIdPair(GetEntityId(), GetId()), nullptr);
|
||||
}
|
||||
|
||||
void EditorNonUniformScaleComponent::Deactivate()
|
||||
{
|
||||
m_componentModeDelegate.Disconnect();
|
||||
|
||||
AZ::NonUniformScaleRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
@@ -116,7 +106,8 @@ namespace AzToolsFramework
|
||||
else
|
||||
{
|
||||
AZ::Vector3 clampedScale = scale.GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
|
||||
AZ_Warning("Editor Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s",
|
||||
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;
|
||||
}
|
||||
|
||||
+6
@@ -13,6 +13,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.h>
|
||||
#include <AzToolsFramework/ComponentMode/ComponentModeDelegate.h>
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzCore/Component/NonUniformScaleBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
@@ -52,6 +55,9 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::Vector3 m_scale = AZ::Vector3::CreateOne();
|
||||
AZ::NonUniformScaleChangedEvent m_scaleChangedEvent;
|
||||
|
||||
//! Responsible for detecting ComponentMode activation and creating a concrete ComponentMode.
|
||||
AzToolsFramework::ComponentModeFramework::ComponentModeDelegate m_componentModeDelegate;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/NonUniformScaleBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Viewport/ViewportColors.h>
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponentMode.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
NonUniformScaleComponentMode::NonUniformScaleComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType)
|
||||
: EditorBaseComponentMode(entityComponentIdPair, componentType)
|
||||
{
|
||||
m_entityComponentIdPair = entityComponentIdPair;
|
||||
|
||||
AZ::Transform worldFromLocal = AZ::Transform::CreateIdentity();
|
||||
AZ::TransformBus::EventResult(worldFromLocal, m_entityComponentIdPair.GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
|
||||
worldFromLocal.ExtractScale();
|
||||
m_manipulators = AZStd::make_unique<ScaleManipulators>(worldFromLocal);
|
||||
m_manipulators->Register(g_mainManipulatorManagerId);
|
||||
m_manipulators->SetAxes(AZ::Vector3::CreateAxisX(), AZ::Vector3::CreateAxisY(), AZ::Vector3::CreateAxisZ());
|
||||
const float axisLength = 2.0f;
|
||||
m_manipulators->ConfigureView(
|
||||
axisLength, AzFramework::ViewportColors::XAxisColor, AzFramework::ViewportColors::YAxisColor,
|
||||
AzFramework::ViewportColors::ZAxisColor);
|
||||
|
||||
auto mouseDownCallback = [this](const LinearManipulator::Action& action) {
|
||||
AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne();
|
||||
|
||||
AZ::NonUniformScaleRequestBus::EventResult(
|
||||
nonUniformScale, m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::GetScale);
|
||||
|
||||
m_initialScale = nonUniformScale + action.m_start.m_scaleSnapOffset;
|
||||
|
||||
AZ::NonUniformScaleRequestBus::Event(
|
||||
m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::SetScale, m_initialScale);
|
||||
};
|
||||
|
||||
m_manipulators->InstallAxisLeftMouseDownCallback(mouseDownCallback);
|
||||
|
||||
m_manipulators->InstallAxisMouseMoveCallback([this](const LinearManipulator::Action& action) {
|
||||
const AZ::Vector3 scaleMultiplier =
|
||||
(AZ::Vector3::CreateOne() + ((action.LocalScaleOffset() * action.m_start.m_sign) / m_initialScale));
|
||||
|
||||
AZ::NonUniformScaleRequestBus::Event(
|
||||
m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::SetScale,
|
||||
(scaleMultiplier * m_initialScale).GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale)));
|
||||
});
|
||||
|
||||
m_manipulators->InstallUniformLeftMouseDownCallback(mouseDownCallback);
|
||||
|
||||
m_manipulators->InstallUniformMouseMoveCallback([this](const LinearManipulator::Action& action) {
|
||||
const auto sumVectorElements = [](const AZ::Vector3& vec) { return vec.GetX() + vec.GetY() + vec.GetZ(); };
|
||||
|
||||
const float minScaleMultiplier = AZ::MinTransformScale / m_initialScale.GetMinElement();
|
||||
const float maxScaleMultiplier = AZ::MaxTransformScale / m_initialScale.GetMaxElement();
|
||||
const float scaleMultiplier = AZ::GetClamp(
|
||||
1.0f + sumVectorElements(action.m_start.m_sign * action.LocalScaleOffset() / m_initialScale), minScaleMultiplier,
|
||||
maxScaleMultiplier);
|
||||
|
||||
AZ::NonUniformScaleRequestBus::Event(
|
||||
m_entityComponentIdPair.GetEntityId(), &AZ::NonUniformScaleRequests::SetScale, scaleMultiplier * m_initialScale);
|
||||
});
|
||||
}
|
||||
|
||||
NonUniformScaleComponentMode::~NonUniformScaleComponentMode()
|
||||
{
|
||||
if (m_manipulators)
|
||||
{
|
||||
m_manipulators->Unregister();
|
||||
}
|
||||
m_manipulators.reset();
|
||||
}
|
||||
|
||||
void NonUniformScaleComponentMode::Refresh()
|
||||
{
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <AzToolsFramework/ComponentMode/EditorBaseComponentMode.h>
|
||||
#include <AzToolsFramework/Manipulators/ScaleManipulators.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
class NonUniformScaleComponentMode : public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(NonUniformScaleComponentMode, AZ::SystemAllocator, 0)
|
||||
|
||||
NonUniformScaleComponentMode(const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType);
|
||||
NonUniformScaleComponentMode(const NonUniformScaleComponentMode&) = delete;
|
||||
NonUniformScaleComponentMode& operator=(const NonUniformScaleComponentMode&) = delete;
|
||||
NonUniformScaleComponentMode(NonUniformScaleComponentMode&&) = delete;
|
||||
NonUniformScaleComponentMode& operator=(NonUniformScaleComponentMode&&) = delete;
|
||||
~NonUniformScaleComponentMode();
|
||||
|
||||
// EditorBaseComponentMode overrides ...
|
||||
void Refresh() override;
|
||||
|
||||
private:
|
||||
AZ::EntityComponentIdPair m_entityComponentIdPair;
|
||||
AZStd::unique_ptr<ScaleManipulators> m_manipulators;
|
||||
AZ::Vector3 m_initialScale;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
+1
-1
@@ -26,4 +26,4 @@ namespace AzToolsFramework
|
||||
};
|
||||
|
||||
using EditorPendingCompositionRequestBus = AZ::EBus<EditorPendingCompositionRequests>;
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -125,4 +125,4 @@ namespace AzToolsFramework
|
||||
EditorComponentBase::Deactivate();
|
||||
}
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -49,4 +49,4 @@ namespace AzToolsFramework
|
||||
AZStd::vector<AZ::Component*> m_pendingComponents;
|
||||
};
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+1
-1
@@ -40,4 +40,4 @@ namespace AzToolsFramework
|
||||
|
||||
using EditorSelectionAccentingRequestBus = AZ::EBus<EditorSelectionAccentingRequests>;
|
||||
} // namespace Components
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+2
-2
@@ -1025,9 +1025,9 @@ namespace AzToolsFramework
|
||||
->Attribute(AZ::Edit::Attributes::NameLabelOverride, &ScriptEditorComponent::m_customName)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->Attribute(AZ::Edit::Attributes::Category, "Scripting")
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/LuaScript.svg")
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/LuaScript.svg")
|
||||
->Attribute(AZ::Edit::Attributes::PrimaryAssetType, AZ::AzTypeInfo<AZ::ScriptAsset>::Uuid())
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/Script.png")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Script.png")
|
||||
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://docs.aws.amazon.com/lumberyard/latest/userguide/component-lua-script.html")
|
||||
->DataElement("AssetRef", &ScriptEditorComponent::m_scriptAsset, "Script", "Which script to use")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &ScriptEditorComponent::ScriptHasChanged)
|
||||
|
||||
+1
-1
@@ -74,4 +74,4 @@ namespace AzToolsFramework
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -69,4 +69,4 @@ namespace AzToolsFramework
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+109
-25
@@ -25,11 +25,16 @@
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <AzFramework/Visibility/EntityBoundsUnionBus.h>
|
||||
#include <AzToolsFramework/API/EntityCompositionRequestBus.h>
|
||||
#include <AzToolsFramework/API/EntityPropertyEditorRequestsBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformScalePropertyHandler.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorPendingCompositionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
@@ -157,6 +162,12 @@ namespace AzToolsFramework
|
||||
classElement.RemoveElementByName(AZ_CRC("InterpolateScale", 0x9d00b831));
|
||||
}
|
||||
|
||||
if (classElement.GetVersion() < 10)
|
||||
{
|
||||
// The "Sync Enabled" flag is no longer needed.
|
||||
classElement.RemoveElementByName(AZ_CRC_CE("Sync Enabled"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Internal
|
||||
@@ -249,7 +260,7 @@ namespace AzToolsFramework
|
||||
m_localTransformDirty = true;
|
||||
m_worldTransformDirty = true;
|
||||
|
||||
if (GetEntity())
|
||||
if (const AZ::Entity* entity = GetEntity())
|
||||
{
|
||||
SetDirty();
|
||||
|
||||
@@ -261,6 +272,29 @@ namespace AzToolsFramework
|
||||
|
||||
AZ::TransformNotificationBus::Event(
|
||||
GetEntityId(), &TransformNotification::OnTransformChanged, localTM, worldTM);
|
||||
m_transformChangedEvent.Signal(localTM, worldTM);
|
||||
|
||||
AzFramework::IEntityBoundsUnion* boundsUnion = AZ::Interface<AzFramework::IEntityBoundsUnion>::Get();
|
||||
if (boundsUnion != nullptr)
|
||||
{
|
||||
boundsUnion->OnTransformUpdated(GetEntity());
|
||||
}
|
||||
// Fire a property changed notification for this component
|
||||
if (const AZ::Component* component = entity->FindComponent<Components::TransformComponent>())
|
||||
{
|
||||
PropertyEditorEntityChangeNotificationBus::Event(
|
||||
GetEntityId(), &PropertyEditorEntityChangeNotifications::OnEntityComponentPropertyChanged, component->GetId());
|
||||
}
|
||||
|
||||
// Refresh the property editor if we're selected
|
||||
bool selected = false;
|
||||
ToolsApplicationRequestBus::BroadcastResult(
|
||||
selected, &AzToolsFramework::ToolsApplicationRequests::IsSelected, GetEntityId());
|
||||
if (selected)
|
||||
{
|
||||
ToolsApplicationEvents::Bus::Broadcast(
|
||||
&ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_Values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,15 +892,14 @@ namespace AzToolsFramework
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AZ::Entity* pEntity = nullptr;
|
||||
EBUS_EVENT_RESULT(pEntity, AZ::ComponentApplicationBus, FindEntity, otherEntityId);
|
||||
if (!pEntity)
|
||||
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(otherEntityId);
|
||||
if (!entity)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pEntity->FindComponent<TransformComponent>();
|
||||
return entity->FindComponent<TransformComponent>();
|
||||
}
|
||||
|
||||
AZ::TransformInterface* TransformComponent::GetParent()
|
||||
@@ -1119,6 +1152,66 @@ namespace AzToolsFramework
|
||||
destinationComponent->SetWorldTM(const_cast<TransformComponent*>(sourceComponent)->GetWorldTM());
|
||||
}
|
||||
|
||||
AZ::Component* TransformComponent::FindPresentOrPendingComponent(AZ::Uuid componentUuid)
|
||||
{
|
||||
// first check if the component is present and valid
|
||||
if (AZ::Component* foundComponent = GetEntity()->FindComponent(componentUuid))
|
||||
{
|
||||
return foundComponent;
|
||||
}
|
||||
|
||||
// then check to see if there's a component pending because it's in an invalid state
|
||||
AZStd::vector<AZ::Component*> pendingComponents;
|
||||
AzToolsFramework::EditorPendingCompositionRequestBus::Event(GetEntityId(),
|
||||
&AzToolsFramework::EditorPendingCompositionRequests::GetPendingComponents, pendingComponents);
|
||||
|
||||
for (const auto pendingComponent : pendingComponents)
|
||||
{
|
||||
if (pendingComponent->RTTI_IsTypeOf(componentUuid))
|
||||
{
|
||||
return pendingComponent;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool TransformComponent::IsAddNonUniformScaleButtonReadOnly()
|
||||
{
|
||||
return FindPresentOrPendingComponent(EditorNonUniformScaleComponent::TYPEINFO_Uuid()) != nullptr;
|
||||
}
|
||||
|
||||
AZ::Crc32 TransformComponent::OnAddNonUniformScaleButtonPressed()
|
||||
{
|
||||
// if there is already a non-uniform scale component, do nothing
|
||||
if (FindPresentOrPendingComponent(EditorNonUniformScaleComponent::TYPEINFO_Uuid()))
|
||||
{
|
||||
return AZ::Edit::PropertyRefreshLevels::None;
|
||||
}
|
||||
|
||||
const AZStd::vector<AZ::EntityId> entityList = { GetEntityId() };
|
||||
const AZ::ComponentTypeList componentsToAdd = { EditorNonUniformScaleComponent::TYPEINFO_Uuid() };
|
||||
|
||||
AzToolsFramework::EntityCompositionRequests::AddComponentsOutcome addComponentsOutcome;
|
||||
AzToolsFramework::EntityCompositionRequestBus::BroadcastResult(addComponentsOutcome,
|
||||
&AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities, entityList, componentsToAdd);
|
||||
|
||||
const auto nonUniformScaleComponent = FindPresentOrPendingComponent(EditorNonUniformScaleComponent::RTTI_Type());
|
||||
AZ::ComponentId nonUniformScaleComponentId =
|
||||
nonUniformScaleComponent ? nonUniformScaleComponent->GetId() : AZ::InvalidComponentId;
|
||||
|
||||
if (!addComponentsOutcome.IsSuccess() || !nonUniformScaleComponent)
|
||||
{
|
||||
AZ_Warning("Transform component", false, "Failed to add non-uniform scale component.");
|
||||
return AZ::Edit::PropertyRefreshLevels::None;
|
||||
}
|
||||
|
||||
AzToolsFramework::EntityPropertyEditorRequestBus::Broadcast(
|
||||
&AzToolsFramework::EntityPropertyEditorRequests::SetNewComponentId, nonUniformScaleComponentId);
|
||||
|
||||
return AZ::Edit::PropertyRefreshLevels::EntireTree;
|
||||
}
|
||||
|
||||
void TransformComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
// reflect data for script, serialization, editing..
|
||||
@@ -1134,21 +1227,22 @@ namespace AzToolsFramework
|
||||
serializeContext->Class<Components::TransformComponent, EditorComponentBase>()->
|
||||
Field("Parent Entity", &TransformComponent::m_parentEntityId)->
|
||||
Field("Transform Data", &TransformComponent::m_editorTransform)->
|
||||
Field("AddNonUniformScaleButton", &TransformComponent::m_addNonUniformScaleButton)->
|
||||
Field("Cached World Transform", &TransformComponent::m_cachedWorldTransform)->
|
||||
Field("Cached World Transform Parent", &TransformComponent::m_cachedWorldTransformParent)->
|
||||
Field("Parent Activation Transform Mode", &TransformComponent::m_parentActivationTransformMode)->
|
||||
Field("IsStatic", &TransformComponent::m_isStatic)->
|
||||
Field("Sync Enabled", &TransformComponent::m_netSyncEnabled)->
|
||||
Field("InterpolatePosition", &TransformComponent::m_interpolatePosition)->
|
||||
Field("InterpolateRotation", &TransformComponent::m_interpolateRotation)->
|
||||
Version(9, &Internal::TransformComponentDataConverter);
|
||||
Version(10, &Internal::TransformComponentDataConverter);
|
||||
|
||||
if (AZ::EditContext* ptrEdit = serializeContext->GetEditContext())
|
||||
{
|
||||
ptrEdit->Class<TransformComponent>("Transform", "Controls the placement of the entity in the world in 3d")->
|
||||
ClassElement(AZ::Edit::ClassElements::EditorData, "")->
|
||||
Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Transform.svg")->
|
||||
Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/Transform.png")->
|
||||
Attribute(AZ::Edit::Attributes::FixedComponentListIndex, 0)->
|
||||
Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Transform.svg")->
|
||||
Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Transform.png")->
|
||||
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &TransformComponent::m_parentEntityId, "Parent entity", "")->
|
||||
Attribute(AZ::Edit::Attributes::ChangeValidate, &TransformComponent::ValidatePotentialParent)->
|
||||
@@ -1157,6 +1251,10 @@ namespace AzToolsFramework
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &TransformComponent::m_editorTransform, "Values", "")->
|
||||
Attribute(AZ::Edit::Attributes::ChangeNotify, &TransformComponent::TransformChanged)->
|
||||
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
||||
DataElement(AZ::Edit::UIHandlers::Button, &TransformComponent::m_addNonUniformScaleButton, "", "")->
|
||||
Attribute(AZ::Edit::Attributes::ButtonText, "Add non-uniform scale")->
|
||||
Attribute(AZ::Edit::Attributes::ReadOnly, &TransformComponent::IsAddNonUniformScaleButtonReadOnly)->
|
||||
Attribute(AZ::Edit::Attributes::ChangeNotify, &TransformComponent::OnAddNonUniformScaleButtonPressed)->
|
||||
DataElement(AZ::Edit::UIHandlers::ComboBox, &TransformComponent::m_parentActivationTransformMode,
|
||||
"Parent activation", "Configures relative transform behavior when parent activates.")->
|
||||
EnumAttribute(AZ::TransformConfig::ParentActivationTransformMode::MaintainOriginalRelativeTransform, "Original relative transform")->
|
||||
@@ -1168,21 +1266,7 @@ namespace AzToolsFramework
|
||||
Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Hide)->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &TransformComponent::m_cachedWorldTransform, "Cached World Transform", "")->
|
||||
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushable)->
|
||||
Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Hide)->
|
||||
|
||||
ClassElement(AZ::Edit::ClassElements::Group, "Network Sync")->
|
||||
Attribute(AZ::Edit::Attributes::AutoExpand, true)->
|
||||
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &TransformComponent::m_netSyncEnabled, "Sync to replicas", "Sync to network replicas.")->
|
||||
DataElement(AZ::Edit::UIHandlers::ComboBox, &TransformComponent::m_interpolatePosition,
|
||||
"Position Interpolation", "Enable local interpolation of position.")->
|
||||
EnumAttribute(AZ::InterpolationMode::NoInterpolation, "None")->
|
||||
EnumAttribute(AZ::InterpolationMode::LinearInterpolation, "Linear")->
|
||||
|
||||
DataElement(AZ::Edit::UIHandlers::ComboBox, &TransformComponent::m_interpolateRotation,
|
||||
"Rotation Interpolation", "Enable local interpolation of rotation.")->
|
||||
EnumAttribute(AZ::InterpolationMode::NoInterpolation, "None")->
|
||||
EnumAttribute(AZ::InterpolationMode::LinearInterpolation, "Linear");
|
||||
Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Hide);
|
||||
|
||||
ptrEdit->Class<EditorTransform>("Values", "XYZ PYR")->
|
||||
DataElement(AZ::Edit::UIHandlers::Default, &EditorTransform::m_translate, "Translate", "Local Position (Relative to parent) in meters.")->
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Commands/SelectionCommand.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h>
|
||||
|
||||
#include "EditorComponentBase.h"
|
||||
#include "TransformComponentBus.h"
|
||||
@@ -217,6 +218,10 @@ namespace AzToolsFramework
|
||||
|
||||
void CheckApplyCachedWorldTransform(const AZ::Transform& parentWorld);
|
||||
|
||||
AZ::Component* FindPresentOrPendingComponent(AZ::Uuid componentUuid);
|
||||
bool IsAddNonUniformScaleButtonReadOnly();
|
||||
AZ::Crc32 OnAddNonUniformScaleButtonPressed();
|
||||
|
||||
// Drives transform behavior when parent activates. See AZ::TransformConfig::ParentActivationTransformMode for details.
|
||||
AZ::TransformConfig::ParentActivationTransformMode m_parentActivationTransformMode;
|
||||
|
||||
@@ -249,6 +254,10 @@ namespace AzToolsFramework
|
||||
bool m_worldTransformDirty = true;
|
||||
bool m_isStatic = false;
|
||||
|
||||
// This is a workaround for a bug which causes the button to appear with incorrect placement if a UI
|
||||
// element is used rather than a data element.
|
||||
bool m_addNonUniformScaleButton = false;
|
||||
|
||||
// Deprecated
|
||||
AZ::InterpolationMode m_interpolatePosition;
|
||||
AZ::InterpolationMode m_interpolateRotation;
|
||||
|
||||
Reference in New Issue
Block a user