Commit Graph

19 Commits (283fe216dcc8c9ee1c814b69e774fdec428bc1f0)

Author SHA1 Message Date
Mike Balfour 0e328afcdd
Optimize surface providers (#7631)
* 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>
4 years ago
bosnichd d0e5f9d20b
Added Async APIs for the various Process*FromList/Region terrain functions. (#7480)
* Added Async APIs for the various Process*FromList terrain functions.

Please note that we are currently defaulting the number of worker threads to one, because splitting the work over multiple threads causes contention when locking various mutexes, resulting in slower overall wall time for async requests split over multiple threads vs one where all the work is done on a single thread. The latter is still preferable over a regular synchronous call because it is just as quick and prevents the main thread from blocking. This should be changed once the mutex contention issues have been addressed, so that async calls automatically split the work between available job manager worker threads, unless the ProcessAsyncParams specify a different desired number of jobs.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix Linux builds by adding missing #include

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Added a test for cancellation of terrain async requests, and fix it so that it works.

Note that the benchmarks show this implementation to be slightly slower than the previous one, which I presume is because we're now calling a 'perSurfacePointFunction' in the inner loop; this can probably be addressed, but will result in a lot of code duplication, and I think efforts will be better spent on removing the mutex contention to enable running multiple terrain async jobs at the same time.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Added Async versions for all Process*Region terrain API functions, along with benchmarks.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix the newly added terrain async request benchmarks to actually use the async APIs.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Revert to the original version which just calls the synchronous API from the job function, along with some other updates in response to review feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Change the TerrainWorldDebugger to use the async API, along with the following changes:
- TerrainJobContext no longer uses a JobCancelGroup so we can guarantee the completion callbacks of associated jobs will be invoked even if it is cancelled.
- As a result of the above change, the ProcessAsyncCompleteCallback function signature again accepts the associated TerrainJobContext as a param.
- The TerrainProcessAsyncCancellation test has been resurrected and simplified by using binary semaphores instead of condition variables.
- All the async related TerrainSystemBenchmark functions have been simplified by using binary semaphores instead of condition variables.
- Global cancellation of all terrain jobs on deactivation of the TerrainSystem has been reintroduced, but in a different way than before.
- Other miscellaneous changes/fixes made while testing and based on earlier PR feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Updates based on review feedback:
- Go back to using a vector instead of an array (fixed the original problem by adding custom copy/assignment constructors/operators to the WireframeSector struct).
- When calling WireframeSector::Reset, block until any associated in flight has completed.
- Added the concept of a minimum number of positions per terrain job.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Use semaphore instead of binary_semaphore in a bunch of places to account for the race condition where a completion callback fires before we started waiting for it.

Signed-off-by: bosnichd <bosnichd@amazon.com>
4 years ago
amzn-sj 396ec8a247
[Terrain] Optimize bulk queries to the Terrain System to retrieve height, surface weights, and normals (#7357) 4 years ago
Ken Pruiksma b455b915a8
Making terrain query resolution a single float instead of a Vector2 (#7186)
* Making terrain query resolution a single float instead of a Vector2

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Keeping the concept of different x/y step sizes in region queries since that may be useful and is separate from query resolution. Also keeping the concept of different x/y step sizes in physics since that's independent of the terrain gem.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Formatting cleanups

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* A few more minor cleanups

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added support to convert serialized Vector2 query resolution to a single float.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Switch ray intersection check back to using separate values for x and y resolution

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing new unit tests added to use float query resolution.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updating automated test

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
bosnichd f34d3a822e
Add a ray cast API to the terrain system, implement it, and use it so entities can be placed on top of terrain. (#6895)
* Add a ray cast API to the terrain system, implement it, and use it so entities can be placed on top of terrain.

Still to do:
- Unit tests
- Profiling/benchmarks
- Optimization (if needed, may not be now after updating to use the iterative approach, but one option could be to use SIMD to ray cast against both triangles at once)

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix typos.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Added a FindNearestIntersectionIterative to use in place of the first-pass FindnearestIntersectionRecursive attempt.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Remove some functions that are no longer being used.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Remove a unicode character from a comment to fix the validation build.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Remove another unicode character from a comment to fix the validation build.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Update to bail out as soon as t > 1.0f

Signed-off-by: bosnichd <bosnichd@amazon.com>
4 years ago
amzn-sj 0a722b5a06 Update comment for clarity
Signed-off-by: amzn-sj <srikkant@amazon.com>
4 years ago
amzn-sj 7bba4172ec Add a GetNumSamplesFromRegion function which returns the number of samples given a region and step size. Update Terrain Feature Processor to use this function to get the number of samples instead of computing num samples independently.
Signed-off-by: amzn-sj <srikkant@amazon.com>
4 years ago
amzn-sj 5dc442fcb0
[Terrain] First pass of the ProcessList and ProcessRegion APIs for retrieving surface data (#6729)
* [Terrain] First pass of the ProcessList and ProcessRegion APIs for retrieving surface data

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add a couple of more tests. The expected values were plugged in based on the values generated by the brute force approach.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Move some declarations out of loops since they can be reused.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update all the per position callbacks to pass SurfacePoint refs. Construct only one SurfacePoint object outside the loop which can be reused.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update tests to use the new per position callbacks

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add ProcessRegion functions to the terrain benchmark.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Change C style static casts to aznumeric_cast. Add maybe_unused to unused params in benchmarks.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update the ProcessList API functions to use array_view instead of a vector. This includes some additional changes to satisfy build dependencies.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add ProcessList API functions to benchmarks

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update the ProcessList API functions to take Vector2 as input positions

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Revert changes to AtomCore library split. Add partial implementation of span(mostly just copied over from array_view) to AzCore std containers.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Adding some const/non-const overloads that were missing in span

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Move input position list generation to a function

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Bring back Vector3 version of ProcessList functions. Rename Vector2 version to follow similar pattern as the Get functions.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Split span.h into .h/.inl files

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add [mayby_unused] for unused parameters to fix build errors

Signed-off-by: amzn-sj <srikkant@amazon.com>
4 years ago
John Jones-Steele 9e7d5fe52b
Test the Terrain World configuration changes when parameters are chan… (#6063)
* Test the Terrain World configuration changes when parameters are changed in the component

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Changes from PR

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Before merge

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Before merge 2

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Changes from PR

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Change from PR

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Change before merge

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Change before merge 2

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Change before merge 3

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Change after merge to fix conflicts

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Fix merge conflict

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Fix merge conflict

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* CHanges from PR

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
4 years ago
Mike Balfour 97b0eddcb4 Hook up the "Use Ground Plane" toggle.
The "Use Ground Plane" toggle is now functional.  When disabled, the terrain layer spawner will say "terrain exists = false" for any point in its bounds unless there's also a Terrain Height Gradient List component with a valid entry.  When enabled, it will always say "terrain exists = true", and it will return the min height of the spawner box as the ground plane if there's no valid Terrain Height Gradient List height provider.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Mike Balfour 86270339d8
Added terrain surface data notifications (#5067)
* Fix notifications for surface data changes.
Separated the notifications from the surface component and the height component to add a reason to a RefreshArea request.  This makes it possible to distinguish between surface changes and height changes and provide the appropriate OnTerrainDataChanged flags.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Reworked to use a changeMask instead of separate calls.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* PR Feedback
Judicious use of "using" to reduce a bunch of bulky namespaces.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Mike Balfour 2fe4524458
Terrain API cleanups (#4914)
* 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>
4 years ago
sphrose 4a4c93f866
Terrain/sphrose/surface gradient list component (#4409)
* cherry-pick conflict fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Missed include file

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* review changes.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* cherry-pick merge fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* review changes.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* bug fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* review changes.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* compile fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* compile fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>
4 years ago
Mike Balfour dc050d4acd
Terrain System bugfixes (#4180)
* Remove the "TEST_SUPPORTED" traits.
Terrain unit tests should be usable on all platforms, so they shouldn't need a platform-specific trait to enable/disable.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fix a few misc terrain bugs.
* Change Activate/Deactivate to happen immediately instead of deferring.  There were too many order-of-operation bugs caused by trying to defer this.
* Added implementation for calculating normals.
* Fixed bug where GetHeightSynchronous wasn't stopping at the highest-priority layer.
* Added locks for SurfaceData bus to help ensure we lock our mutexes in the correct order and avoid deadlocks.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Add trivial TerrainSystem tests.
Tests construction, Activate(), Deactivate(), and destruction.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Unified Terrain system calls on single bus.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Added mock for TerrainDataNotificationBus listener.
Also added unit tests to verify the listener, and added in missing notification events.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Removed extra Sampler class.
Fixed up APIs to correctly pass Sampler and terrainExistsPtr around.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Switched MockTerrainSystem to be proper gmock.
This makes it for flexible to use and easier to reuse from other test environments.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fix settings bug caused by bad order of operations that occurred when the methods moved to a different bus.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Eliminate extra EBus by simplifying area initialization.
Previously, there was a back-and-forth ebus signal used for the terrain system to find any terrain spawners that were created prior to the terrain system activation.  Now it uses the more simple technique of just grabbing all the spawners that are currently hooked up to the spawner ebus.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Switch to NiceMock so that "uninteresting" mock calls get ignored.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Addressed PR feedback.
Filled in terrainExistsPtr at the end, and added it to GetNormal as well.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fixed shader height calculation.
It was off by half a pixel, and it was interpolating, both of which were wrong.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Create initial LmbrCentral mocks that other Gems can use.
To help improve mock maintenance over time, this creates mocks in the same Gem as the systems being mocked, instead of the other Gems that need to use mocked systems during testing.  This way, the mocks should more easily stay in sync with the interface that they mock out.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Null-guard any uses of Atom to make the class easier to unit test.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Add more mocked terrain services

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Moved Terrain mocks to publicly-available Mocks directory.  Also added more unit tests.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Change debug code to use EXACT instead of BILINEAR height sampling, because it's specifically using the terrain grid.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Added support for the sampler filters.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fix bad merge.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Add unit test to verify terrain layers define terrain regions.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Moved the AABB component mock into a private terrain header, since it's a specialized mock just for the terrain tests.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Moved sampler and normal calculations into TerrainSystem so that they can work across multiple adjacent areas.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Missed a couple of unit test changes.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Removed normal query as well, that needs a seprate unit test.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Removed unused variable that was only caught in Linux/Android builds.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Addressed PR feedback
Made the parameter names consistently listed in MockShapes.h.
Added comments to TerrainHeightGradientListComponent explaining why terrainExists is always true when a gradient exists.
Also fixed a bug where terrainExists should technically be *false* if no gradient exists.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Added more descriptive comments and names for ClampPosition.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Mike Balfour 089391f761
Terrain System cleanups and unit tests (#4119)
* Remove the "TEST_SUPPORTED" traits.
Terrain unit tests should be usable on all platforms, so they shouldn't need a platform-specific trait to enable/disable.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fix a few misc terrain bugs.
* Change Activate/Deactivate to happen immediately instead of deferring.  There were too many order-of-operation bugs caused by trying to defer this.
* Added implementation for calculating normals.
* Fixed bug where GetHeightSynchronous wasn't stopping at the highest-priority layer.
* Added locks for SurfaceData bus to help ensure we lock our mutexes in the correct order and avoid deadlocks.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Add trivial TerrainSystem tests.
Tests construction, Activate(), Deactivate(), and destruction.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Unified Terrain system calls on single bus.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Added mock for TerrainDataNotificationBus listener.
Also added unit tests to verify the listener, and added in missing notification events.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Removed extra Sampler class.
Fixed up APIs to correctly pass Sampler and terrainExistsPtr around.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Switched MockTerrainSystem to be proper gmock.
This makes it for flexible to use and easier to reuse from other test environments.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fix settings bug caused by bad order of operations that occurred when the methods moved to a different bus.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Eliminate extra EBus by simplifying area initialization.
Previously, there was a back-and-forth ebus signal used for the terrain system to find any terrain spawners that were created prior to the terrain system activation.  Now it uses the more simple technique of just grabbing all the spawners that are currently hooked up to the spawner ebus.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Switch to NiceMock so that "uninteresting" mock calls get ignored.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Addressed PR feedback.
Filled in terrainExistsPtr at the end, and added it to GetNormal as well.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fixed shader height calculation.
It was off by half a pixel, and it was interpolating, both of which were wrong.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Artur K 3a4937456a
Build time reduction: AzStdOnDemandReflection (#3111)
* Move a few specializations from AzStdOnDemandReflection.inl to cpp file

This reduces compilation time and produced profile/debug file sizes.

The specializations for string and string_view are only implemented for 'char' type, since
others are not used anywhere.

Extracted `Reflect` method from `ClientAuthAWSCredentials` to a cpp file.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Windows build fixes.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Added missing license.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix missing spaces in template argument lists

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Clang format on ClientAuthAWSCredentials.cpp

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Merge upstream development and fix linux build.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
4 years ago
sphrose cc7cc9b7a8
Terrain/sphrose/layer spawner (#3980)
* #3326 Get layer priorities to work.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Refresh terrain when layer settings change

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Removed dependency notification handling: it isn't needed due to deactivate/activate cycle caused by editor redrawing.
Moved layer registering to ordered map sorted by priority.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Remove unused code, add extra sort condition.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Fix copy/paste error.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Change erase method.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Review suggestions.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Fix bus disconnect order, change GetUseGroundPlane to return bool.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Create unit tests for Terrain Spawning component #3224

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Remove unintended commit.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Remove blank line.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* PR changes.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>
4 years ago
Ken Pruiksma 0c7dfce5a0
First pass terrain cleanup (#3753)
* First pass cleanup of some terrain components.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding basic culling to terrain sectors

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding default value for m_transform

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Mike Balfour 40f41689ee
Initial Terrain System (#3401)
This represents the very beginnings of the Terrain System presented in Sig-Content RFC 4 ( https://github.com/o3de/sig-content/blob/main/rfcs/rfc-4-terrain-system.md ). There is some basic working functionality in this PR, but the system as a whole should not be considered working yet. The gem is disabled by default in all projects.

All of the code below is contained in the Terrain Gem, which is disabled by default. The following components exist and can be experimented with, but should not be expected to be functionally complete yet:

Terrain World - level component for enabling terrain
Terrain World Debugger - level component for enabling terrain debugging features
Terrain Layer Spawner - component for defining a region of terrain
Terrain Height Gradient List - component for defining a list of gradients to use as terrain heights

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago