diff --git a/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py b/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py index 5381fd9fd8..10df59e086 100644 --- a/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py +++ b/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py @@ -20,6 +20,7 @@ import subprocess @pytest.mark.SUITE_smoke class TestCLIToolAssetBuilderWorks(object): + @pytest.mark.xfail(reason="Ignoring failure temporarily - SPEC-6905") def test_CLITool_AssetBuilder_Works(self, build_directory): file_path = os.path.join(build_directory, "AssetBuilder") help_message = "AssetBuilder is part of the Asset Processor" diff --git a/Code/Framework/AzCore/Platform/iOS/AzCore/Module/DynamicModuleHandle_iOS.cpp b/Code/Framework/AzCore/Platform/iOS/AzCore/Module/DynamicModuleHandle_iOS.cpp index 53514c89e4..a389162ccc 100644 --- a/Code/Framework/AzCore/Platform/iOS/AzCore/Module/DynamicModuleHandle_iOS.cpp +++ b/Code/Framework/AzCore/Platform/iOS/AzCore/Module/DynamicModuleHandle_iOS.cpp @@ -40,7 +40,7 @@ namespace AZ // Afterwards use the AZ::IO::Path Append function append the filename as a child // of the framework directory AZ::IO::FixedMaxPathString fileName{ fullPath.Filename().Native() }; - fullPath.ReplaceFilename(AZ::IO::PathView((fileName + ".framework").c_str())); + fullPath.ReplaceFilename(AZ::IO::PathView(AZStd::string_view(fileName + ".framework"))); fullPath /= fileName; } } diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Character.h b/Code/Framework/AzFramework/AzFramework/Physics/Character.h index 19a6cbfe03..2401c9c5b9 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Character.h +++ b/Code/Framework/AzFramework/AzFramework/Physics/Character.h @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -36,7 +37,7 @@ namespace Physics static void Reflect(AZ::ReflectContext* context); AZStd::string m_name; - ShapeConfigurationList m_shapes; + AzPhysics::ShapeColliderPairList m_shapes; }; class CharacterColliderConfiguration diff --git a/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp b/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp index eb74390638..e43bda4c88 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp @@ -57,7 +57,7 @@ namespace Physics classElement.RemoveElement(shapesIndex); // add a new vector in the new format - const int newShapesIndex = classElement.AddElement(context, "shapes"); + const int newShapesIndex = classElement.AddElement(context, "shapes"); if (newShapesIndex != -1) { AZ::SerializeContext::DataElementNode& newShapesElement = classElement.GetSubElement(newShapesIndex); @@ -65,7 +65,9 @@ namespace Physics // convert the old shapes into the new format and add to the vector for (AZ::SerializeContext::DataElementNode shape : shapesCopy) { - const int pairIndex = newShapesElement.AddElementWithData(context, "element", ShapeConfigurationPair()); + const int pairIndex = newShapesElement.AddElementWithData( + context, "element", AzPhysics::ShapeColliderPair()); + AZ::SerializeContext::DataElementNode& pairElement = newShapesElement.GetSubElement(pairIndex); ColliderConfiguration colliderConfig; @@ -131,8 +133,8 @@ namespace Physics AZ::SerializeContext::DataElementNode* baseBaseClass1 = baseClass1->FindSubElement(AZ_CRC("BaseClass1", 0xd4925735)); if (baseBaseClass1 && baseBaseClass1->FindSubElementAndGetData(AZ_CRC("name", 0x5e237e06), name)) { - ShapeConfigurationList shapes; - if (nodeElement.FindSubElementAndGetData(AZ_CRC("shapes", 0x93dba512), shapes)) + AzPhysics::ShapeColliderPairList shapes; + if (nodeElement.FindSubElementAndGetData(AZ_CRC("shapes", 0x93dba512), shapes)) { CharacterColliderNodeConfiguration newColliderNodeConfig; newColliderNodeConfig.m_name = name; diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h index 5158da275e..b2b5fd1511 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h +++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsTypes.h @@ -70,7 +70,10 @@ namespace AzPhysics using SimulatedBodyHandleList = AZStd::vector; //! Helper used for pairing the ShapeConfiguration and ColliderConfiguration together which is used when creating a Simulated Body. - using ShapeColliderPair = AZStd::pair; + using ShapeColliderPair = AZStd::pair< + AZStd::shared_ptr, + AZStd::shared_ptr>; + using ShapeColliderPairList = AZStd::vector; //! Flags used to specifying which properties of a body to compute. enum class MassComputeFlags : AZ::u8 diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Shape.h b/Code/Framework/AzFramework/AzFramework/Physics/Shape.h index 115503c536..2ac38690ff 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Shape.h +++ b/Code/Framework/AzFramework/AzFramework/Physics/Shape.h @@ -80,9 +80,6 @@ namespace Physics void OnContactOffsetChanged(); }; - using ShapeConfigurationPair = AZStd::pair, AZStd::shared_ptr>; - using ShapeConfigurationList = AZStd::vector; - struct RayCastRequest; class Shape diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp index daf2c63921..79c1a28e5d 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp @@ -30,7 +30,8 @@ namespace AzFramework AZ_CVAR(float, ed_cameraSystemOrbitDollyScrollSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); AZ_CVAR(float, ed_cameraSystemOrbitDollyCursorSpeed, 0.01f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); AZ_CVAR(float, ed_cameraSystemScrollTranslateSpeed, 0.02f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); - AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 60.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); + AZ_CVAR(float, ed_cameraSystemMinOrbitDistance, 6.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); + AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 50.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); AZ_CVAR(float, ed_cameraSystemLookSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); AZ_CVAR(float, ed_cameraSystemTranslateSmoothness, 5.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); AZ_CVAR(float, ed_cameraSystemRotateSpeed, 0.005f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); @@ -532,20 +533,39 @@ namespace AzFramework if (Beginning()) { - float hit_distance = 0.0f; - AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight)) - .CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance); + const auto hasLookAt = [&nextCamera, &targetCamera, lookAtFn = m_lookAtFn] { + if (lookAtFn) + { + if (const auto lookAt = lookAtFn()) + { + auto transform = AZ::Transform::CreateLookAt(targetCamera.m_lookAt, *lookAt); + nextCamera.m_lookDist = -lookAt->GetDistance(targetCamera.m_lookAt); + UpdateCameraFromTransform(nextCamera, transform); - if (hit_distance > 0.0f) + return true; + } + } + return false; + }(); + + if (!hasLookAt) { - hit_distance = AZStd::min(hit_distance, ed_cameraSystemMaxOrbitDistance); - nextCamera.m_lookDist = -hit_distance; - nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance; - } - else - { - nextCamera.m_lookDist = -ed_cameraSystemMaxOrbitDistance; - nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * ed_cameraSystemMaxOrbitDistance; + float hit_distance = 0.0f; + AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight)) + .CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance); + + if (hit_distance > 0.0f) + { + hit_distance = AZStd::min(hit_distance, ed_cameraSystemMaxOrbitDistance); + nextCamera.m_lookDist = -hit_distance; + nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance; + } + else + { + nextCamera.m_lookDist = -ed_cameraSystemMinOrbitDistance; + nextCamera.m_lookAt = + targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * ed_cameraSystemMinOrbitDistance; + } } } diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h index 41d7f11385..b6b2bc1e6a 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h @@ -199,6 +199,7 @@ namespace AzFramework public: explicit RotateCameraInput(InputChannelId rotateChannelId); + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; @@ -239,6 +240,7 @@ namespace AzFramework public: PanCameraInput(InputChannelId panChannelId, PanAxesFn panAxesFn); + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; @@ -279,6 +281,7 @@ namespace AzFramework public: explicit TranslateCameraInput(TranslationAxesFn translationAxesFn); + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; void ResetImpl() override; @@ -348,6 +351,7 @@ namespace AzFramework class OrbitDollyScrollCameraInput : public CameraInput { public: + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; }; @@ -357,6 +361,7 @@ namespace AzFramework public: explicit OrbitDollyCursorMoveCameraInput(InputChannelId dollyChannelId); + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; @@ -367,6 +372,7 @@ namespace AzFramework class ScrollTranslationCameraInput : public CameraInput { public: + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; }; @@ -374,16 +380,32 @@ namespace AzFramework class OrbitCameraInput : public CameraInput { public: + using LookAtFn = AZStd::function()>; + + // CameraInput overrides ... void HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; - bool Exclusive() const override - { - return true; - } + bool Exclusive() const override; Cameras m_orbitCameras; + + //! Override the default behavior for how a look-at point is calculated. + void SetLookAtFn(const LookAtFn& lookAtFn); + + private: + LookAtFn m_lookAtFn; }; + inline void OrbitCameraInput::SetLookAtFn(const LookAtFn& lookAtFn) + { + m_lookAtFn = lookAtFn; + } + + inline bool OrbitCameraInput::Exclusive() const + { + return true; + } + struct WindowSize; //! Map from a generic InputChannel event to a camera specific InputEvent. diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/SelectionProxyModel.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/SelectionProxyModel.cpp new file mode 100644 index 0000000000..ed7fda7fa8 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/SelectionProxyModel.cpp @@ -0,0 +1,167 @@ +/* +* 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 +#include + +namespace AzQtComponents +{ + SelectionProxyModel::SelectionProxyModel(QItemSelectionModel* sourceSelectionModel, QAbstractProxyModel* proxyModel, QObject* parent) + : QItemSelectionModel(proxyModel, parent) + , m_sourceSelectionModel(sourceSelectionModel) + { + connect(sourceSelectionModel, &QItemSelectionModel::selectionChanged, this, &SelectionProxyModel::OnSourceSelectionChanged); + connect(sourceSelectionModel, &QItemSelectionModel::currentChanged, this, &SelectionProxyModel::OnSourceSelectionCurrentChanged); + connect(proxyModel, &QAbstractItemModel::rowsInserted, this, &SelectionProxyModel::OnProxyModelRowsInserted); + connect(this, &QItemSelectionModel::selectionChanged, this, &SelectionProxyModel::OnProxySelectionChanged); + + // Find the chain of proxy models + QAbstractProxyModel* sourceProxyModel = proxyModel; + while (sourceProxyModel) + { + m_proxyModels.push_back(sourceProxyModel); + sourceProxyModel = qobject_cast(sourceProxyModel->sourceModel()); + } + + const QItemSelection currentSelection = mapFromSource(m_sourceSelectionModel->selection()); + QItemSelectionModel::select(currentSelection, QItemSelectionModel::ClearAndSelect); + + const QModelIndex currentModelIndex = mapFromSource(m_sourceSelectionModel->currentIndex()); + QItemSelectionModel::setCurrentIndex(currentModelIndex, QItemSelectionModel::ClearAndSelect); + } + + void SelectionProxyModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) + { + const QModelIndex sourcetIndex = mapToSource(index); + m_sourceSelectionModel->setCurrentIndex(sourcetIndex, command); + } + + void SelectionProxyModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) + { + const QModelIndex sourceIndex = mapToSource(index); + m_sourceSelectionModel->select(sourceIndex, command); + } + + void SelectionProxyModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) + { + const QItemSelection sourceSelection = mapToSource(selection); + m_sourceSelectionModel->select(sourceSelection, command); + } + + void SelectionProxyModel::clear() + { + m_sourceSelectionModel->clear(); + } + + void SelectionProxyModel::reset() + { + m_sourceSelectionModel->reset(); + } + + void SelectionProxyModel::clearCurrentIndex() + { + m_sourceSelectionModel->clearCurrentIndex(); + } + + void SelectionProxyModel::OnSourceSelectionCurrentChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous) + { + QModelIndex targetCurrent = mapFromSource(current); + QItemSelectionModel::setCurrentIndex(targetCurrent, QItemSelectionModel::NoUpdate); + } + + void SelectionProxyModel::OnSourceSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) + { + QItemSelection targetSelected = mapFromSource(selected); + QItemSelection targetDeselected = mapFromSource(deselected); + + QItemSelectionModel::select(targetSelected, QItemSelectionModel::Select); + QItemSelectionModel::select(targetDeselected, QItemSelectionModel::Deselect); + } + + void SelectionProxyModel::OnProxySelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) + { + const QItemSelection sourceSelected = mapToSource(selected); + const QItemSelection sourceDeselected = mapToSource(deselected); + + // Disconnect from the selectionChanged signal in the source model to prevent recursion. We could also block the signals + // of the source selection model, but someone else may be connected to its signals and expect to get an update. + disconnect(m_sourceSelectionModel, &QItemSelectionModel::selectionChanged, this, &SelectionProxyModel::OnSourceSelectionChanged); + if (selected.empty() && deselected.empty()) + { + // Force the signal to fire + emit m_sourceSelectionModel->selectionChanged({}, {}); + } + else + { + m_sourceSelectionModel->select(sourceSelected, QItemSelectionModel::Select); + m_sourceSelectionModel->select(sourceDeselected, QItemSelectionModel::Deselect); + } + connect(m_sourceSelectionModel, &QItemSelectionModel::selectionChanged, this, &SelectionProxyModel::OnSourceSelectionChanged); + } + + void SelectionProxyModel::OnProxyModelRowsInserted([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int first, [[maybe_unused]] int last) + { + QModelIndex sourceIndex = m_sourceSelectionModel->currentIndex(); + QModelIndex targetIndex = mapFromSource(sourceIndex); + if (targetIndex != currentIndex()) + { + QItemSelectionModel::setCurrentIndex(targetIndex, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); + } + + QItemSelection sourceSelection = m_sourceSelectionModel->selection(); + QItemSelection targetSelection = mapFromSource(sourceSelection); + if (targetSelection != selection()) + { + QItemSelectionModel::select(targetSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + } + } + + QModelIndex SelectionProxyModel::mapFromSource(const QModelIndex& sourceIndex) + { + QModelIndex mappedIndex = sourceIndex; + for (QVector::const_reverse_iterator itProxy = m_proxyModels.rbegin(); itProxy != m_proxyModels.rend(); ++itProxy) + { + mappedIndex = (*itProxy)->mapFromSource(mappedIndex); + } + return mappedIndex; + } + + QItemSelection SelectionProxyModel::mapFromSource(const QItemSelection& sourceSelection) + { + QItemSelection mappedSelection = sourceSelection; + for (QVector::const_reverse_iterator itProxy = m_proxyModels.rbegin(); itProxy != m_proxyModels.rend(); ++itProxy) + { + mappedSelection = (*itProxy)->mapSelectionFromSource(mappedSelection); + } + return mappedSelection; + } + + QModelIndex SelectionProxyModel::mapToSource(const QModelIndex& targetIndex) + { + QModelIndex mappedIndex = targetIndex; + for (QVector::const_iterator itProxy = m_proxyModels.begin(); itProxy != m_proxyModels.end(); ++itProxy) + { + mappedIndex = (*itProxy)->mapToSource(mappedIndex); + } + return mappedIndex; + } + + QItemSelection SelectionProxyModel::mapToSource(const QItemSelection& targetSelection) + { + QItemSelection mappedSelection = targetSelection; + for (QVector::const_iterator itProxy = m_proxyModels.begin(); itProxy != m_proxyModels.end(); ++itProxy) + { + mappedSelection = (*itProxy)->mapSelectionToSource(mappedSelection); + } + return mappedSelection; + } +} // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/SelectionProxyModel.h b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/SelectionProxyModel.h new file mode 100644 index 0000000000..5187ed9cb0 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/SelectionProxyModel.h @@ -0,0 +1,66 @@ +/* +* 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 +#include +#include +#endif + +QT_FORWARD_DECLARE_CLASS(QAbstractProxyModel) + +namespace AzQtComponents +{ + //! This class is a QItemSelectionModel that syncs through proxy models and maintains + //! selection. In Qt we can have a model being filtered/sorted by proxy models. If the + //! selection model is connected to the original model, the view needs a new selection + //! model that understands the filtering. This class does that conversion. + //! @Note: this class does not support changing proxy models (anywhere in the chain). + //! The class will have to be recreated with the new proxy model. + class AZ_QT_COMPONENTS_API SelectionProxyModel + : public QItemSelectionModel + { + Q_OBJECT // AUTOMOC + + public: + SelectionProxyModel(QItemSelectionModel* sourceSelectionModel, QAbstractProxyModel* proxyModel, QObject* parent = nullptr); + + void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override; + void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override; + void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override; + void clear() override; + void reset() override; + void clearCurrentIndex() override; + + private slots: + void OnSourceSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); + void OnSourceSelectionCurrentChanged(const QModelIndex& current, const QModelIndex& previous); + void OnProxySelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); + void OnProxyModelRowsInserted(const QModelIndex& parent, int first, int last); + + private: + QModelIndex mapFromSource(const QModelIndex& sourceIndex); + QItemSelection mapFromSource(const QItemSelection& sourceSelection); + + QModelIndex mapToSource(const QModelIndex& targetIndex); + QItemSelection mapToSource(const QItemSelection& targetSelection); + + // Contains the chain of proxy models that leads us to the real model. The outer-most proxy model + // comes first and is followed by inner proxy models. + AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING + QVector m_proxyModels; + AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING + QItemSelectionModel* m_sourceSelectionModel; + }; +} // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index 30929b712b..33a35e0524 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -287,6 +287,8 @@ set(FILES Utilities/ScreenUtilities.cpp Utilities/ScreenGrabber.h Utilities/ScopedCleanup.h + Utilities/SelectionProxyModel.cpp + Utilities/SelectionProxyModel.h Utilities/TextUtilities.cpp Utilities/TextUtilities.h ) diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 436d4bba63..85c40f2092 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -49,6 +49,7 @@ #include #include #include +#include // AtomToolsFramework #include @@ -1238,6 +1239,20 @@ void EditorViewportWidget::SetViewportId(int id) auto firstPersonWheelCamera = AZStd::make_shared(); auto orbitCamera = AZStd::make_shared(); + orbitCamera->SetLookAtFn([]() -> AZStd::optional { + AZStd::optional manipulatorTransform; + AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( + manipulatorTransform, AzToolsFramework::GetEntityContextId(), + &AzToolsFramework::EditorTransformComponentSelectionRequestBus::Events::GetManipulatorTransform); + + if (manipulatorTransform) + { + return manipulatorTransform->GetTranslation(); + } + + return {}; + }); + auto orbitRotateCamera = AZStd::make_shared(AzFramework::CameraOrbitLookButton); auto orbitTranslateCamera = AZStd::make_shared(AzFramework::OrbitTranslation); auto orbitDollyWheelCamera = AZStd::make_shared(); diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index a25db506f4..e925c81032 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -200,11 +200,11 @@ namespace RedirectOutput { s_RedirectModule = module; - SetRedirection("stdout", g_redirect_stdout_saved, g_redirect_stdout, [](const char* msg) { + SetRedirection("stdout", g_redirect_stdout_saved, g_redirect_stdout, []([[maybe_unused]] const char* msg) { AZ_TracePrintf("Python", msg); }); - SetRedirection("stderr", g_redirect_stderr_saved, g_redirect_stderr, [](const char* msg) { + SetRedirection("stderr", g_redirect_stderr_saved, g_redirect_stderr, []([[maybe_unused]] const char* msg) { AZ_TracePrintf("Python", msg); }); diff --git a/Code/Tools/SerializeContextTools/SliceConverter.cpp b/Code/Tools/SerializeContextTools/SliceConverter.cpp index 7631eabf22..a18a6ff3a3 100644 --- a/Code/Tools/SerializeContextTools/SliceConverter.cpp +++ b/Code/Tools/SerializeContextTools/SliceConverter.cpp @@ -173,8 +173,7 @@ namespace AZ return false; } - const SliceComponent::SliceList& sliceList = sliceComponent->GetSlices(); - AZ_Warning("Convert-Slice", sliceList.empty(), " Slice depends on other slices, this conversion will lose data.\n"); + AZ_Warning("Convert-Slice", sliceComponent->GetSlices().empty(), " Slice depends on other slices, this conversion will lose data.\n"); // Create the Prefab with the entities from the slice AZStd::unique_ptr sourceInstance( diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/LightCulling/NVLC.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/LightCulling/NVLC.azsli index 8bcd21b19b..60d5bf38f2 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/LightCulling/NVLC.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/LightCulling/NVLC.azsli @@ -26,7 +26,7 @@ // //---------------------------------------------------------------------------------- -#define Depth_to_Z(d, unprojectZ) (unprojectZ.x / (d + unprojectZ.y)) +#define DepthBufferToViewSpace(d, unprojectZ) (unprojectZ.x / (d + unprojectZ.y)) #define NVLC_MAX_POSSIBLE_LIGHTS_PER_BIN 256 @@ -187,7 +187,7 @@ float4 RemapZToUnit(float4 z, float2 minmaxz) uint DepthSamplesToBinMask2x(float2 d, float2 minmaxz, float2 unprojectZ) { - float2 z = Depth_to_Z(d, unprojectZ); + float2 z = DepthBufferToViewSpace(d, unprojectZ); // Tile_UnitValueToBit will convert that 0 to 1 value into 0.0 to 31.99999 float2 bit = Tile_UnitValueToBit(RemapZToUnit(z, minmaxz)); @@ -207,7 +207,7 @@ uint DepthSamplesToBinMask2x(float2 d, float2 minmaxz, float2 unprojectZ) uint DepthSamplesToBinMask4x(float4 d, float2 minmaxz, float2 unprojectZ) { - float4 z = Depth_to_Z(d, unprojectZ); + float4 z = DepthBufferToViewSpace(d, unprojectZ); // Tile_UnitValueToBit will convert that 0 to 1 value into 0.0 to 31.99999 float4 bit = Tile_UnitValueToBit(RemapZToUnit(z, minmaxz)); diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/LightCulling/LightCullingTilePrepare.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/LightCulling/LightCullingTilePrepare.azsl index fba2175c9b..a8b2ab76db 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/LightCulling/LightCullingTilePrepare.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/LightCulling/LightCullingTilePrepare.azsl @@ -150,7 +150,7 @@ uint ComputeTransparentBitMask(float2 minmaxZ) return 0; } - float2 minmaxZ_transparent = Depth_to_Z(minmaxDepth_transparent, PassSrg::m_constantData.m_unprojectZ); + float2 minmaxZ_transparent = DepthBufferToViewSpace(minmaxDepth_transparent, PassSrg::m_constantData.m_unprojectZ); float2 minmaxUnit_transparent = RemapZToUnit(minmaxZ_transparent, minmaxZ); @@ -295,7 +295,7 @@ void MainCS( float2 minmaxDepth_opaque = ComputeDepthMinMaxFrom2Samples(opaqueDepthSamples); minmaxDepth_both = ExpandMinMax(minmaxDepth_opaque, minmaxDepth_transparent); UpdateMinMaxFromAllThreads(minmaxDepth_both, minmaxDepth_transparent, isPixelOnScreen); - minmaxDepth_both = Depth_to_Z(minmaxDepth_both, PassSrg::m_constantData.m_unprojectZ); + minmaxDepth_both = DepthBufferToViewSpace(minmaxDepth_both, PassSrg::m_constantData.m_unprojectZ); // if zNear == zFar we want to map z == zNear to 0-bit, so we have to keep zNear without modifications minmaxDepth_both.y = IncrementULP(minmaxDepth_both.y); @@ -313,7 +313,7 @@ void MainCS( float2 minmaxDepth_opaque = ComputeDepthMinMaxFrom4Samples(opaqueDepthSamples); minmaxDepth_both = ExpandMinMax(minmaxDepth_opaque, minmaxDepth_transparent); UpdateMinMaxFromAllThreads(minmaxDepth_both, minmaxDepth_transparent, isPixelOnScreen); - minmaxDepth_both = Depth_to_Z(minmaxDepth_both, PassSrg::m_constantData.m_unprojectZ); + minmaxDepth_both = DepthBufferToViewSpace(minmaxDepth_both, PassSrg::m_constantData.m_unprojectZ); // if zNear == zFar we want to map z == zNear to 0-bit, so we have to keep zNear without modifications minmaxDepth_both.y = IncrementULP(minmaxDepth_both.y); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h index fe40cabc12..31cdb34ddd 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h @@ -62,7 +62,7 @@ namespace AZ bool m_enableShadow = false; ShadowmapSize m_shadowmapMaxSize = ShadowmapSize::Size256; ShadowFilterMethod m_shadowFilterMethod = ShadowFilterMethod::None; - PcfMethod m_pcfMethod = PcfMethod::BoundarySearch; + PcfMethod m_pcfMethod = PcfMethod::Bicubic; float m_boundaryWidthInDegrees = 0.25f; uint16_t m_predictionSampleCount = 4; uint16_t m_filteringSampleCount = 12; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h index 7de2857541..237c1f3016 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h @@ -61,7 +61,7 @@ namespace AZ float m_shadowFarClipDistance = 100.f; //! Width/Height of shadowmap images. - ShadowmapSize m_shadowmapSize = MaxShadowmapImageSize; + ShadowmapSize m_shadowmapSize = ShadowmapSize::Size1024; //! Number of cascades. uint32_t m_cascadeCount = 4; @@ -117,7 +117,7 @@ namespace AZ //! It is used only when the pixel is predicted as on the boundary. uint16_t m_filteringSampleCount = 32; - PcfMethod m_pcfMethod = PcfMethod::BoundarySearch; + PcfMethod m_pcfMethod = PcfMethod::Bicubic; bool IsSplitManual() const; bool IsSplitAutomatic() const; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp index a77bcfdd12..69bec21a6c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorAreaLightComponent.cpp @@ -173,10 +173,10 @@ namespace AZ ->DataElement( Edit::UIHandlers::ComboBox, &AreaLightComponentConfig::m_pcfMethod, "Pcf method", "Type of PCF to use.\n" - " Boundary search: do several taps to first determine if we are on a shadow boundary\n" - " Bicubic: a smooth, fixed-size kernel \n") - ->EnumAttribute(PcfMethod::BoundarySearch, "Boundary search") + " Bicubic: a smooth, fixed-size kernel \n" + " Boundary search: do several taps to first determine if we are on a shadow boundary\n") ->EnumAttribute(PcfMethod::Bicubic, "Bicubic") + ->EnumAttribute(PcfMethod::BoundarySearch, "Boundary search") ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) ->Attribute(Edit::Attributes::Visibility, &AreaLightComponentConfig::SupportsShadows) ->Attribute(Edit::Attributes::ReadOnly, &AreaLightComponentConfig::IsShadowPcfDisabled); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorDirectionalLightComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorDirectionalLightComponent.cpp index 35c5522c4e..a40557f2f1 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorDirectionalLightComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/EditorDirectionalLightComponent.cpp @@ -163,10 +163,10 @@ namespace AZ ->DataElement( Edit::UIHandlers::ComboBox, &DirectionalLightComponentConfig::m_pcfMethod, "Pcf Method", "Type of Pcf to use.\n" - " Boundary search: do several taps to first determine if we are on a shadow boundary\n" - " Bicubic: a smooth, fixed-size kernel \n") - ->EnumAttribute(PcfMethod::BoundarySearch, "Boundary Search") + " Bicubic: a smooth, fixed-size kernel \n" + " Boundary search: do several taps to first determine if we are on a shadow boundary\n") ->EnumAttribute(PcfMethod::Bicubic, "Bicubic") + ->EnumAttribute(PcfMethod::BoundarySearch, "Boundary Search") ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) ->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowPcfDisabled); ; diff --git a/Gems/Blast/Code/Source/Actor/ShapesProvider.cpp b/Gems/Blast/Code/Source/Actor/ShapesProvider.cpp index 42bdd773f7..a739f25cf9 100644 --- a/Gems/Blast/Code/Source/Actor/ShapesProvider.cpp +++ b/Gems/Blast/Code/Source/Actor/ShapesProvider.cpp @@ -27,7 +27,7 @@ namespace Blast PhysX::ColliderComponentRequestBus::Handler::BusDisconnect(m_entityId); } - Physics::ShapeConfigurationList ShapesProvider::GetShapeConfigurations() + AzPhysics::ShapeColliderPairList ShapesProvider::GetShapeConfigurations() { return {}; } diff --git a/Gems/Blast/Code/Source/Actor/ShapesProvider.h b/Gems/Blast/Code/Source/Actor/ShapesProvider.h index 4e737be080..0b23dc542c 100644 --- a/Gems/Blast/Code/Source/Actor/ShapesProvider.h +++ b/Gems/Blast/Code/Source/Actor/ShapesProvider.h @@ -28,7 +28,7 @@ namespace Blast void AddShape(AZStd::shared_ptr shape); // This class is not supposed to provide shape configurations, only shapes themselves. - Physics::ShapeConfigurationList GetShapeConfigurations() override; + AzPhysics::ShapeColliderPairList GetShapeConfigurations() override; AZStd::vector> GetShapes() override; diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.cpp b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.cpp index fae3ee742c..bd0d998737 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.cpp @@ -251,7 +251,7 @@ namespace EMotionFX return false; } - Physics::ShapeConfigurationPair newCollider; + AzPhysics::ShapeColliderPair newCollider; // Either in case the contents got specified via a command parameter or in case of redo. if (m_contents) @@ -263,7 +263,7 @@ namespace EMotionFX else if (m_colliderType) { // Create new collider. - AZ::Outcome colliderOutcome = PhysicsSetup::CreateColliderByType(m_colliderType.value(), outResult); + AZ::Outcome colliderOutcome = PhysicsSetup::CreateColliderByType(m_colliderType.value(), outResult); if (!colliderOutcome.IsSuccess()) { return false; @@ -367,7 +367,7 @@ namespace EMotionFX return false; } - const Physics::ShapeConfigurationPair& collider = nodeConfig->m_shapes[m_oldColliderIndex.value()]; + const AzPhysics::ShapeColliderPair& collider = nodeConfig->m_shapes[m_oldColliderIndex.value()]; m_contents = MCore::ReflectionSerializer::Serialize(&collider).GetValue(); CommandColliderHelpers::RemoveCollider(m_actorId, m_jointName, m_configType, m_oldColliderIndex.value(), /*commandGroup*/ nullptr, true); @@ -472,7 +472,7 @@ namespace EMotionFX AZ_UNUSED(parameters); Actor* actor = nullptr; - Physics::ShapeConfigurationPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult); + AzPhysics::ShapeColliderPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult); if (!shapeConfigPair) { return false; @@ -524,7 +524,7 @@ namespace EMotionFX AZ_UNUSED(parameters); Actor* actor = nullptr; - Physics::ShapeConfigurationPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult); + AzPhysics::ShapeColliderPair* shapeConfigPair = GetShapeConfigPair(&actor, outResult); if (!shapeConfigPair) { return false; @@ -606,7 +606,7 @@ namespace EMotionFX return true; } - Physics::ShapeConfigurationPair* CommandAdjustCollider::GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const + AzPhysics::ShapeColliderPair* CommandAdjustCollider::GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const { Actor* actor = GetActor(this, outResult); if (!actor) @@ -647,7 +647,7 @@ namespace EMotionFX return nullptr; } - Physics::ShapeConfigurationPair& shapeConfigPair = nodeConfig->m_shapes[m_index.value()]; + AzPhysics::ShapeColliderPair& shapeConfigPair = nodeConfig->m_shapes[m_index.value()]; return &shapeConfigPair; } diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.h index f0d20ce5f3..bb84e955ef 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ColliderCommands.h @@ -159,7 +159,7 @@ namespace EMotionFX static const char* s_commandName; private: - Physics::ShapeConfigurationPair* GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const; + AzPhysics::ShapeColliderPair* GetShapeConfigPair(Actor** outActor, AZStd::string& outResult) const; AZStd::optional m_configType; AZStd::optional m_index; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.cpp index e8e5afb90f..cbe3e73cb3 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.cpp @@ -198,13 +198,13 @@ namespace EMotionFX return m_config.m_simulatedObjectColliderConfig; } - AZ::Outcome PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId) + AZ::Outcome PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId) { AZStd::string outResult; return CreateColliderByType(typeId, outResult); } - AZ::Outcome PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult) + AZ::Outcome PhysicsSetup::CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult) { if (typeId.IsNull()) { @@ -227,14 +227,16 @@ namespace EMotionFX return AZ::Failure(); } - Physics::ShapeConfiguration* shapeConfig = reinterpret_cast(classData->m_factory->Create(classData->m_name)); + AZStd::shared_ptr shapeConfig( + reinterpret_cast(classData->m_factory->Create(classData->m_name))); + if (!shapeConfig) { outResult = AZStd::string::format("Could not create collider with type '%s'.", typeId.ToString().c_str()); return AZ::Failure(); } - Physics::ShapeConfigurationPair pair(AZStd::make_shared(), shapeConfig); + AzPhysics::ShapeColliderPair pair(AZStd::make_shared(), shapeConfig); if (pair.first->m_materialSelection.GetMaterialIdsAssignedToSlots().empty()) { pair.first->m_materialSelection.SetMaterialSlots(Physics::MaterialSelection::SlotsArray()); @@ -242,7 +244,7 @@ namespace EMotionFX return AZ::Success(pair); } - void PhysicsSetup::AutoSizeCollider(Physics::ShapeConfigurationPair& collider, const Actor* actor, const Node* joint) + void PhysicsSetup::AutoSizeCollider(AzPhysics::ShapeColliderPair& collider, const Actor* actor, const Node* joint) { if (!collider.second || !actor || !joint) { @@ -417,7 +419,7 @@ namespace EMotionFX nodeConfig = &hitDetectionConfig.m_nodes.back(); } - Physics::ShapeConfigurationList& collisionShapes = nodeConfig->m_shapes; + AzPhysics::ShapeColliderPairList& collisionShapes = nodeConfig->m_shapes; Physics::ColliderConfiguration* colliderConfig = aznew Physics::ColliderConfiguration(); colliderConfig->m_position = position; diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.h b/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.h index 4ff925739a..1da80faa34 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/PhysicsSetup.h @@ -68,9 +68,9 @@ namespace EMotionFX void OptimizeForServer(); - static AZ::Outcome CreateColliderByType(const AZ::TypeId& typeId); - static AZ::Outcome CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult); - static void AutoSizeCollider(Physics::ShapeConfigurationPair& collider, const Actor* actor, const Node* node); + static AZ::Outcome CreateColliderByType(const AZ::TypeId& typeId); + static AZ::Outcome CreateColliderByType(const AZ::TypeId& typeId, AZStd::string& outResult); + static void AutoSizeCollider(AzPhysics::ShapeColliderPair& collider, const Actor* actor, const Node* node); static void Reflect(AZ::ReflectContext* context); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp index 7a219b5ff3..0edc6ebb38 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp @@ -51,7 +51,7 @@ namespace EMotionFX m_collisionObjects.reserve(3); } - void SpringSolver::CreateCollider(AZ::u32 skeletonJointIndex, const Physics::ShapeConfigurationPair& shapePair) + void SpringSolver::CreateCollider(AZ::u32 skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair) { const Physics::ShapeConfiguration* shapeConfig = shapePair.second.get(); if (!shapeConfig) @@ -104,7 +104,7 @@ namespace EMotionFX bool colliderFound = false; for (const auto& nodeConfig : colliderSetup.m_nodes) { - for (const Physics::ShapeConfigurationPair& shapePair : nodeConfig.m_shapes) + for (const AzPhysics::ShapeColliderPair& shapePair : nodeConfig.m_shapes) { if (shapePair.first->m_tag == colliderTag) { diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h index 5843ea02be..ca45343a6b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.h @@ -87,7 +87,7 @@ namespace EMotionFX AZ::Vector3 m_end = AZ::Vector3::CreateZero(); /**< The end position of the primitive. In case of a sphere this is ignored. */ float m_radius = 1.0f; /**< The radius or thickness. */ float m_scaledRadius = 1.0f; /**< The scaled radius value, scaled by the joint's world space transform. */ - const Physics::ShapeConfigurationPair* m_shapePair = nullptr; + const AzPhysics::ShapeColliderPair* m_shapePair = nullptr; }; struct EMFX_API InitSettings @@ -151,7 +151,7 @@ namespace EMotionFX private: void InitColliders(const InitSettings& initSettings); - void CreateCollider(AZ::u32 skeletonJointIndex, const Physics::ShapeConfigurationPair& shapePair); + void CreateCollider(AZ::u32 skeletonJointIndex, const AzPhysics::ShapeColliderPair& shapePair); void InitColliderFromColliderSetupShape(CollisionObject& collider); void InitCollidersFromColliderSetupShapes(); bool RecursiveAddJoint(const SimulatedJoint* joint, size_t parentParticleIndex); diff --git a/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.cpp b/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.cpp index f6c196b23e..bd013da767 100644 --- a/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.cpp @@ -266,7 +266,7 @@ namespace EMotionFX connect(this, &AzQtComponents::Card::contextMenuRequested, this, &ColliderWidget::OnCardContextMenu); } - void ColliderWidget::Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationPair& collider) + void ColliderWidget::Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPair& collider) { m_actor = actor; m_joint = joint; @@ -276,7 +276,7 @@ namespace EMotionFX if (!collider.first || !collider.second) { m_editor->ClearInstances(true); - m_collider = Physics::ShapeConfigurationPair(); + m_collider = AzPhysics::ShapeColliderPair(); return; } @@ -520,7 +520,7 @@ namespace EMotionFX CommandSystem::GetCommandManager()->RemoveCommandCallback(m_commandCallback, /*delFromMem=*/true); } - void ColliderContainerWidget::Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationList& colliders, AZ::SerializeContext* serializeContext) + void ColliderContainerWidget::Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPairList& colliders, AZ::SerializeContext* serializeContext) { m_actor = actor; m_joint = joint; @@ -557,7 +557,7 @@ namespace EMotionFX for (size_t i = numColliders; i < numAvailableColliderWidgets; ++i) { m_colliderWidgets[i]->hide(); - m_colliderWidgets[i]->Update(nullptr, nullptr, MCORE_INVALIDINDEX32, PhysicsSetup::ColliderConfigType::Unknown, Physics::ShapeConfigurationPair()); + m_colliderWidgets[i]->Update(nullptr, nullptr, MCORE_INVALIDINDEX32, PhysicsSetup::ColliderConfigType::Unknown, AzPhysics::ShapeColliderPair()); } } @@ -571,7 +571,7 @@ namespace EMotionFX void ColliderContainerWidget::Reset() { - Update(nullptr, nullptr, PhysicsSetup::ColliderConfigType::Unknown, Physics::ShapeConfigurationList(), nullptr); + Update(nullptr, nullptr, PhysicsSetup::ColliderConfigType::Unknown, AzPhysics::ShapeColliderPairList(), nullptr); } void ColliderContainerWidget::contextMenuEvent(QContextMenuEvent* event) @@ -614,7 +614,7 @@ namespace EMotionFX return QWidget::sizeHint() + QSize(0, s_layoutSpacing); } - void ColliderContainerWidget::RenderColliders(const Physics::ShapeConfigurationList& colliders, + void ColliderContainerWidget::RenderColliders(const AzPhysics::ShapeColliderPairList& colliders, const ActorInstance* actorInstance, const Node* node, EMStudio::EMStudioPlugin::RenderInfo* renderInfo, @@ -704,7 +704,7 @@ namespace EMotionFX if (joint) { const bool jointSelected = selectedJointIndices.empty() || selectedJointIndices.find(joint->GetNodeIndex()) != selectedJointIndices.end(); - const Physics::ShapeConfigurationList& colliders = nodeConfig.m_shapes; + const AzPhysics::ShapeColliderPairList& colliders = nodeConfig.m_shapes; RenderColliders(colliders, actorInstance, joint, renderInfo, jointSelected ? selectedColor : defaultColor); } } diff --git a/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.h b/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.h index e8cc717e49..31f28ce210 100644 --- a/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.h +++ b/Gems/EMotionFX/Code/Source/Editor/ColliderContainerWidget.h @@ -71,7 +71,7 @@ namespace EMotionFX public: ColliderWidget(QIcon* icon, QWidget* parent, AZ::SerializeContext* serializeContext); - void Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationPair& collider); + void Update(Actor* actor, Node* joint, size_t colliderIndex, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPair& collider); void Update(); void Reset(); @@ -99,7 +99,7 @@ namespace EMotionFX PhysicsSetup::ColliderConfigType m_colliderType = PhysicsSetup::ColliderConfigType::Unknown; Node* m_joint = nullptr; size_t m_colliderIndex = MCORE_INVALIDINDEX32; - Physics::ShapeConfigurationPair m_collider; + AzPhysics::ShapeColliderPair m_collider; QIcon* m_icon; }; @@ -140,7 +140,7 @@ namespace EMotionFX ColliderContainerWidget(const QIcon& colliderIcon, QWidget* parent = nullptr); ~ColliderContainerWidget(); - void Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const Physics::ShapeConfigurationList& colliders, AZ::SerializeContext* serializeContext); + void Update(Actor* actor, Node* joint, PhysicsSetup::ColliderConfigType colliderType, const AzPhysics::ShapeColliderPairList& colliders, AZ::SerializeContext* serializeContext); void Update(); void Reset(); PhysicsSetup::ColliderConfigType ColliderType() { return m_colliderType; } @@ -156,7 +156,7 @@ namespace EMotionFX * @param[in] renderInfo Needed to access the render util. * @param[in] colliderColor The collider color. */ - static void RenderColliders(const Physics::ShapeConfigurationList& colliders, + static void RenderColliders(const AzPhysics::ShapeColliderPairList& colliders, const ActorInstance* actorInstance, const Node* node, EMStudio::EMStudioPlugin::RenderInfo* renderInfo, diff --git a/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.cpp b/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.cpp index b8f6311600..2cab16e2c1 100644 --- a/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.cpp @@ -40,7 +40,7 @@ namespace EMotionFX const Physics::CharacterColliderNodeConfiguration* copyFromNodeConfig = copyFromColliderConfig->FindNodeConfigByName(joint->GetNameString()); if (copyFromNodeConfig) { - for (const Physics::ShapeConfigurationPair& shapeConfigPair : copyFromNodeConfig->m_shapes) + for (const AzPhysics::ShapeColliderPair& shapeConfigPair : copyFromNodeConfig->m_shapes) { const AZStd::string contents = MCore::ReflectionSerializer::Serialize(&shapeConfigPair).GetValue(); CommandColliderHelpers::AddCollider(actor->GetID(), joint->GetNameString(), copyTo, contents, AZStd::nullopt, &commandGroup); @@ -231,7 +231,7 @@ namespace EMotionFX const Physics::CharacterColliderNodeConfiguration* copyFromNodeConfig = copyFromColliderConfig->FindNodeConfigByName(joint->GetNameString()); if (copyFromNodeConfig && shapeIndex < copyFromNodeConfig->m_shapes.size()) { - const Physics::ShapeConfigurationPair* shape = ©FromNodeConfig->m_shapes[shapeIndex]; + const AzPhysics::ShapeColliderPair* shape = ©FromNodeConfig->m_shapes[shapeIndex]; const AZStd::string contents = MCore::ReflectionSerializer::Serialize(shape).GetValue(); QMimeData* mimeData = new QMimeData(); mimeData->setData( diff --git a/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.h b/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.h index 462638e793..a2eba33682 100644 --- a/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.h +++ b/Gems/EMotionFX/Code/Source/Editor/ColliderHelpers.h @@ -28,7 +28,7 @@ namespace EMotionFX public: static QString GetMimeTypeForColliderShape() { - return QString("com.amazon.lumberyard/%1").arg(azrtti_typeid().ToString()); + return QString("com.amazon.lumberyard/%1").arg(azrtti_typeid().ToString()); } static void AddCopyColliderCommandToGroup(const Actor* actor, const Node* joint, PhysicsSetup::ColliderConfigType copyFrom, PhysicsSetup::ColliderConfigType copyTo, MCore::CommandGroup& commandGroup); diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp index c2e2c5cc1b..e2fde04016 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp @@ -507,7 +507,7 @@ namespace EMotionFX const Physics::CharacterColliderNodeConfiguration* colliderNodeConfig = colliderConfig.FindNodeConfigByName(joint->GetNameString()); if (colliderNodeConfig) { - const Physics::ShapeConfigurationList& colliders = colliderNodeConfig->m_shapes; + const AzPhysics::ShapeColliderPairList& colliders = colliderNodeConfig->m_shapes; ColliderContainerWidget::RenderColliders(colliders, actorInstance, joint, renderInfo, finalColor); } } diff --git a/Gems/EMotionFX/Code/Tests/ColliderCommandTests.cpp b/Gems/EMotionFX/Code/Tests/ColliderCommandTests.cpp index 0d81bc55b9..772ebad295 100644 --- a/Gems/EMotionFX/Code/Tests/ColliderCommandTests.cpp +++ b/Gems/EMotionFX/Code/Tests/ColliderCommandTests.cpp @@ -196,7 +196,7 @@ namespace EMotionFX ASSERT_TRUE(nodeConfig != nullptr); EXPECT_EQ(nodeConfig->m_shapes.size(), 1); - Physics::ShapeConfigurationPair& shapeConfigPair = nodeConfig->m_shapes[0]; + AzPhysics::ShapeColliderPair& shapeConfigPair = nodeConfig->m_shapes[0]; Physics::ColliderConfiguration* colliderConfig = shapeConfigPair.first.get(); Physics::ShapeConfiguration* shapeConfig = shapeConfigPair.second.get(); Physics::BoxShapeConfiguration* boxShapeConfig = azdynamic_cast(shapeConfig); diff --git a/Gems/EMotionFX/Code/Tests/PhysicsSetupUtils.cpp b/Gems/EMotionFX/Code/Tests/PhysicsSetupUtils.cpp index 9f13e3e34f..c201ae1f48 100644 --- a/Gems/EMotionFX/Code/Tests/PhysicsSetupUtils.cpp +++ b/Gems/EMotionFX/Code/Tests/PhysicsSetupUtils.cpp @@ -37,7 +37,7 @@ namespace EMotionFX else { // Count in only the given collider type. - for (const Physics::ShapeConfigurationPair& shapeConfigPair : nodeConfig.m_shapes) + for (const AzPhysics::ShapeColliderPair& shapeConfigPair : nodeConfig.m_shapes) { if (shapeConfigPair.second->GetShapeType() == shapeTypeToCount) { diff --git a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp index 251c178035..093c9dad22 100644 --- a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp +++ b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.cpp @@ -163,7 +163,7 @@ namespace ImGui void ImGuiLYAssetExplorer::ImGuiUpdate_DrawMenu() { - // Master on / off Switch + // Primary on / off Switch ImGui::Checkbox("Mesh Debug Enabled", &m_meshDebugEnabled); ImGui::SameLine(); diff --git a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.h b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.h index b5f8ea576c..04d87575fb 100644 --- a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.h +++ b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYAssetExplorer.h @@ -103,7 +103,7 @@ namespace ImGui void MeshInstanceList_CheckMeshFilter(); void MeshInstanceList_CheckEntityFilter(); - // The Master list of Meshes and Instances of them + // The Primary list of Meshes and Instances of them AZStd::list m_meshInstanceDisplayList; // Helper functions for the ImGui Update diff --git a/Gems/LyShine/Code/Source/UiTextComponent.cpp b/Gems/LyShine/Code/Source/UiTextComponent.cpp index 937f323b01..648013108b 100644 --- a/Gems/LyShine/Code/Source/UiTextComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTextComponent.cpp @@ -3568,13 +3568,14 @@ UiTextComponent::FontEffectComboBoxVec UiTextComponent::PopulateFontEffectList() FontEffectComboBoxVec result; AZStd::vector entityIdList; - // there is always a valid font since we default to "default-ui" - // so just get the effects from the font and add their names to the result list - unsigned int numEffects = m_font->GetNumEffects(); - for (int i = 0; i < numEffects; ++i) + if (m_font) { - const char* name = m_font->GetEffectName(i); - result.push_back(AZStd::make_pair(i, name)); + unsigned int numEffects = m_font->GetNumEffects(); + for (int i = 0; i < numEffects; ++i) + { + const char* name = m_font->GetEffectName(i); + result.push_back(AZStd::make_pair(i, name)); + } } return result; diff --git a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp index f63382ca6e..2c9d14dc94 100644 --- a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp +++ b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ActorClothColliders.cpp @@ -95,7 +95,7 @@ namespace NvCloth continue; } - for (const Physics::ShapeConfigurationPair& shapeConfigPair : clothNodeConfig.m_shapes) + for (const AzPhysics::ShapeColliderPair& shapeConfigPair : clothNodeConfig.m_shapes) { const auto& colliderConfig = shapeConfigPair.first; diff --git a/Gems/PhysX/Code/Include/PhysX/ColliderComponentBus.h b/Gems/PhysX/Code/Include/PhysX/ColliderComponentBus.h index fc06d69b4a..4b53ccec4e 100644 --- a/Gems/PhysX/Code/Include/PhysX/ColliderComponentBus.h +++ b/Gems/PhysX/Code/Include/PhysX/ColliderComponentBus.h @@ -30,7 +30,7 @@ namespace PhysX { public: //! Gets the collection of collider configuration / shape configuration pairs used to define the collider's shapes. - virtual Physics::ShapeConfigurationList GetShapeConfigurations() = 0; + virtual AzPhysics::ShapeColliderPairList GetShapeConfigurations() = 0; //! Gets the collection of physics shapes associated with the collider. virtual AZStd::vector> GetShapes() = 0; diff --git a/Gems/PhysX/Code/Include/PhysX/MeshAsset.h b/Gems/PhysX/Code/Include/PhysX/MeshAsset.h index 1af297edcc..8467c04359 100644 --- a/Gems/PhysX/Code/Include/PhysX/MeshAsset.h +++ b/Gems/PhysX/Code/Include/PhysX/MeshAsset.h @@ -58,7 +58,7 @@ namespace PhysX static constexpr AZ::u16 TriangleMeshMaterialIndex = (std::numeric_limits::max)(); using ShapeConfigurationPair = AZStd::pair, - AZStd::shared_ptr>; // Have to use shared_ptr here because Physics::ShapeConfigurationList uses it + AZStd::shared_ptr>; // Have to use shared_ptr here because AzPhysics::ShapeColliderPairList uses it using ShapeConfigurationList = AZStd::vector; ShapeConfigurationList m_colliderShapes; //!< Shapes data with optional collider configuration override. diff --git a/Gems/PhysX/Code/Source/BaseColliderComponent.cpp b/Gems/PhysX/Code/Source/BaseColliderComponent.cpp index c8581efcb7..57a37e5e88 100644 --- a/Gems/PhysX/Code/Source/BaseColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/BaseColliderComponent.cpp @@ -104,7 +104,7 @@ namespace PhysX } } - void BaseColliderComponent::SetShapeConfigurationList(const Physics::ShapeConfigurationList& shapeConfigList) + void BaseColliderComponent::SetShapeConfigurationList(const AzPhysics::ShapeColliderPairList& shapeConfigList) { if (GetEntity()->GetState() == AZ::Entity::State::Active) { @@ -115,7 +115,7 @@ namespace PhysX m_shapeConfigList = shapeConfigList; } - Physics::ShapeConfigurationList BaseColliderComponent::GetShapeConfigurations() + AzPhysics::ShapeColliderPairList BaseColliderComponent::GetShapeConfigurations() { return m_shapeConfigList; } @@ -319,7 +319,7 @@ namespace PhysX { AZ_Assert(IsMeshCollider(), "InitMeshCollider called for a non-mesh collider."); - const Physics::ShapeConfigurationPair& shapeConfigurationPair = *(m_shapeConfigList.begin()); + const AzPhysics::ShapeColliderPair& shapeConfigurationPair = *(m_shapeConfigList.begin()); const Physics::ColliderConfiguration& componentColliderConfiguration = *(shapeConfigurationPair.first.get()); const Physics::PhysicsAssetShapeConfiguration& physicsAssetConfiguration = *(static_cast(shapeConfigurationPair.second.get())); diff --git a/Gems/PhysX/Code/Source/BaseColliderComponent.h b/Gems/PhysX/Code/Source/BaseColliderComponent.h index b23e6f1f09..747ffe9d16 100644 --- a/Gems/PhysX/Code/Source/BaseColliderComponent.h +++ b/Gems/PhysX/Code/Source/BaseColliderComponent.h @@ -40,10 +40,10 @@ namespace PhysX BaseColliderComponent() = default; - void SetShapeConfigurationList(const Physics::ShapeConfigurationList& shapeConfigList); + void SetShapeConfigurationList(const AzPhysics::ShapeColliderPairList& shapeConfigList); // ColliderComponentRequestBus - Physics::ShapeConfigurationList GetShapeConfigurations() override; + AzPhysics::ShapeColliderPairList GetShapeConfigurations() override; AZStd::vector> GetShapes() override; // TransformNotificationsBus @@ -114,7 +114,7 @@ namespace PhysX virtual void UpdateScaleForShapeConfigs(); ShapeInfoCache m_shapeInfoCache; - Physics::ShapeConfigurationList m_shapeConfigList; + AzPhysics::ShapeColliderPairList m_shapeConfigList; private: bool InitShapes(); bool IsMeshCollider() const; diff --git a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp index 18bb06ba74..e9b9c41da3 100644 --- a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp @@ -312,6 +312,26 @@ namespace PhysX } } + AZStd::shared_ptr EditorProxyShapeConfig::CloneCurrent() const + { + switch (m_shapeType) + { + case Physics::ShapeType::Sphere: + return AZStd::make_shared(m_sphere); + case Physics::ShapeType::Capsule: + return AZStd::make_shared(m_capsule); + case Physics::ShapeType::PhysicsAsset: + return AZStd::make_shared(m_physicsAsset.m_configuration); + case Physics::ShapeType::CookedMesh: + return AZStd::make_shared(m_cookedMesh); + default: + AZ_Warning("EditorProxyShapeConfig", false, "Unsupported shape type, defaulting to Box."); + [[fallthrough]]; + case Physics::ShapeType::Box: + return AZStd::make_shared(m_box); + } + } + bool EditorProxyShapeConfig::ShowingSubdivisionLevel() const { return (m_hasNonUniformScale && (IsCapsuleConfig() || IsSphereConfig() || IsAssetConfig())); @@ -590,10 +610,6 @@ namespace PhysX configuration.m_entityId = GetEntityId(); configuration.m_debugName = GetEntity()->GetName(); - // This configuration needs to be at the scope of the function to be added - // to m_colliderAndShapeData as a pointer. - Physics::ColliderConfiguration colliderConfig; - if (m_shapeConfiguration.IsAssetConfig()) { AZStd::vector> shapes; @@ -603,13 +619,15 @@ namespace PhysX } else { - colliderConfig = GetColliderConfigurationScaled(); - Physics::ShapeConfiguration& shapeConfig = m_shapeConfiguration.GetCurrent(); + AZStd::shared_ptr colliderConfig = AZStd::make_shared( + GetColliderConfigurationScaled()); + AZStd::shared_ptr shapeConfig = m_shapeConfiguration.CloneCurrent(); + if (IsNonUniformlyScaledPrimitive(m_shapeConfiguration)) { - auto convexConfig = Utils::CreateConvexFromPrimitive(GetColliderConfiguration(), shapeConfig, - m_shapeConfiguration.m_subdivisionLevel, shapeConfig.m_scale); - auto colliderConfigurationNoOffset = colliderConfig; + auto convexConfig = Utils::CreateConvexFromPrimitive(GetColliderConfiguration(), *(shapeConfig.get()), + m_shapeConfiguration.m_subdivisionLevel, shapeConfig->m_scale); + Physics::ColliderConfiguration colliderConfigurationNoOffset = *colliderConfig; colliderConfigurationNoOffset.m_rotation = AZ::Quaternion::CreateIdentity(); colliderConfigurationNoOffset.m_position = AZ::Vector3::CreateZero(); @@ -622,7 +640,7 @@ namespace PhysX } else { - configuration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&colliderConfig, &shapeConfig); + configuration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig); } } @@ -805,7 +823,7 @@ namespace PhysX return; } - Physics::ShapeConfigurationList shapeConfigList; + AzPhysics::ShapeColliderPairList shapeConfigList; Utils::GetColliderShapeConfigsFromAsset(physicsAssetConfiguration, m_configuration, m_hasNonUniformScale, m_shapeConfiguration.m_subdivisionLevel, shapeConfigList); @@ -879,7 +897,7 @@ namespace PhysX const Physics::PhysicsAssetShapeConfiguration& physicsAssetConfiguration = m_shapeConfiguration.m_physicsAsset.m_configuration; - Physics::ShapeConfigurationList shapeConfigList; + AzPhysics::ShapeColliderPairList shapeConfigList; Utils::GetColliderShapeConfigsFromAsset(physicsAssetConfiguration, m_configuration, m_hasNonUniformScale, m_shapeConfiguration.m_subdivisionLevel, shapeConfigList); diff --git a/Gems/PhysX/Code/Source/EditorColliderComponent.h b/Gems/PhysX/Code/Source/EditorColliderComponent.h index 1f9c00d4f5..818de62a04 100644 --- a/Gems/PhysX/Code/Source/EditorColliderComponent.h +++ b/Gems/PhysX/Code/Source/EditorColliderComponent.h @@ -86,6 +86,8 @@ namespace PhysX Physics::ShapeConfiguration& GetCurrent(); const Physics::ShapeConfiguration& GetCurrent() const; + AZStd::shared_ptr CloneCurrent() const; + bool ShowingSubdivisionLevel() const; AZ::u32 OnConfigurationChanged(); diff --git a/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp index 82a38a04c2..379afc3f2d 100644 --- a/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp @@ -226,7 +226,7 @@ namespace PhysX void EditorShapeColliderComponent::BuildGameEntity(AZ::Entity* gameEntity) { auto* shapeColliderComponent = gameEntity->CreateComponent(); - Physics::ShapeConfigurationList shapeConfigurationList; + AzPhysics::ShapeColliderPairList shapeConfigurationList; shapeConfigurationList.reserve(m_shapeConfigs.size()); for (const auto& shapeConfig : m_shapeConfigs) { @@ -257,11 +257,12 @@ namespace PhysX configuration.m_entityId = GetEntityId(); configuration.m_debugName = GetEntity()->GetName(); - AZStd::vector colliderShapePairs; + AzPhysics::ShapeColliderPairList colliderShapePairs; colliderShapePairs.reserve(m_shapeConfigs.size()); for (const auto& shapeConfig : m_shapeConfigs) { - colliderShapePairs.emplace_back(&m_colliderConfig, shapeConfig.get()); + colliderShapePairs.emplace_back( + AZStd::make_shared(m_colliderConfig), shapeConfig); } configuration.m_colliderAndShapeData = colliderShapePairs; diff --git a/Gems/PhysX/Code/Source/Utils.cpp b/Gems/PhysX/Code/Source/Utils.cpp index 767f386b6f..a85426d532 100644 --- a/Gems/PhysX/Code/Source/Utils.cpp +++ b/Gems/PhysX/Code/Source/Utils.cpp @@ -770,7 +770,7 @@ namespace PhysX return worldPosAabb; } - Physics::ShapeConfigurationList colliderShapes; + AzPhysics::ShapeColliderPairList colliderShapes; GetColliderShapeConfigsFromAsset(physicsAssetConfig, colliderConfiguration, hasNonUniformScale, @@ -812,7 +812,7 @@ namespace PhysX void GetColliderShapeConfigsFromAsset(const Physics::PhysicsAssetShapeConfiguration& assetConfiguration, const Physics::ColliderConfiguration& originalColliderConfiguration, bool hasNonUniformScale, - AZ::u8 subdivisionLevel, Physics::ShapeConfigurationList& resultingColliderShapes) + AZ::u8 subdivisionLevel, AzPhysics::ShapeColliderPairList& resultingColliderShapes) { if (!assetConfiguration.m_asset.IsReady()) { @@ -896,13 +896,13 @@ namespace PhysX const Physics::ColliderConfiguration& originalColliderConfiguration, bool hasNonUniformScale, AZ::u8 subdivisionLevel, AZStd::vector>& resultingShapes) { - Physics::ShapeConfigurationList resultingColliderShapeConfigs; + AzPhysics::ShapeColliderPairList resultingColliderShapeConfigs; GetColliderShapeConfigsFromAsset(assetConfiguration, originalColliderConfiguration, hasNonUniformScale, subdivisionLevel, resultingColliderShapeConfigs); resultingShapes.reserve(resultingShapes.size() + resultingColliderShapeConfigs.size()); - for (const Physics::ShapeConfigurationPair& shapeConfigPair : resultingColliderShapeConfigs) + for (const AzPhysics::ShapeColliderPair& shapeConfigPair : resultingColliderShapeConfigs) { // Scale the collider offset shapeConfigPair.first->m_position *= shapeConfigPair.second->m_scale; diff --git a/Gems/PhysX/Code/Source/Utils.h b/Gems/PhysX/Code/Source/Utils.h index 2a8329b267..2885e86a09 100644 --- a/Gems/PhysX/Code/Source/Utils.h +++ b/Gems/PhysX/Code/Source/Utils.h @@ -179,7 +179,7 @@ namespace PhysX void GetColliderShapeConfigsFromAsset(const Physics::PhysicsAssetShapeConfiguration& assetConfiguration, const Physics::ColliderConfiguration& originalColliderConfiguration, - bool hasNonUniformScale, AZ::u8 subdivisionLevel, Physics::ShapeConfigurationList& resultingColliderShapes); + bool hasNonUniformScale, AZ::u8 subdivisionLevel, AzPhysics::ShapeColliderPairList& resultingColliderShapes); //! Gets the scale from the entity's Transform component. AZ::Vector3 GetTransformScale(AZ::EntityId entityId); diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarkWashingMachine.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarkWashingMachine.cpp index adc910e8c8..24fbfd742e 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarkWashingMachine.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarkWashingMachine.cpp @@ -13,6 +13,7 @@ #ifdef HAVE_BENCHMARK #include +#include #include #include #include @@ -96,9 +97,12 @@ namespace PhysX::Benchmarks config.m_position.SetY((cylinderRadius + halfCylinderWallThickness) * std::sin(AZ::Constants::TwoPi * i / NumCylinderSide) + position.GetY()); config.m_position.SetZ(z); config.m_orientation = AZ::Quaternion::CreateRotationZ(AZ::Constants::HalfPi + (cylinderTheta * i)); - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(cylinderRadius, cylinderWallThickness, cylinderHeight)); - config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&colliderConfig, &shapeConfiguration); + + auto shapeConfiguration = AZStd::make_shared( + AZ::Vector3(cylinderRadius, cylinderWallThickness, cylinderHeight)); + + config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), shapeConfiguration); m_cylinder[i] = scene->AddSimulatedBody(&config); } @@ -114,9 +118,9 @@ namespace PhysX::Benchmarks bladeRigidBodyConfig.m_position = position; bladeRigidBodyConfig.m_position.SetZ(position.GetZ() + (bladeHeight / 2.0f)); bladeRigidBodyConfig.m_orientation = AZ::Quaternion::CreateRotationZ(0.0f); - Physics::ColliderConfiguration bladeColliderConfig; - Physics::BoxShapeConfiguration bladeShapeConfiguration(AZ::Vector3(bladeLength, 1.0f, bladeHeight)); - bladeRigidBodyConfig.m_colliderAndShapeData = AZStd::make_pair(&bladeColliderConfig, &bladeShapeConfiguration); + auto bladeShapeConfiguration = AZStd::make_shared(AZ::Vector3(bladeLength, 1.0f, bladeHeight)); + bladeRigidBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), bladeShapeConfiguration); m_blade = scene->AddSimulatedBody(&bladeRigidBodyConfig); } diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.cpp index 1684dd4c7f..bc48b5fb92 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -34,9 +35,9 @@ namespace PhysX::Benchmarks AzPhysics::RigidBodyConfiguration rigidBodyConfig; rigidBodyConfig.m_ccdEnabled = enableCCD; - Physics::ColliderConfiguration rigidBodyColliderConfig; + auto rigidBodyColliderConfig = AZStd::make_shared(); - Physics::BoxShapeConfiguration defaultShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3::CreateOne()); + auto defaultShapeConfiguration = AZStd::make_shared(AZ::Vector3::CreateOne()); for (int i = 0; i < numRigidBodies; i++) { //call the optional function pointers, otherwise assign a default @@ -57,16 +58,16 @@ namespace PhysX::Benchmarks rigidBodyConfig.m_orientation = (*genSpawnOriFuncPtr)(i); } - Physics::ShapeConfiguration* shapeConfig = nullptr; + AZStd::shared_ptr shapeConfig = nullptr; if (genColliderFuncPtr != nullptr) { shapeConfig = (*genColliderFuncPtr)(i); } if (shapeConfig == nullptr) { - shapeConfig = &defaultShapeConfiguration; + shapeConfig = defaultShapeConfiguration; } - rigidBodyConfig.m_colliderAndShapeData = AZStd::make_pair(&rigidBodyColliderConfig, shapeConfig); + rigidBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(rigidBodyColliderConfig, shapeConfig); AzPhysics::SimulatedBodyHandle simBodyHandle = scene->AddSimulatedBody(&rigidBodyConfig); rigidBodies.push_back(simBodyHandle); diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.h b/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.h index ab9a0ba2ab..ab9bd58148 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.h +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXBenchmarksUtilities.h @@ -40,7 +40,7 @@ namespace PhysX::Benchmarks namespace Utils { //! Function pointer to allow Shape configuration customization rigid bodies created with Utils::CreateRigidBodies. int param is the id of the rigid body being created (values 0-N, where N=number requested to be created) - using GenerateColliderFuncPtr = AZStd::function; + using GenerateColliderFuncPtr = AZStd::function(int)>; //! Function pointer to allow spawn position customization rigid bodies created with Utils::CreateRigidBodies. int param is the id of the rigid body being created (values 0-N, where N=number requested to be created) using GenerateSpawnPositionFuncPtr = AZStd::function; //! Function pointer to allow spawn orientation customization rigid bodies created with Utils::CreateRigidBodies. int param is the id of the rigid body being created (values 0-N, where N=number requested to be created) diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp index 7d650d6bef..24b51f0085 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp @@ -136,9 +136,8 @@ namespace PhysX::Benchmarks { AZStd::vector joints; - Physics::ColliderConfiguration colliderConfig; - Physics::SphereShapeConfiguration shapeConfiguration = Physics::SphereShapeConfiguration(JointConstants::CreateJointDefaults::ColliderRadius); - AzPhysics::ShapeColliderPair shapeColliderConfig(&colliderConfig, &shapeConfiguration); + auto shapeConfiguration = AZStd::make_shared(JointConstants::CreateJointDefaults::ColliderRadius); + AzPhysics::ShapeColliderPair shapeColliderConfig(AZStd::make_shared(), shapeConfiguration); for (int i = 0; i < numJoints; i++) { JointGroup newJoint; @@ -340,13 +339,13 @@ namespace PhysX::Benchmarks const int numSegments = aznumeric_cast(state.range(0)); //create the collider shape config to use on the whole snake - Physics::SphereShapeConfiguration snakePartShapeConfiguration = Physics::SphereShapeConfiguration(JointConstants::CreateJointDefaults::ColliderRadius); - Physics::ColliderConfiguration snakeHeadcolliderConfig; + auto snakePartShapeConfiguration = AZStd::make_shared(JointConstants::CreateJointDefaults::ColliderRadius); //create the had of the snake this is the only static part. AzPhysics::StaticRigidBodyConfiguration snakeHeadBodyConfig; snakeHeadBodyConfig.m_position = AZ::Vector3::CreateZero(); - snakeHeadBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&snakeHeadcolliderConfig, &snakePartShapeConfiguration); + snakeHeadBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), snakePartShapeConfiguration); AzPhysics::SimulatedBody* snakeHead = nullptr; if (auto* sceneInterface = AZ::Interface::Get()) @@ -358,7 +357,7 @@ namespace PhysX::Benchmarks //create the body Utils::GenerateColliderFuncPtr colliderGenerator = [&snakePartShapeConfiguration]([[maybe_unused]] int idx) -> auto { - return &snakePartShapeConfiguration; + return snakePartShapeConfiguration; }; Utils::GenerateSpawnPositionFuncPtr posGenerator = [](int idx) -> auto { diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp index e295916554..7ad3061910 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp @@ -203,10 +203,10 @@ namespace PhysX::Benchmarks return AZ::Vector3(x, y, z); }; - Physics::BoxShapeConfiguration boxShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); - Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) -> Physics::ShapeConfiguration* + auto boxShapeConfiguration = AZStd::make_shared(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); + Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) { - return &boxShapeConfiguration; + return boxShapeConfiguration; }; //spawn the rigid bodies AzPhysics::SimulatedBodyHandleList rigidBodies = Utils::CreateRigidBodies(numRigidBodies, m_defaultScene, @@ -275,10 +275,10 @@ namespace PhysX::Benchmarks Utils::GenerateMassFuncPtr massGenerator = [&rand]([[maybe_unused]] int idx) -> float { return rand.GetRandomFloat() * 25.0f + 5.0f; }; - Physics::BoxShapeConfiguration boxShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); - Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) -> Physics::ShapeConfiguration* + auto boxShapeConfiguration = AZStd::make_shared(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); + Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) { - return &boxShapeConfiguration; + return boxShapeConfiguration; }; //spawn the rigid bodies AzPhysics::SimulatedBodyHandleList rigidBodies = Utils::CreateRigidBodies(numRigidBodies, m_defaultScene, @@ -408,10 +408,10 @@ namespace PhysX::Benchmarks Utils::GenerateEntityIdFuncPtr entityIdGenerator = [&rand](int idx) -> AZ::EntityId { return AZ::EntityId(static_cast(idx) + RigidBodyConstants::RigidBodys::RigidBodyEntityIdStart); }; - Physics::BoxShapeConfiguration boxShapeConfiguration = Physics::BoxShapeConfiguration(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); - Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) -> Physics::ShapeConfiguration* + auto boxShapeConfiguration = AZStd::make_shared(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); + Utils::GenerateColliderFuncPtr colliderGenerator = [&boxShapeConfiguration]([[maybe_unused]] int idx) { - return &boxShapeConfiguration; + return boxShapeConfiguration; }; //spawn the rigid bodies AzPhysics::SimulatedBodyHandleList rigidBodies = Utils::CreateRigidBodies(numRigidBodies, m_defaultScene, diff --git a/Gems/PhysX/Code/Tests/ColliderScalingTests.cpp b/Gems/PhysX/Code/Tests/ColliderScalingTests.cpp index ae65fcfc23..25747a55f6 100644 --- a/Gems/PhysX/Code/Tests/ColliderScalingTests.cpp +++ b/Gems/PhysX/Code/Tests/ColliderScalingTests.cpp @@ -30,7 +30,7 @@ namespace PhysXEditorTests PhysX::BaseColliderComponent* colliderComponent = gameEntity->FindComponent(); ASSERT_TRUE(colliderComponent != nullptr); - Physics::ShapeConfigurationList shapeConfigList = colliderComponent->GetShapeConfigurations(); + AzPhysics::ShapeColliderPairList shapeConfigList = colliderComponent->GetShapeConfigurations(); EXPECT_EQ(shapeConfigList.size(), 1); for (const auto& shapeConfigPair : shapeConfigList) diff --git a/Gems/PhysX/Code/Tests/PhysXGenericTest.cpp b/Gems/PhysX/Code/Tests/PhysXGenericTest.cpp index 45b1e469f4..7648871380 100644 --- a/Gems/PhysX/Code/Tests/PhysXGenericTest.cpp +++ b/Gems/PhysX/Code/Tests/PhysXGenericTest.cpp @@ -325,9 +325,10 @@ namespace PhysX // Box should start asleep AzPhysics::RigidBodyConfiguration config; config.m_startAsleep = true; - Physics::ColliderConfiguration colliderConfig; - Physics::SphereShapeConfiguration shapeConfiguration; - config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), + AZStd::make_shared() + ); AzPhysics::SimulatedBodyHandle rigidBodyHandle = sceneInterface->AddSimulatedBody(sceneHandle, &config); TestUtils::UpdateScene(sceneHandle, 1.0f / 60.0f, 100); diff --git a/Gems/PhysX/Code/Tests/PhysXGenericTestFixture.cpp b/Gems/PhysX/Code/Tests/PhysXGenericTestFixture.cpp index 5240cc06e6..9955cbbd97 100644 --- a/Gems/PhysX/Code/Tests/PhysXGenericTestFixture.cpp +++ b/Gems/PhysX/Code/Tests/PhysXGenericTestFixture.cpp @@ -104,12 +104,12 @@ namespace PhysX auto colliderConfig = AZStd::make_shared(); colliderConfig->m_collisionLayer = config.m_layer; - Physics::ShapeConfigurationList shapeconfigurationList; + AzPhysics::ShapeColliderPairList shapeconfigurationList; struct Visitor { AZStd::shared_ptr& colliderConfig; - Physics::ShapeConfigurationList& shapeconfigurationList; + AzPhysics::ShapeColliderPairList& shapeconfigurationList; void operator()(const MultiShapeConfig::ShapeList::ShapeData::Box& box) const { diff --git a/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp b/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp index 2a38e1b867..9514f6908e 100644 --- a/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp @@ -83,10 +83,10 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); //add a static rigid body - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); AzPhysics::StaticRigidBodyConfiguration config; - config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &config); EXPECT_FALSE(simBodyHandle == AzPhysics::InvalidSimulatedBodyHandle); } @@ -104,14 +104,15 @@ namespace PhysX EXPECT_TRUE(emptyBodies.empty()); //add some rigid bodies - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); + AzPhysics::ShapeColliderPair shapeColliderData( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); constexpr const int numberOfBodies = 100; for (int i = 0; i < numberOfBodies; i++) { const float xpos = 2.0f * static_cast(i); AzPhysics::RigidBodyConfiguration* config = aznew AzPhysics::RigidBodyConfiguration(); - config->m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config->m_colliderAndShapeData = shapeColliderData; config->m_position = AZ::Vector3::CreateAxisX(xpos); configs.emplace_back(config); } @@ -150,15 +151,16 @@ namespace PhysX AzPhysics::SimulatedBodyConfigurationList configs; //add some rigid bodies - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); - + AzPhysics::ShapeColliderPair shapeColliderData( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); + constexpr const int numberOfBodies = 100; for (int i = 0; i < numberOfBodies; i++) { const float xpos = 2.0f * static_cast(i); AzPhysics::RigidBodyConfiguration* config = aznew AzPhysics::RigidBodyConfiguration(); - config->m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config->m_colliderAndShapeData = shapeColliderData; config->m_position = AZ::Vector3::CreateAxisX(xpos); configs.emplace_back(config); } @@ -205,10 +207,11 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); //add a simulated body - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); + AzPhysics::ShapeColliderPair shapeColliderData( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); AzPhysics::StaticRigidBodyConfiguration config; - config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config.m_colliderAndShapeData = shapeColliderData; AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &config); //remove the body @@ -223,10 +226,11 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); //add a few simulated body - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); + AzPhysics::ShapeColliderPair shapeColliderData( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); AzPhysics::StaticRigidBodyConfiguration config; - config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config.m_colliderAndShapeData = shapeColliderData; AzPhysics::SimulatedBodyHandleList simBodyHandles; constexpr const int numBodies = 10; @@ -281,10 +285,11 @@ namespace PhysX sceneInterface->RegisterSimulationBodyRemovedHandler(m_testSceneHandle, removedEvent); //add a simulated body - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); + AzPhysics::ShapeColliderPair shapeColliderData( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); AzPhysics::StaticRigidBodyConfiguration config; - config.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + config.m_colliderAndShapeData = shapeColliderData; AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &config); EXPECT_TRUE(addTriggered); @@ -552,17 +557,18 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); // setup shape config - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(1.0f, 1.0f, 1.0f)); + AzPhysics::ShapeColliderPair shapeColliderData( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3::CreateOne())); // add a static simulated body - this is not expected to be reported as an active actor AzPhysics::StaticRigidBodyConfiguration staticConfig; - staticConfig.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + staticConfig.m_colliderAndShapeData = shapeColliderData; AzPhysics::SimulatedBodyHandle staticSphereHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &staticConfig); // add a rigid body - this is expect to be reported as an active actor AzPhysics::RigidBodyConfiguration rigidConfig; - rigidConfig.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + rigidConfig.m_colliderAndShapeData = shapeColliderData; AzPhysics::SimulatedBodyHandle rigidSphereHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &rigidConfig); // create + register the active handler diff --git a/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp b/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp index 74c88d0b46..98ee82f11a 100644 --- a/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp @@ -539,14 +539,14 @@ namespace PhysX TEST_F(PhysXSpecificTest, RigidBody_CenterOfMassOffsetComputed) { AZ::Vector3 halfExtents(1.0f, 2.0f, 3.0f); - Physics::BoxShapeConfiguration shapeConfig(halfExtents * 2.0f); - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi); + auto shapeConfig = AZStd::make_shared(halfExtents * 2.0f); + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi); AzPhysics::RigidBodyConfiguration rigidBodyConfiguration; rigidBodyConfiguration.m_computeCenterOfMass = true; rigidBodyConfiguration.m_computeInertiaTensor = true; - rigidBodyConfiguration.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig); + rigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig); AzPhysics::RigidBody* rigidBody = nullptr; if (auto* sceneInterface = AZ::Interface::Get()) { @@ -562,15 +562,15 @@ namespace PhysX TEST_F(PhysXSpecificTest, RigidBody_CenterOfMassOffsetSpecified) { AZ::Vector3 halfExtents(1.0f, 2.0f, 3.0f); - Physics::BoxShapeConfiguration shapeConfig(halfExtents * 2.0f); - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi); + auto shapeConfig = AZStd::make_shared(halfExtents * 2.0f); + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi); AzPhysics::RigidBodyConfiguration rigidBodyConfiguration; rigidBodyConfiguration.m_computeCenterOfMass = false; rigidBodyConfiguration.m_centerOfMassOffset = AZ::Vector3::CreateOne(); rigidBodyConfiguration.m_computeInertiaTensor = true; - rigidBodyConfiguration.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig); + rigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig); AzPhysics::RigidBody* rigidBody = nullptr; if (auto* sceneInterface = AZ::Interface::Get()) @@ -1113,15 +1113,15 @@ namespace PhysX auto CreateBoxRigidBody = [this](const AZ::Vector3& position, bool simulatedFlag, bool triggerFlag) -> AzPhysics::RigidBody* { - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_isSimulated = simulatedFlag; - colliderConfig.m_isTrigger = triggerFlag; - Physics::BoxShapeConfiguration shapeConfig; + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_isSimulated = simulatedFlag; + colliderConfig->m_isTrigger = triggerFlag; AzPhysics::RigidBodyConfiguration rigidBodyConfig; rigidBodyConfig.m_entityId = AZ::EntityId(0); // Set entity ID to avoid warnings in OnTriggerEnter rigidBodyConfig.m_position = position; - rigidBodyConfig.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig); + rigidBodyConfig.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + colliderConfig, AZStd::make_shared()); if (auto* sceneInterface = AZ::Interface::Get()) { diff --git a/Gems/PhysX/Code/Tests/PhysXTestCommon.cpp b/Gems/PhysX/Code/Tests/PhysXTestCommon.cpp index 93ad7704c9..b4e5410981 100644 --- a/Gems/PhysX/Code/Tests/PhysXTestCommon.cpp +++ b/Gems/PhysX/Code/Tests/PhysXTestCommon.cpp @@ -107,7 +107,7 @@ namespace PhysX auto shapeConfig = AZStd::make_shared(radius); auto shpereColliderComponent = entity->CreateComponent(); - shpereColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) }); + shpereColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) }); AzPhysics::RigidBodyConfiguration rigidBodyConfig; rigidBodyConfig.m_computeMass = false; @@ -136,7 +136,7 @@ namespace PhysX colliderConfig->m_collisionLayer = layer; auto shapeConfig = AZStd::make_shared(radius); auto sphereColliderComponent = entity->CreateComponent(); - sphereColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) }); + sphereColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) }); entity->CreateComponent(sceneHandle); @@ -171,7 +171,7 @@ namespace PhysX auto boxColliderComponent = entity->CreateComponent(); auto colliderConfig = AZStd::make_shared(); colliderConfig->m_collisionLayer = layer; - boxColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) }); + boxColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) }); entity->CreateComponent(sceneHandle); entity->Activate(); return entity; @@ -195,7 +195,7 @@ namespace PhysX colliderConfig->m_collisionLayer = layer; auto shapeConfig = AZStd::make_shared(height, radius); auto capsuleColliderComponent = entity->CreateComponent(); - capsuleColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) }); + capsuleColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) }); AzPhysics::RigidBodyConfiguration rigidBodyConfig; rigidBodyConfig.m_computeMass = false; @@ -223,7 +223,7 @@ namespace PhysX colliderConfig->m_collisionLayer = layer; auto shapeConfig = AZStd::make_shared(height, radius); auto capsuleColliderComponent = entity->CreateComponent(); - capsuleColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) }); + capsuleColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) }); entity->CreateComponent(sceneHandle); @@ -244,14 +244,13 @@ namespace PhysX AZ_Assert(cookingResult, "Failed to cook the cube mesh."); // Setup shape & collider configurations - Physics::CookedMeshShapeConfiguration shapeConfig; - shapeConfig.SetCookedMeshData(cookedData.data(), cookedData.size(), + auto shapeConfig = AZStd::make_shared(); + shapeConfig->SetCookedMeshData(cookedData.data(), cookedData.size(), Physics::CookedMeshShapeConfiguration::MeshType::TriangleMesh); - Physics::ColliderConfiguration colliderConfig; - AzPhysics::StaticRigidBodyConfiguration staticRigidBodyConfiguration; - staticRigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&colliderConfig, &shapeConfig); + staticRigidBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), shapeConfig); if (auto* sceneInterface = AZ::Interface::Get()) { @@ -290,7 +289,7 @@ namespace PhysX auto shapeConfig = AZStd::make_shared(dimensions); auto boxColliderComponent = entity->CreateComponent(); - boxColliderComponent->SetShapeConfigurationList({ AZStd::make_pair(colliderConfig, shapeConfig) }); + boxColliderComponent->SetShapeConfigurationList({ AzPhysics::ShapeColliderPair(colliderConfig, shapeConfig) }); AzPhysics::RigidBodyConfiguration rigidBodyConfig; rigidBodyConfig.m_computeMass = false; @@ -307,7 +306,7 @@ namespace PhysX AZ::TransformConfig transformConfig; transformConfig.m_worldTransform = AZ::Transform::CreateTranslation(position); entity->CreateComponent()->SetConfiguration(transformConfig); - Physics::ShapeConfigurationList shapeConfigList = { AZStd::make_pair( + AzPhysics::ShapeColliderPairList shapeConfigList = { AzPhysics::ShapeColliderPair( AZStd::make_shared(), AZStd::make_shared()) }; auto boxCollider = entity->CreateComponent(); @@ -371,10 +370,10 @@ namespace PhysX AzPhysics::StaticRigidBody* AddStaticFloorToScene(AzPhysics::SceneHandle sceneHandle, const AZ::Transform& transform) { - Physics::ColliderConfiguration colliderConfig; - Physics::BoxShapeConfiguration shapeConfiguration(AZ::Vector3(20.0f, 20.0f, 1.0f)); AzPhysics::StaticRigidBodyConfiguration staticBodyConfiguration; - staticBodyConfiguration.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + staticBodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(), + AZStd::make_shared(AZ::Vector3(20.0f, 20.0f, 1.0f))); if (auto* sceneInterface = AZ::Interface::Get()) { AzPhysics::SimulatedBodyHandle simBodyHandle = sceneInterface->AddSimulatedBody(sceneHandle, &staticBodyConfiguration); @@ -410,10 +409,10 @@ namespace PhysX AzPhysics::SimulatedBodyHandle AddSphereToScene(AzPhysics::SceneHandle sceneHandle, const AZ::Vector3& position, const float radius /*= 0.5f*/, const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/) { - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_collisionLayer = layer; - Physics::SphereShapeConfiguration shapeConfiguration; - shapeConfiguration.m_radius = radius; + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_collisionLayer = layer; + auto shapeConfiguration = AZStd::make_shared(); + shapeConfiguration->m_radius = radius; AzPhysics::RigidBodyConfiguration rigidBodySettings; rigidBodySettings.m_computeMass = false; rigidBodySettings.m_computeInertiaTensor = false; @@ -421,7 +420,7 @@ namespace PhysX rigidBodySettings.m_mass = 1.0f; rigidBodySettings.m_position = position; rigidBodySettings.m_linearDamping = 0.0f; - rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfiguration); if (auto* sceneInterface = AZ::Interface::Get()) { @@ -435,11 +434,12 @@ namespace PhysX const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/) { AzPhysics::RigidBodyConfiguration rigidBodySettings; - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_collisionLayer = layer; - colliderConfig.m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi); - Physics::CapsuleShapeConfiguration shapeConfig(height, radius); - rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfig); + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_collisionLayer = layer; + colliderConfig->m_rotation = AZ::Quaternion::CreateRotationX(AZ::Constants::HalfPi); + + rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, + AZStd::make_shared(height, radius)); rigidBodySettings.m_position = position; rigidBodySettings.m_computeMass = false; rigidBodySettings.m_computeInertiaTensor = false; @@ -457,10 +457,10 @@ namespace PhysX const AZ::Vector3& position, const AZ::Vector3& dimensions /*= AZ::Vector3(1.0f)*/, const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/) { - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_collisionLayer = layer; - Physics::BoxShapeConfiguration shapeConfiguration; - shapeConfiguration.m_dimensions = dimensions; + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_collisionLayer = layer; + auto shapeConfiguration = AZStd::make_shared(); + shapeConfiguration->m_dimensions = dimensions; AzPhysics::RigidBodyConfiguration rigidBodySettings; rigidBodySettings.m_computeMass = false; @@ -469,7 +469,7 @@ namespace PhysX rigidBodySettings.m_mass = 1.0f; rigidBodySettings.m_position = position; rigidBodySettings.m_linearDamping = 0.0f; - rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfiguration); if (auto* sceneInterface = AZ::Interface::Get()) { return sceneInterface->AddSimulatedBody(sceneHandle, &rigidBodySettings); @@ -481,13 +481,14 @@ namespace PhysX const AZ::Vector3& position, const AZ::Vector3& dimensions /*= AZ::Vector3(1.0f)*/, const AzPhysics::CollisionLayer& layer /*= AzPhysics::CollisionLayer::Default*/) { - Physics::ColliderConfiguration colliderConfig; - colliderConfig.m_collisionLayer = layer; - Physics::BoxShapeConfiguration shapeConfiguration; - shapeConfiguration.m_dimensions = dimensions; + auto colliderConfig = AZStd::make_shared(); + colliderConfig->m_collisionLayer = layer; + auto shapeConfiguration = AZStd::make_shared(); + shapeConfiguration->m_dimensions = dimensions; + AzPhysics::StaticRigidBodyConfiguration rigidBodySettings; rigidBodySettings.m_position = position; - rigidBodySettings.m_colliderAndShapeData = AZStd::make_pair(&colliderConfig, &shapeConfiguration); + rigidBodySettings.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(colliderConfig, shapeConfiguration); if (auto* sceneInterface = AZ::Interface::Get()) { diff --git a/Gems/QtForPython/Code/CMakeLists.txt b/Gems/QtForPython/Code/CMakeLists.txt index 413e542c9f..74c660043f 100644 --- a/Gems/QtForPython/Code/CMakeLists.txt +++ b/Gems/QtForPython/Code/CMakeLists.txt @@ -23,6 +23,7 @@ endif() ly_add_target( NAME QtForPython.Editor.Static STATIC NAMESPACE Gem + find_package(Qt) FILES_CMAKE qtforpython_editor_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake PLATFORM_INCLUDE_FILES @@ -40,6 +41,7 @@ ly_add_target( Gem::EditorPythonBindings.Static RUNTIME_DEPENDENCIES 3rdParty::pyside2 + Qt5::Test ) ly_add_target( diff --git a/Gems/WhiteBox/Code/Source/Components/EditorWhiteBoxColliderComponent.cpp b/Gems/WhiteBox/Code/Source/Components/EditorWhiteBoxColliderComponent.cpp index c8b189942e..d7acb18f29 100644 --- a/Gems/WhiteBox/Code/Source/Components/EditorWhiteBoxColliderComponent.cpp +++ b/Gems/WhiteBox/Code/Source/Components/EditorWhiteBoxColliderComponent.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -150,7 +151,9 @@ namespace WhiteBox bodyConfiguration.m_entityId = GetEntityId(); bodyConfiguration.m_orientation = GetTransform()->GetWorldRotationQuaternion(); bodyConfiguration.m_position = GetTransform()->GetWorldTranslation(); - bodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair(&m_physicsColliderConfiguration, &m_meshShapeConfiguration); + bodyConfiguration.m_colliderAndShapeData = AzPhysics::ShapeColliderPair( + AZStd::make_shared(m_physicsColliderConfiguration), + AZStd::make_shared(m_meshShapeConfiguration)); if (m_sceneInterface) { diff --git a/cmake/Tools/layout_tool.py b/cmake/Tools/layout_tool.py index 82d10f412f..8f573b61f5 100755 --- a/cmake/Tools/layout_tool.py +++ b/cmake/Tools/layout_tool.py @@ -333,7 +333,9 @@ def create_link(src:pathlib.Path, tgt:pathlib.Path, copy): import _winapi _winapi.CreateJunction(str(src), str(tgt)) else: - src.symlink_to(tgt, target_is_directory=True) + if tgt.exists(): + tgt.unlink() + tgt.symlink_to(src, target_is_directory=True) except OSError as e: raise common.LmbrCmdError(f"Error trying to create {link_type} {src} => {tgt} : {e}", e.errno)