diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp index 043f864245..54e7f7608c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp @@ -650,7 +650,10 @@ namespace AzToolsFramework AZStd::unique_ptr Instance::DetachContainerEntity() { - m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId()); + if (m_containerEntity) + { + m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId()); + } return AZStd::move(m_containerEntity); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp index c455873036..7b7107ae3e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabCatchmentProcessor.cpp @@ -65,16 +65,24 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils AzFramework::Spawnable::EntityList& entities = spawnable->GetEntities(); for (auto it = entities.begin(); it != entities.end(); ) { - (*it)->InvalidateDependencies(); - AZ::Entity::DependencySortOutcome evaluation = (*it)->EvaluateDependenciesGetDetails(); - if (evaluation.IsSuccess()) + if (*it) { - ++it; + (*it)->InvalidateDependencies(); + AZ::Entity::DependencySortOutcome evaluation = (*it)->EvaluateDependenciesGetDetails(); + if (evaluation.IsSuccess()) + { + ++it; + } + else + { + AZ_Error( + "Prefabs", false, "Entity '%s' %s cannot be activated for the following reason: %s", (*it)->GetName().c_str(), + (*it)->GetId().ToString().c_str(), evaluation.GetError().m_message.c_str()); + it = entities.erase(it); + } } else { - AZ_Error("Prefabs", false, "Entity '%s' %s cannot be activated for the following reason: %s", - (*it)->GetName().c_str(), (*it)->GetId().ToString().c_str(), evaluation.GetError().m_message.c_str()); it = entities.erase(it); } } diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp index 4eef54669a..35064bf4a4 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace SurfaceData { @@ -20,7 +19,6 @@ namespace SurfaceData SurfaceDataSystemComponent::CreateDescriptor(), SurfaceDataColliderComponent::CreateDescriptor(), SurfaceDataShapeComponent::CreateDescriptor(), - Terrain::TerrainSurfaceDataSystemComponent::CreateDescriptor(), }); } @@ -28,7 +26,6 @@ namespace SurfaceData { return AZ::ComponentTypeList{ azrtti_typeid(), - azrtti_typeid(), }; } } diff --git a/Gems/SurfaceData/Code/surfacedata_files.cmake b/Gems/SurfaceData/Code/surfacedata_files.cmake index 487dcb70e5..4b8ac914d7 100644 --- a/Gems/SurfaceData/Code/surfacedata_files.cmake +++ b/Gems/SurfaceData/Code/surfacedata_files.cmake @@ -19,8 +19,6 @@ set(FILES Include/SurfaceData/Utility/SurfaceDataUtility.h Source/SurfaceDataSystemComponent.cpp Source/SurfaceDataSystemComponent.h - Source/TerrainSurfaceDataSystemComponent.cpp - Source/TerrainSurfaceDataSystemComponent.h Source/SurfaceTag.cpp Source/Components/SurfaceDataColliderComponent.cpp Source/Components/SurfaceDataColliderComponent.h diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg new file mode 100644 index 0000000000..57835e9c20 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainHeight.svg @@ -0,0 +1,7 @@ + + + icon / Environmental / Terrain Height + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg new file mode 100644 index 0000000000..fb9590ae7b --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerRenderer.svg @@ -0,0 +1,7 @@ + + + icon / Environmental / Terrain Mesh + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg new file mode 100644 index 0000000000..df73d78276 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainLayerSpawner.svg @@ -0,0 +1,7 @@ + + + icon / Environmental / Generate Terrian + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg new file mode 100644 index 0000000000..c6388d6215 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorld.svg @@ -0,0 +1,8 @@ + + + icon / Environmental / Terrain Refactor + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg new file mode 100644 index 0000000000..bd1512afda --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldDebugger.svg @@ -0,0 +1,8 @@ + + + icon / Environmental / Terrain World Debugger + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg new file mode 100644 index 0000000000..ab3716ad5d --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/TerrainWorldRenderer.svg @@ -0,0 +1,8 @@ + + + icon / Environmental / Terrain World Renderer + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg new file mode 100644 index 0000000000..b87a0b4d7e --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainHeight.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain Height - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg new file mode 100644 index 0000000000..521d56784c --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerRenderer.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain Mesh - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg new file mode 100644 index 0000000000..c078d32fe5 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainLayerSpawner.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Generate Terrian - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg new file mode 100644 index 0000000000..2aee65f2a8 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorld.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain Refactor - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg new file mode 100644 index 0000000000..1b729ab73f --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldDebugger.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain World Debugger - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg new file mode 100644 index 0000000000..4287508f10 --- /dev/null +++ b/Gems/Terrain/Assets/Editor/Icons/Components/Viewport/TerrainWorldRenderer.svg @@ -0,0 +1,25 @@ + + + icon / Environmental / Terrain World Renderer - box + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gems/Terrain/CMakeLists.txt b/Gems/Terrain/CMakeLists.txt new file mode 100644 index 0000000000..34bce0825f --- /dev/null +++ b/Gems/Terrain/CMakeLists.txt @@ -0,0 +1,8 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +add_subdirectory(Code) diff --git a/Gems/Terrain/Code/CMakeLists.txt b/Gems/Terrain/Code/CMakeLists.txt new file mode 100644 index 0000000000..f40dd17ede --- /dev/null +++ b/Gems/Terrain/Code/CMakeLists.txt @@ -0,0 +1,139 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +ly_add_target( + NAME Terrain.Static STATIC + NAMESPACE Gem + FILES_CMAKE + terrain_files.cmake + INCLUDE_DIRECTORIES + PUBLIC + Include + PRIVATE + Source + BUILD_DEPENDENCIES + PUBLIC + AZ::AzCore + AZ::AzFramework + Gem::Atom_RPI.Public + Gem::Atom_Utils.Static + Gem::GradientSignal + Gem::SurfaceData + Gem::LmbrCentral +) + +ly_add_target( + NAME Terrain ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE} + NAMESPACE Gem + FILES_CMAKE + terrain_shared_files.cmake + INCLUDE_DIRECTORIES + PUBLIC + Include + PRIVATE + Source + BUILD_DEPENDENCIES + PRIVATE + Gem::Terrain.Static + Gem::LmbrCentral + RUNTIME_DEPENDENCIES + Gem::LmbrCentral +) + +# the above module is for use in all client/server types +ly_create_alias(NAME Terrain.Servers NAMESPACE Gem TARGETS Gem::Terrain) +ly_create_alias(NAME Terrain.Clients NAMESPACE Gem TARGETS Gem::Terrain) + +# If we are on a host platform, we want to add the host tools targets like the Terrain.Editor target which +# will also depend on Terrain.Static +if(PAL_TRAIT_BUILD_HOST_TOOLS) + ly_add_target( + NAME Terrain.Editor MODULE + NAMESPACE Gem + AUTOMOC + OUTPUT_NAME Gem.Terrain.Editor + FILES_CMAKE + terrain_editor_shared_files.cmake + COMPILE_DEFINITIONS + PRIVATE + TERRAIN_EDITOR + INCLUDE_DIRECTORIES + PRIVATE + Source + PUBLIC + Include + BUILD_DEPENDENCIES + PUBLIC + AZ::AzToolsFramework + Gem::GradientSignal + Gem::LmbrCentral + Gem::Terrain.Static + ) + + # the above module is for use in dev tool situations + ly_create_alias(NAME Terrain.Builders NAMESPACE Gem TARGETS Gem::Terrain.Editor) + ly_create_alias(NAME Terrain.Tools NAMESPACE Gem TARGETS Gem::Terrain.Editor) +endif() + +################################################################################ +# Tests +################################################################################ +# See if globally, tests are supported +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) + # We globally support tests, see if we support tests on this platform for Terrain.Static + if(PAL_TRAIT_TERRAIN_TEST_SUPPORTED) + # We support Terrain.Tests on this platform, add Terrain.Tests target which depends on Terrain.Static + ly_add_target( + NAME Terrain.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + terrain_files.cmake + terrain_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + AZ::AzFramework + Gem::Terrain.Static + ) + + # Add Terrain.Tests to googletest + ly_add_googletest( + NAME Gem::Terrain.Tests + ) + endif() + + # If we are a host platform we want to add tools test like editor tests here + if(PAL_TRAIT_BUILD_HOST_TOOLS) + # We are a host platform, see if Editor tests are supported on this platform + if(PAL_TRAIT_TERRAIN_EDITOR_TEST_SUPPORTED) + # We support Terrain.Editor.Tests on this platform, add Terrain.Editor.Tests target which depends on Terrain.Editor + ly_add_target( + NAME Terrain.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + terrain_editor_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + Gem::Terrain.Editor + ) + + # Add Terrain.Editor.Tests to googletest + ly_add_googletest( + NAME Gem::Terrain.Editor.Tests + ) + endif() + endif() +endif() diff --git a/Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.cpp similarity index 96% rename from Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.cpp rename to Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.cpp index a60bbc4034..04c94b24d6 100644 --- a/Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.cpp +++ b/Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.cpp @@ -6,7 +6,7 @@ * */ -#include +#include #include #include #include @@ -58,7 +58,7 @@ namespace Terrain editContext->Class("Terrain Surface Data System", "Manages surface data requests against legacy terrain") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::Category, "Surface Data") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b)) + ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("System")) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement(0, &TerrainSurfaceDataSystemComponent::m_configuration, "Configuration", "") ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) @@ -78,18 +78,18 @@ namespace Terrain void TerrainSurfaceDataSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("SurfaceDataProviderService", 0xfe9fb95e)); - services.push_back(AZ_CRC("TerrainSurfaceDataProviderService", 0xa1ac7717)); + services.push_back(AZ_CRC_CE("SurfaceDataProviderService")); + services.push_back(AZ_CRC_CE("TerrainSurfaceDataProviderService")); } void TerrainSurfaceDataSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("TerrainSurfaceDataProviderService", 0xa1ac7717)); + services.push_back(AZ_CRC_CE("TerrainSurfaceDataProviderService")); } void TerrainSurfaceDataSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("SurfaceDataSystemService", 0x1d44d25f)); + services.push_back(AZ_CRC_CE("SurfaceDataSystemService")); } void TerrainSurfaceDataSystemComponent::Activate() diff --git a/Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.h b/Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.h similarity index 100% rename from Gems/SurfaceData/Code/Source/TerrainSurfaceDataSystemComponent.h rename to Gems/Terrain/Code/Source/Components/TerrainSurfaceDataSystemComponent.h diff --git a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp new file mode 100644 index 0000000000..dea7babbbc --- /dev/null +++ b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + + +#include + +#include +#include +#include + +#include + +namespace Terrain +{ + void TerrainSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serialize = azrtti_cast(context)) + { + serialize->Class() + ->Version(0); + + if (AZ::EditContext* ec = serialize->GetEditContext()) + { + ec->Class("Terrain", "The Terrain System Component enables Terrain.") + ->ClassElement(AZ::Edit::ClassElements::EditorData, "") + ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("System")) + ->Attribute(AZ::Edit::Attributes::AutoExpand, true) + ; + } + } + } + + void TerrainSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("TerrainService")); + } + + void TerrainSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) + { + incompatible.push_back(AZ_CRC_CE("TerrainService")); + } + + void TerrainSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) + { + required.push_back(AZ_CRC_CE("RPISystem")); + } + + void TerrainSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent) + { + } + + void TerrainSystemComponent::Init() + { + } + + void TerrainSystemComponent::Activate() + { + } + + void TerrainSystemComponent::Deactivate() + { + } +} diff --git a/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h new file mode 100644 index 0000000000..b294c0473a --- /dev/null +++ b/Gems/Terrain/Code/Source/Components/TerrainSystemComponent.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace Terrain +{ + class TerrainSystem; + + class TerrainSystemComponent + : public AZ::Component + { + public: + AZ_COMPONENT(TerrainSystemComponent, "{CD5A517E-3BD8-49AE-8F9B-33C6FC47EC67}"); + + static void Reflect(AZ::ReflectContext* context); + + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); + static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); + static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); + static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent); + + protected: + //////////////////////////////////////////////////////////////////////// + // AZ::Component interface implementation + void Init() override; + void Activate() override; + void Deactivate() override; + //////////////////////////////////////////////////////////////////////// + + TerrainSystem* m_terrainSystem{ nullptr }; + }; +} diff --git a/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp new file mode 100644 index 0000000000..7fa35cc81c --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +namespace Terrain +{ + void EditorTerrainSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (auto serializeContext = azrtti_cast(context)) + { + serializeContext->Class()->Version(1); + } + } + + void EditorTerrainSystemComponent::Activate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusConnect(); + } + + void EditorTerrainSystemComponent::Deactivate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect(); + } + +} // namespace Terrain diff --git a/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h new file mode 100644 index 0000000000..274e561ace --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorComponents/EditorTerrainSystemComponent.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +#include + +namespace Terrain +{ + /// System component for Terrain editor + class EditorTerrainSystemComponent + : public AZ::Component + , private AzToolsFramework::EditorEvents::Bus::Handler + { + public: + AZ_COMPONENT(EditorTerrainSystemComponent, "{5E9f2200-9099-4325-BABD-6A533A1ABEA8}"); + static void Reflect(AZ::ReflectContext* context); + + EditorTerrainSystemComponent() = default; + + private: + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("TerrainEditorService")); + } + + static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) + { + required.push_back(AZ_CRC_CE("TerrainService")); + } + + // AZ::Component + void Activate() override; + void Deactivate() override; + }; +} // namespace Terrain diff --git a/Gems/Terrain/Code/Source/EditorTerrainModule.cpp b/Gems/Terrain/Code/Source/EditorTerrainModule.cpp new file mode 100644 index 0000000000..bd4c94f4bf --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorTerrainModule.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +namespace Terrain +{ + EditorTerrainModule::EditorTerrainModule() + { + m_descriptors.insert( + m_descriptors.end(), + { + Terrain::EditorTerrainSystemComponent::CreateDescriptor(), + }); + } + + AZ::ComponentTypeList EditorTerrainModule::GetRequiredSystemComponents() const + { + AZ::ComponentTypeList requiredComponents = TerrainModule::GetRequiredSystemComponents(); + requiredComponents.insert( + requiredComponents.end(), + { + azrtti_typeid(), + }); + + return requiredComponents; + } +} + +AZ_DECLARE_MODULE_CLASS(Gem_TerrainEditor, Terrain::EditorTerrainModule) diff --git a/Gems/Terrain/Code/Source/EditorTerrainModule.h b/Gems/Terrain/Code/Source/EditorTerrainModule.h new file mode 100644 index 0000000000..76c4706478 --- /dev/null +++ b/Gems/Terrain/Code/Source/EditorTerrainModule.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace Terrain +{ + class EditorTerrainModule + : public TerrainModule + { + public: + AZ_RTTI(EditorTerrainModule, "{68693F28-7051-4C14-85EA-DE6FD8CFCBD6}", TerrainModule); + AZ_CLASS_ALLOCATOR(EditorTerrainModule, AZ::SystemAllocator, 0); + + EditorTerrainModule(); + + AZ::ComponentTypeList GetRequiredSystemComponents() const override; + }; +} diff --git a/Gems/Terrain/Code/Source/TerrainModule.cpp b/Gems/Terrain/Code/Source/TerrainModule.cpp new file mode 100644 index 0000000000..ec9325eb5c --- /dev/null +++ b/Gems/Terrain/Code/Source/TerrainModule.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +#include +#include +#include + +namespace Terrain +{ + TerrainModule::TerrainModule() + : AZ::Module() + { + m_descriptors.insert(m_descriptors.end(), { + TerrainSystemComponent::CreateDescriptor(), + TerrainSurfaceDataSystemComponent::CreateDescriptor(), + }); + } + + AZ::ComponentTypeList TerrainModule::GetRequiredSystemComponents() const + { + return AZ::ComponentTypeList{ + azrtti_typeid(), + azrtti_typeid(), + }; + } +} + +#if !defined(TERRAIN_EDITOR) +// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM +// The first parameter should be GemName_GemIdLower +// The second should be the fully qualified name of the class above +AZ_DECLARE_MODULE_CLASS(Gem_Terrain, Terrain::TerrainModule) +#endif + diff --git a/Gems/Terrain/Code/Source/TerrainModule.h b/Gems/Terrain/Code/Source/TerrainModule.h new file mode 100644 index 0000000000..c665ee44eb --- /dev/null +++ b/Gems/Terrain/Code/Source/TerrainModule.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +namespace Terrain +{ + class TerrainModule + : public AZ::Module + { + public: + AZ_RTTI(TerrainModule, "{B1CFB3A0-EA27-4AF0-A16D-E943C98FED88}", AZ::Module); + AZ_CLASS_ALLOCATOR(TerrainModule, AZ::SystemAllocator, 0); + + TerrainModule(); + + AZ::ComponentTypeList GetRequiredSystemComponents() const override; + }; +} diff --git a/Gems/Terrain/Code/Tests/TerrainEditorTest.cpp b/Gems/Terrain/Code/Tests/TerrainEditorTest.cpp new file mode 100644 index 0000000000..47492dfe40 --- /dev/null +++ b/Gems/Terrain/Code/Tests/TerrainEditorTest.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +class TerrainEditorTest + : public ::testing::Test +{ +protected: + void SetUp() override + { + + } + + void TearDown() override + { + + } +}; + +TEST_F(TerrainEditorTest, SanityTest) +{ + ASSERT_TRUE(true); +} + +AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV); diff --git a/Gems/Terrain/Code/Tests/TerrainTest.cpp b/Gems/Terrain/Code/Tests/TerrainTest.cpp new file mode 100644 index 0000000000..9b47c91a31 --- /dev/null +++ b/Gems/Terrain/Code/Tests/TerrainTest.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +class TerrainTest + : public ::testing::Test +{ +protected: + void SetUp() override + { + + } + + void TearDown() override + { + + } +}; + +TEST_F(TerrainTest, SanityTest) +{ + ASSERT_TRUE(true); +} + +AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV); diff --git a/Gems/Terrain/Code/terrain_editor_shared_files.cmake b/Gems/Terrain/Code/terrain_editor_shared_files.cmake new file mode 100644 index 0000000000..68ec9aeb54 --- /dev/null +++ b/Gems/Terrain/Code/terrain_editor_shared_files.cmake @@ -0,0 +1,16 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Source/EditorComponents/EditorTerrainSystemComponent.cpp + Source/EditorComponents/EditorTerrainSystemComponent.h + Source/EditorTerrainModule.cpp + Source/EditorTerrainModule.h + Source/TerrainModule.cpp + Source/TerrainModule.h +) diff --git a/Gems/Terrain/Code/terrain_editor_tests_files.cmake b/Gems/Terrain/Code/terrain_editor_tests_files.cmake new file mode 100644 index 0000000000..d5d0ec5393 --- /dev/null +++ b/Gems/Terrain/Code/terrain_editor_tests_files.cmake @@ -0,0 +1,11 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Tests/TerrainEditorTest.cpp +) diff --git a/Gems/Terrain/Code/terrain_files.cmake b/Gems/Terrain/Code/terrain_files.cmake new file mode 100644 index 0000000000..c67d0c63b4 --- /dev/null +++ b/Gems/Terrain/Code/terrain_files.cmake @@ -0,0 +1,14 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Source/Components/TerrainSurfaceDataSystemComponent.cpp + Source/Components/TerrainSurfaceDataSystemComponent.h + Source/Components/TerrainSystemComponent.cpp + Source/Components/TerrainSystemComponent.h +) diff --git a/Gems/Terrain/Code/terrain_shared_files.cmake b/Gems/Terrain/Code/terrain_shared_files.cmake new file mode 100644 index 0000000000..211182b0fa --- /dev/null +++ b/Gems/Terrain/Code/terrain_shared_files.cmake @@ -0,0 +1,12 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Source/TerrainModule.h + Source/TerrainModule.cpp +) diff --git a/Gems/Terrain/Code/terrain_tests_files.cmake b/Gems/Terrain/Code/terrain_tests_files.cmake new file mode 100644 index 0000000000..beed6bd83d --- /dev/null +++ b/Gems/Terrain/Code/terrain_tests_files.cmake @@ -0,0 +1,11 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +set(FILES + Tests/TerrainTest.cpp +) diff --git a/Gems/Terrain/gem.json b/Gems/Terrain/gem.json new file mode 100644 index 0000000000..ccf034d399 --- /dev/null +++ b/Gems/Terrain/gem.json @@ -0,0 +1,10 @@ +{ + "gem_name": "Terrain", + "display_name": "Terrain (WIP)", + "license": "Apache-2.0 Or MIT", + "origin": "Open 3D Engine - o3de.org", + "summary": "The Terrain Gem is a WIP (work-in-progress) Gem for providing terrain services including authoring workflows, rendering, and physics.", + "canonical_tags": [ "Gem" ], + "user_tags": [ "Environment", "Terrain" ], + "icon_path": "preview.png" +} diff --git a/Gems/Terrain/preview.png b/Gems/Terrain/preview.png new file mode 100644 index 0000000000..2f1ed47754 --- /dev/null +++ b/Gems/Terrain/preview.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d6204c6730e5675791765ca194e9b1cbec282208e280507de830afc2805e5fa +size 41127 diff --git a/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp b/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp index dd0e63c15b..345c27d27a 100644 --- a/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp +++ b/Gems/Vegetation/Code/Source/VegetationSystemComponent.cpp @@ -47,19 +47,24 @@ namespace Vegetation void VegetationSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("VegetationSystemService", 0xa2322728)); + services.push_back(AZ_CRC_CE("VegetationSystemService")); } void VegetationSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("VegetationSystemService", 0xa2322728)); + services.push_back(AZ_CRC_CE("VegetationSystemService")); } void VegetationSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services) { - services.push_back(AZ_CRC("VegetationAreaSystemService", 0x36da2b62)); - services.push_back(AZ_CRC("VegetationInstanceSystemService", 0x823a6007)); - services.push_back(AZ_CRC("SurfaceDataProviderService", 0xfe9fb95e)); + services.push_back(AZ_CRC_CE("VegetationAreaSystemService")); + services.push_back(AZ_CRC_CE("VegetationInstanceSystemService")); + services.push_back(AZ_CRC_CE("SurfaceDataSystemService")); + } + + void VegetationSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services) + { + services.push_back(AZ_CRC_CE("SurfaceDataProviderService")); } void VegetationSystemComponent::Reflect(AZ::ReflectContext* context) diff --git a/Gems/Vegetation/Code/Source/VegetationSystemComponent.h b/Gems/Vegetation/Code/Source/VegetationSystemComponent.h index ff4ab17586..bbe92e2cf8 100644 --- a/Gems/Vegetation/Code/Source/VegetationSystemComponent.h +++ b/Gems/Vegetation/Code/Source/VegetationSystemComponent.h @@ -22,6 +22,7 @@ namespace Vegetation static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services); static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services); static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services); + static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services); static void Reflect(AZ::ReflectContext* context); VegetationSystemComponent(); diff --git a/engine.json b/engine.json index 29532347db..63bddc9548 100644 --- a/engine.json +++ b/engine.json @@ -76,6 +76,7 @@ "Gems/StartingPointInput", "Gems/StartingPointMovement", "Gems/SurfaceData", + "Gems/Terrain", "Gems/TestAssetBuilder", "Gems/TextureAtlas", "Gems/TickBusOrderViewer",