* Add comparison operators to SurfaceTagWeight.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed AddSurfaceTagWeight to always combine weights.
This simplifies the API a bit and defines the behavior if someone ever tries to add a duplicate tag.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added benchmarks for measuring the performance-critical APIs.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed SurfaceTagWeights to a fixed_vector.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add inPosition to AddSurfacePoint.
This will be used to detect which input the surface point is associated with.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add inPositionIndex to the appropriate APIs.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched Gradient Surface benchmarks to use actual surface components.
The gradient unit tests and benchmarks were previously using a mock surface data system, which led to misleading benchmark results. Now, the actual SurfaceData system gets constructed, and the tests use a mock provider, but the benchmarks use actual shape providers for more realistic benchmarking.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed unit tests to have better query ranges.
Half of each previous range was querying outside the surface provider's data.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* First attempt at removing SurfacePointLists.
This currently runs significantly slower than the previous code but passes the unit tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Another attempt at optimization.
This one runs faster than the previous, but still slow.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix the cmake dependency so that the gradient tests rebuild SurfaceData.dll when run.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switch SurfaceAltitudeGradient over to the new bulk API.
Also, optimized the non-bulk API by having it reuse the SurfacePointList to avoid the repeated allocation / deallocation cost.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched to using an indirect index so that all allocations are consecutive in our reserved buffer.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched back to SurfaceTagWeight again.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added runtime dependency to LmbrCentral for unit tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched code over to use the full EnumeratePoints in most cases.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added knowledge of max surface point creation into the system.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add generic GetSurfacePointsFromList API implementation for surface providers.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed implementation to use the correct maximum number of input points based on the surface providers being queried.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix out-of-bounds references on empty lists.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix memory allocation that caused benchmark runs to crash.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Starting to clean up the API.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Move SurfacePointList into separate files for easier maintainability.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed bug where too many points were filtered out due to using the position Z as a part of the AABB check.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Made FilterPoints an internal part of SurfacePointList so we can choose when and how to perform the filtering.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Final cleanup / comments.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added includes for non-unity builds.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Optimized GetValues() implementations.
Also consolidated GetValue() and GetValues() down to a single implementation under the covers for easier maintenance.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed how unit tests initialize the mock lists to try and fix the linux errors.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switch to explicit span declarations to help ensure this works with linux.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed compile error.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Make the bulk terrain APIs take in const Vector instead of non-const.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Optimize the surface data providers for bulk queries.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add comparison operators to SurfaceTagWeight.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed AddSurfaceTagWeight to always combine weights.
This simplifies the API a bit and defines the behavior if someone ever tries to add a duplicate tag.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added benchmarks for measuring the performance-critical APIs.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed SurfaceTagWeights to a fixed_vector.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add inPosition to AddSurfacePoint.
This will be used to detect which input the surface point is associated with.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add inPositionIndex to the appropriate APIs.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched Gradient Surface benchmarks to use actual surface components.
The gradient unit tests and benchmarks were previously using a mock surface data system, which led to misleading benchmark results. Now, the actual SurfaceData system gets constructed, and the tests use a mock provider, but the benchmarks use actual shape providers for more realistic benchmarking.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed unit tests to have better query ranges.
Half of each previous range was querying outside the surface provider's data.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* First attempt at removing SurfacePointLists.
This currently runs significantly slower than the previous code but passes the unit tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Another attempt at optimization.
This one runs faster than the previous, but still slow.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix the cmake dependency so that the gradient tests rebuild SurfaceData.dll when run.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switch SurfaceAltitudeGradient over to the new bulk API.
Also, optimized the non-bulk API by having it reuse the SurfacePointList to avoid the repeated allocation / deallocation cost.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched to using an indirect index so that all allocations are consecutive in our reserved buffer.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched back to SurfaceTagWeight again.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added runtime dependency to LmbrCentral for unit tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched code over to use the full EnumeratePoints in most cases.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added knowledge of max surface point creation into the system.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add generic GetSurfacePointsFromList API implementation for surface providers.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed implementation to use the correct maximum number of input points based on the surface providers being queried.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix out-of-bounds references on empty lists.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix memory allocation that caused benchmark runs to crash.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Starting to clean up the API.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Move SurfacePointList into separate files for easier maintainability.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed bug where too many points were filtered out due to using the position Z as a part of the AABB check.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Made FilterPoints an internal part of SurfacePointList so we can choose when and how to perform the filtering.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Final cleanup / comments.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added includes for non-unity builds.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed how unit tests initialize the mock lists to try and fix the linux errors.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed compile error.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* First pass at encapsulating SurfacePointList.
The biggest challenge in optimizing SurfacePointList(s) usage is the overall memory management associated with it. There are M surface points with N surface mask entries created for every input point, which leads to a lot of container reallocation and memory shuffling when processing multiple input points. By encapsulating the list, it should become easier to preallocate the entries, as well as keep "helper data" around for managing the bookkeeping to associate the input points with the output points.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Small fixes and TODO reminders.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Encapsulate surface point creation and separate EnumeratePoints out from modifications.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Start removing SurfacePoint from the exposed API.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Changed SurfacePointList to split out the surface point storage to allow for span<> usage over time.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed entity id
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed SurfacePoint from SurfaceData, changed all remaining uses to AzFramework::SurfaceData::SurfacePoint.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Encapsulated SurfaceTagWeightMap and renamed to SurfaceTagWeights.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed make file.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Better commenting and parameter naming.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Renamed methods to be more descriptive.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Misc SurfaceData Optimizations.
This includes a few different optimizations found while trying to make the bulk query APIs faster:
* Switches mutexes over to shared_lock to optimize for the multi-reader-single-writer pattern
* Surface provider point creation now uses a pre-created set of masks to initialize with, and uses std::move() to move the created point into the output list instead of copying it.
* Splits CombineSortAndFilterNeightboringPoints so that the FilterPoints() can occur separately and efficiently with erase/remove_if, and avoids making a copy of the output points.
* Optimized SurfaceDataShapeComponent::ModifySurfacePoints
* Fixed potential bug where the sort wasn't stable since it only compared the Z value, and could have produced unexpected results for differing points with the exact same Z value.
* Fixed up a couple small bugs and missing checks in the unit tests
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed syntax on unit tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Initial cleanup of GetSurfacePointsFromRegion in prep for bulk API support.
* Removed the generated lookup point from the output structure. Nothing was using it, and by keeping it separate, I can pass it in as a list of points that can be passed throughout the terrain, gradient, and surface data APIs.
* Clarified on the SurfaceProvider bus that GetSurfacePoints() only gets valid XY values on the inPosition.
* Simplified the TerrainSurfaceDataSystemComponent implementation a bit. The EnumerateHandlers() and the terrain Aabb checks were overkill. Also, the terrain Aabb check assumed that the Z value on the inPosition was valid, which it isn't always.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Remove CryCommon dependency.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed "chatty" profile markers.
These three markers were making terrain refreshes take ~200% longer in profile builds.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Terrain surface data wasn't updating its AABB correctly.
The code was making an invalid assumption that changes to the world bounds would result in an invalid dirtyRegion. It actually gets a valid region encapsulating the old and new bounds. The fix is an additional check to see if the terrain bounds changed.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Addressed previous PR feedback that terrainSystem ought to be a local variable in each test.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Terrain API fixups
Moved SurfaceData definitions in AzFramework out of terrain into separate files.
Added some missing API calls: Get*FromVector2, GetSurfacePoint*
Changed OrderedSurfaceTagWeightSet to SurfaceTagWeightList
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* PR feedback - remove IsClose check.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed PhysX test compile failures by redcoding a bunch of "dummy terrain" implementation that's unused.
It was originally added for the PhysX Terrain component, but that component is long gone and has been superceded by the more generic PhysX Heightfield Collider.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed up failing terrain unit tests.
Added API changes, and changed the assumption on where the surface weight sort is taking place. The component is no longer expected to provide the sorted list, it only needs to be sorted at the end coming out of the terrain system, so the unit tests have been modified to reflect that.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Bugfixes for terrain surface data.
1. Changed the TerrainSurfaceDataSystem component to query for all the surface types, now that we have them.
2. Added dependency tracking to the TerrainSurfaceGradientList component so that it will refresh terrain data when any of its data changes.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Addressed PR feedback
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
This is the initial Terrain Gem. In this PR, it doesn't do anything, but it contains all of the initial code, icons, and build scripts for the gem to compile and build successfully. The follow-up PR will contain the first round of functioning code.
Also, with the creation of the gem, the TerrainSurfaceDataSystemComponent is getting relocated from the SurfaceData Gem to the Terrain Gem. This should have no impact, as that component has provided no active functionality in o3de. (It will start working again with the initial terrain system code in the next PR)
This also adds a couple of null guards to prefab code to prevent AP crashes, and fixed an incorrect service dependency in the VegetationSystemComponent that was exposed by moving the TerrainSurfaceDataSystemComponent.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>