Skip to content

Commit a3380ce

Browse files
authored
Added GeoJSONSpawner Gem (#93)
--------- Signed-off-by: Patryk Antosz <[email protected]>
1 parent df67e08 commit a3380ce

File tree

58 files changed

+2587
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2587
-0
lines changed

Gems/GeoJSONSpawner/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# Query the gem name from the gem.json file if possible
3+
# otherwise fallback to using GeoJSONSpawner
4+
o3de_find_ancestor_gem_root(gem_path gem_name "${CMAKE_CURRENT_SOURCE_DIR}")
5+
if (NOT gem_name)
6+
set(gem_name "GeoJSONSpawner")
7+
endif()
8+
9+
# Fallback to using the current source CMakeLists.txt directory as the gem root path
10+
if (NOT gem_path)
11+
set(gem_path ${CMAKE_CURRENT_SOURCE_DIR})
12+
endif()
13+
14+
set(gem_json ${gem_path}/gem.json)
15+
16+
o3de_restricted_path(${gem_json} gem_restricted_path gem_parent_relative_path)
17+
18+
o3de_pal_dir(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
19+
20+
ly_add_external_target_path(${CMAKE_CURRENT_SOURCE_DIR}/3rdParty)
21+
22+
add_subdirectory(Code)
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
2+
# Currently we are in the Code folder: ${CMAKE_CURRENT_LIST_DIR}
3+
# Get the platform specific folder ${pal_dir} for the current folder: ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}
4+
# Note: o3de_pal_dir will take care of the details for us, as this may be a restricted platform
5+
# in which case it will see if that platform is present here or in the restricted folder.
6+
# i.e. It could here in our gem : Gems/GeoJSONSpawner/Code/Platform/<platorm_name> or
7+
# <restricted_folder>/<platform_name>/Gems/GeoJSONSpawner/Code
8+
o3de_pal_dir(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME} "${gem_restricted_path}" "${gem_path}" "${gem_parent_relative_path}")
9+
10+
# Now that we have the platform abstraction layer (PAL) folder for this folder, thats where we will find the
11+
# traits for this platform. Traits for a platform are defines for things like whether or not something in this gem
12+
# is supported by this platform.
13+
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
14+
15+
# Check to see if building the Gem Modules are supported for the current platform
16+
if(NOT PAL_TRAIT_GEOJSONSPAWNER_SUPPORTED)
17+
return()
18+
endif()
19+
20+
# The ${gem_name}.API target declares the common interface that users of this gem should depend on in their targets
21+
ly_add_target(
22+
NAME ${gem_name}.API INTERFACE
23+
NAMESPACE Gem
24+
FILES_CMAKE
25+
geojsonspawner_api_files.cmake
26+
${pal_dir}/geojsonspawner_api_files.cmake
27+
INCLUDE_DIRECTORIES
28+
INTERFACE
29+
Include
30+
BUILD_DEPENDENCIES
31+
INTERFACE
32+
AZ::AzCore
33+
)
34+
35+
# The ${gem_name}.Private.Object target is an internal target
36+
# It should not be used outside of this Gems CMakeLists.txt
37+
ly_add_target(
38+
NAME ${gem_name}.Private.Object STATIC
39+
NAMESPACE Gem
40+
FILES_CMAKE
41+
geojsonspawner_private_files.cmake
42+
${pal_dir}/geojsonspawner_private_files.cmake
43+
TARGET_PROPERTIES
44+
O3DE_PRIVATE_TARGET TRUE
45+
INCLUDE_DIRECTORIES
46+
PRIVATE
47+
Include
48+
Source
49+
BUILD_DEPENDENCIES
50+
PUBLIC
51+
AZ::AzCore
52+
AZ::AzFramework
53+
PRIVATE
54+
Gem::ROS2.Static
55+
)
56+
57+
# Here add ${gem_name} target, it depends on the Private Object library and Public API interface
58+
ly_add_target(
59+
NAME ${gem_name} ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
60+
NAMESPACE Gem
61+
FILES_CMAKE
62+
geojsonspawner_shared_files.cmake
63+
${pal_dir}/geojsonspawner_shared_files.cmake
64+
INCLUDE_DIRECTORIES
65+
PUBLIC
66+
Include
67+
PRIVATE
68+
Source
69+
BUILD_DEPENDENCIES
70+
PUBLIC
71+
Gem::${gem_name}.API
72+
PRIVATE
73+
Gem::${gem_name}.Private.Object
74+
)
75+
76+
target_depends_on_ros2_packages(${gem_name}.Private.Object std_msgs std_srvs)
77+
78+
# By default, we will specify that the above target ${gem_name} would be used by
79+
# Client and Server type targets when this gem is enabled. If you don't want it
80+
# active in Clients or Servers by default, delete one of both of the following lines:
81+
ly_create_alias(NAME ${gem_name}.Clients NAMESPACE Gem TARGETS Gem::${gem_name})
82+
ly_create_alias(NAME ${gem_name}.Servers NAMESPACE Gem TARGETS Gem::${gem_name})
83+
ly_create_alias(NAME ${gem_name}.Unified NAMESPACE Gem TARGETS Gem::${gem_name})
84+
85+
# For the Client and Server variants of ${gem_name} Gem, an alias to the ${gem_name}.API target will be made
86+
ly_create_alias(NAME ${gem_name}.Clients.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
87+
ly_create_alias(NAME ${gem_name}.Servers.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
88+
ly_create_alias(NAME ${gem_name}.Unified.API NAMESPACE Gem TARGETS Gem::${gem_name}.API)
89+
90+
# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
91+
# for the Clients, Servers, Unified gem variants
92+
o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Clients Servers Unified)
93+
94+
# If we are on a host platform, we want to add the host tools targets like the ${gem_name}.Editor MODULE target
95+
if(PAL_TRAIT_BUILD_HOST_TOOLS)
96+
# The ${gem_name}.Editor.API target can be used by other gems that want to interact with the ${gem_name}.Editor module
97+
ly_add_target(
98+
NAME ${gem_name}.Editor.API INTERFACE
99+
NAMESPACE Gem
100+
FILES_CMAKE
101+
geojsonspawner_editor_api_files.cmake
102+
${pal_dir}/geojsonspawner_editor_api_files.cmake
103+
INCLUDE_DIRECTORIES
104+
INTERFACE
105+
Include
106+
BUILD_DEPENDENCIES
107+
INTERFACE
108+
AZ::AzToolsFramework
109+
)
110+
111+
# The ${gem_name}.Editor.Private.Object target is an internal target
112+
# which is only to be used by this gems CMakeLists.txt and any subdirectories
113+
# Other gems should not use this target
114+
ly_add_target(
115+
NAME ${gem_name}.Editor.Private.Object STATIC
116+
NAMESPACE Gem
117+
FILES_CMAKE
118+
geojsonspawner_editor_private_files.cmake
119+
TARGET_PROPERTIES
120+
O3DE_PRIVATE_TARGET TRUE
121+
INCLUDE_DIRECTORIES
122+
PRIVATE
123+
Include
124+
Source
125+
BUILD_DEPENDENCIES
126+
PUBLIC
127+
AZ::AzToolsFramework
128+
$<TARGET_OBJECTS:Gem::${gem_name}.Private.Object>
129+
PRIVATE
130+
Gem::ROS2.Editor.Static
131+
)
132+
133+
ly_add_target(
134+
NAME ${gem_name}.Editor GEM_MODULE
135+
NAMESPACE Gem
136+
AUTOMOC
137+
FILES_CMAKE
138+
geojsonspawner_editor_shared_files.cmake
139+
INCLUDE_DIRECTORIES
140+
PRIVATE
141+
Source
142+
PUBLIC
143+
Include
144+
BUILD_DEPENDENCIES
145+
PUBLIC
146+
Gem::${gem_name}.Editor.API
147+
PRIVATE
148+
Gem::${gem_name}.Editor.Private.Object
149+
Gem::ROS2.Editor.Static
150+
)
151+
152+
target_depends_on_ros2_packages(${gem_name}.Editor.Private.Object std_srvs)
153+
154+
# By default, we will specify that the above target ${gem_name} would be used by
155+
# Tool and Builder type targets when this gem is enabled. If you don't want it
156+
# active in Tools or Builders by default, delete one of both of the following lines:
157+
ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
158+
ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem TARGETS Gem::${gem_name}.Editor)
159+
160+
# For the Tools and Builders variants of ${gem_name} Gem, an alias to the ${gem_name}.Editor API target will be made
161+
ly_create_alias(NAME ${gem_name}.Tools.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
162+
ly_create_alias(NAME ${gem_name}.Builders.API NAMESPACE Gem TARGETS Gem::${gem_name}.Editor.API)
163+
164+
# Add in CMake dependencies for each gem dependency listed in this gem's gem.json file
165+
# for the Tools and Builders gem variants
166+
o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders)
167+
endif()
168+
169+
################################################################################
170+
# Tests
171+
################################################################################
172+
# See if globally, tests are supported
173+
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
174+
# We globally support tests, see if we support tests on this platform for ${gem_name}.Tests
175+
if(PAL_TRAIT_GEOJSONSPAWNER_TEST_SUPPORTED)
176+
# We support ${gem_name}.Tests on this platform, add dependency on the Private Object target
177+
ly_add_target(
178+
NAME ${gem_name}.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
179+
NAMESPACE Gem
180+
FILES_CMAKE
181+
geojsonspawner_tests_files.cmake
182+
INCLUDE_DIRECTORIES
183+
PRIVATE
184+
Tests
185+
Source
186+
Include
187+
BUILD_DEPENDENCIES
188+
PRIVATE
189+
AZ::AzTest
190+
AZ::AzFramework
191+
Gem::${gem_name}.Private.Object
192+
)
193+
194+
# Add ${gem_name}.Tests to googletest
195+
ly_add_googletest(
196+
NAME Gem::${gem_name}.Tests
197+
)
198+
endif()
199+
200+
# If we are a host platform we want to add tools test like editor tests here
201+
if(PAL_TRAIT_BUILD_HOST_TOOLS)
202+
# We are a host platform, see if Editor tests are supported on this platform
203+
if(PAL_TRAIT_GEOJSONSPAWNER_EDITOR_TEST_SUPPORTED)
204+
# We support ${gem_name}.Editor.Tests on this platform, add ${gem_name}.Editor.Tests target which depends on
205+
# private ${gem_name}.Editor.Private.Object target
206+
ly_add_target(
207+
NAME ${gem_name}.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
208+
NAMESPACE Gem
209+
FILES_CMAKE
210+
geojsonspawner_editor_tests_files.cmake
211+
INCLUDE_DIRECTORIES
212+
PRIVATE
213+
Tests
214+
Source
215+
Include
216+
BUILD_DEPENDENCIES
217+
PRIVATE
218+
AZ::AzTest
219+
Gem::${gem_name}.Editor.Private.Object
220+
)
221+
222+
# Add ${gem_name}.Editor.Tests to googletest
223+
ly_add_googletest(
224+
NAME Gem::${gem_name}.Editor.Tests
225+
)
226+
endif()
227+
endif()
228+
endif()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright (C) Robotec AI - All Rights Reserved
3+
*
4+
* This source code is protected under international copyright law. All rights
5+
* reserved and protected by the copyright holders.
6+
* This file is confidential and only available to authorized individuals with the
7+
* permission of the copyright holders. If you encounter this file and do not have
8+
* permission, please contact the copyright holders and delete this file.
9+
*/
10+
11+
#pragma once
12+
13+
#include <AzCore/EBus/EBus.h>
14+
15+
namespace GeoJSONSpawner
16+
{
17+
using Result = AZ::Outcome<void, AZStd::string>;
18+
using GetIdsResult = AZ::Outcome<AZStd::string, AZStd::string>;
19+
20+
//! Interface for the GeoJSONSpawner
21+
//! Used for spawning, despawning and modifying prefabs described in the GeoJSON file
22+
class GeoJSONSpawnerRequests : public AZ::ComponentBus
23+
{
24+
public:
25+
using BusIdType = AZ::EntityId;
26+
using MutexType = AZStd::mutex;
27+
28+
//! Spawn prefabs based on the information in provided GeoJSON. If there are already spawned entities on the scene, Component will
29+
//! despawn all of them before spawning new ones.
30+
//! @param rawJsonString - raw string with a GeoJSON to spawn
31+
virtual Result SpawnWithRawString(const AZStd::string& rawJsonString) = 0;
32+
33+
//! Spawn prefabs using file from a given path. If there are already spawned entities on the scene, Component will despawn all of
34+
//! them before spawning new ones.
35+
//! @param assetPath - path to a file with a GeoJSON to spawn
36+
virtual Result SpawnWithAssetPath(const AZ::IO::Path& assetPath) = 0;
37+
38+
//! Modify spawned prefabs based on the information in provided GeoJSON. Component will despawn all entities that are associated
39+
//! with given group ids before spawning modified ones.
40+
//! @param rawJsonString - raw string with a GeoJSON to modify
41+
//! If any of the given ID does not exist then modify action will be canceled
42+
virtual Result Modify(const AZStd::string& rawJsonString) = 0;
43+
44+
//! Delete all prefabs spawned with GeoJSONSpawner
45+
virtual Result DeleteAll() = 0;
46+
47+
//! Delete prefabs based on the information in provided GeoJSON
48+
//! @param idsToDelete - unordered set containing IDs to delete
49+
virtual Result DeleteById(const AZStd::unordered_set<int>& idsToDelete) = 0;
50+
51+
//! Get all used IDs together with a number of spawned prefabs associated with each ID
52+
//! @return AZStd::string with all IDs that are in use with a number of prefabs associated with each ID
53+
virtual GetIdsResult GetIds() const = 0;
54+
};
55+
56+
using GeoJSONSpawnerRequestBus = AZ::EBus<GeoJSONSpawnerRequests>;
57+
58+
} // namespace GeoJSONSpawner
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (C) Robotec AI - All Rights Reserved
3+
*
4+
* This source code is protected under international copyright law. All rights
5+
* reserved and protected by the copyright holders.
6+
* This file is confidential and only available to authorized individuals with the
7+
* permission of the copyright holders. If you encounter this file and do not have
8+
* permission, please contact the copyright holders and delete this file.
9+
*/
10+
11+
#pragma once
12+
13+
namespace GeoJSONSpawner
14+
{
15+
// System Component TypeIds
16+
inline constexpr const char* GeoJSONSpawnerSystemComponentTypeId = "{CD4EB5DE-E197-433A-B651-A0507E6A7138}";
17+
inline constexpr const char* GeoJSONSpawnerEditorSystemComponentTypeId = "{6894C22F-7C51-4C87-92E0-83D93F42252C}";
18+
19+
// Module derived classes TypeIds
20+
inline constexpr const char* GeoJSONSpawnerModuleInterfaceTypeId = "{457EB65D-5DFC-4341-BDE3-79D054485C58}";
21+
inline constexpr const char* GeoJSONSpawnerModuleTypeId = "{E56013BF-CE3A-4AA5-81AD-698844BEA7C6}";
22+
// The Editor Module by default is mutually exclusive with the Client Module
23+
// so they use the Same TypeId
24+
inline constexpr const char* GeoJSONSpawnerEditorModuleTypeId = GeoJSONSpawnerModuleTypeId;
25+
26+
// Editor Components TypeIds
27+
inline constexpr const char* GeoJSONSpawnerEditorComponentTypeId = "{97d8cdeb-8a82-4bb0-adc3-c42a3eac21c7}";
28+
29+
// Configurations TypeIds
30+
inline constexpr const char* GeoJSONSpawnableAssetConfigurationTypeId = "{cee254bb-edc8-45b1-b85a-aaf19ec3af83}";
31+
inline constexpr const char* GeoJSONSpawnableEntityInfoTypeId = "{170bb487-fbae-4394-8176-069045a3a316}";
32+
inline constexpr const char* FeatureObjectInfoTypeId = "{00f38302-9f4d-4bac-805b-72a29e42a704}";
33+
34+
// Components TypeIds
35+
inline constexpr const char* GeoJSONSpawnerComponentTypeId = "{839ede69-92f1-45b0-a60e-035d0b84e1fd}";
36+
37+
// Interface TypeIds
38+
inline constexpr const char* GeoJSONSpawnerRequestsTypeId = "{EE523E9E-CFDF-4590-BBDE-054848BBA790}";
39+
} // namespace GeoJSONSpawner
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
set(PAL_TRAIT_GEOJSONSPAWNER_SUPPORTED TRUE)
3+
set(PAL_TRAIT_GEOJSONSPAWNER_TEST_SUPPORTED FALSE)
4+
set(PAL_TRAIT_GEOJSONSPAWNER_EDITOR_TEST_SUPPORTED FALSE)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FILES
3+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Platform specific files for Android
3+
# i.e. ../Source/Android/GeoJSONSpawnerAndroid.cpp
4+
# ../Source/Android/GeoJSONSpawnerAndroid.h
5+
# ../Include/Android/GeoJSONSpawnerAndroid.h
6+
7+
set(FILES
8+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Platform specific files for Android
3+
# i.e. ../Source/Android/GeoJSONSpawnerAndroid.cpp
4+
# ../Source/Android/GeoJSONSpawnerAndroid.h
5+
# ../Include/Android/GeoJSONSpawnerAndroid.h
6+
7+
set(FILES
8+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
set(PAL_TRAIT_GEOJSONSPAWNER_SUPPORTED TRUE)
3+
set(PAL_TRAIT_GEOJSONSPAWNER_TEST_SUPPORTED FALSE)
4+
set(PAL_TRAIT_GEOJSONSPAWNER_EDITOR_TEST_SUPPORTED FALSE)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FILES
3+
)

0 commit comments

Comments
 (0)