Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GeoJSONSpawner Gem #93

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

patrykantosz
Copy link
Contributor

@patrykantosz patrykantosz commented Dec 3, 2024

This PR adds a new gem - GeoJSONSpawner. This gem provides a GeoJSONSpawner component that allows to:

  • spawn prefabs using GeoJSON format. JSON can be read from the file as well as form the raw string
  • delete (despawn) and modify prefabs by their group id (it can be one id associated with one prefab or dozens of prefabs associated with one id - this is configurable via the GeoJSON request) at runtime
  • delete (despawn) all prefabs spawned with this component

In the Editor all operations can only be done via the file that is loaded into the component (similar to the CsvSpawner) - this file is then read again by the Game component to spawn entities at exactly the same locations (I had some problems with copying the exact logic from the CsvSpawner, so GeoJSONSpawner reads the file again when GL is started).
As said, GL reads the associated file at the startup, then all operations are available via the EBuses.

Using GeoJSONSpawnerROS2 Gem it is possible to use GeoJSONSpawner in runtime via the ROS 2 interface.

Since the GeoJSON standard only provides longitude and latitude information by default (and all online editors that I've seen follow it) I decided to set the desired altitude in the Spawnable Asset Configuration as the Raytrace starting height (probably this is not the best name for a value used in a way, that is described later). The use of this value depends on the Place on terrain switch - if the switch is set to true, the Raytrace starting height value is used as the name suggests - raytracing starts at that height. Otherwise, if the switch is set to false, this value is just a Z-axis coordinate at which the prefab will be spawned.

Usage description is available in the README.

Signed-off-by: Patryk Antosz <[email protected]>
Signed-off-by: Patryk Antosz <[email protected]>
Signed-off-by: Patryk Antosz <[email protected]>
*additionaly added separated struct with configuration

Signed-off-by: Patryk Antosz <[email protected]>
*code refactored
*added new required field to the json schema (id)

Signed-off-by: Patryk Antosz <[email protected]>
*splited into Editor and Game Components
*added randomization (based on the configuration)
*works in the Editor and in the GameLauncher

Signed-off-by: Patryk Antosz <[email protected]>
Signed-off-by: Patryk Antosz <[email protected]>
*changed used `find` function from AZStd::find to AZStd::unordered_set::find

Signed-off-by: Patryk Antosz <[email protected]>
Signed-off-by: Patryk Antosz <[email protected]>
@wc-robotec wc-robotec self-requested a review December 3, 2024 11:32
Copy link
Contributor

@wc-robotec wc-robotec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine. Code looks good.

@pijaro pijaro requested a review from michalpelka December 5, 2024 12:45
Copy link
Collaborator

@michalpelka michalpelka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1st round of comments from me. I would not merge at is it, but it is close.
I would consider:

  • break it to second Gem : 1st core with C++/Lua API, 2nd with ROS2 integration (can be done in other PR)
  • Some form of tests since there is a lot of logic.

*ROS2 handlers will be moved to new gem
*added simple state queue to properly handle spawn/despawn requests

Signed-off-by: Patryk Antosz <[email protected]>
@patrykantosz patrykantosz force-pushed the pantosz/geojson_spawner branch from 61eb3d5 to 17cb098 Compare December 10, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants