* Change GetValues() to take in const positions.
To support this, span needed some template deductions to correctly convert from non-const containers to const ones.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed the most problematic template deduction rules.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Remove duplicate validate_iterator methods.
iterator type is a pointer, not a value, so "const iterator" and "const const_iterator" produce the same function signature.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed the span types.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Benchmarks and tests for Image and Constant GetValues
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Verify GetValues for Perlin and Random Gradients
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Standardized the assert format for GetValues().
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* More GetValues unit tests and test cleanup
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed typos
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* GetValues() unit tests for surface gradients.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Benchmarks for ShapeAreaFalloff Gradient
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added benchmarks for all remaining gradients and cleaned up the helper methods.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Renamed class for better report formatting.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added missing Mocks dependencies for the Editor tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* First batch of specific GetValues() overrides.
Each one is measurably faster than the generic version. Also, in ShapeAreaFalloffGradient, I optimized and simplified the logic a bit, so GetValue() is marginally faster too.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Change GetValues() to use span and add more overrides.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Convert GetValues() to use AZStd::span and added more overrides.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add missing include.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* PR feedback - switch to fill
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed the logic and added unit tests and comments.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Benchmarks and tests for Image and Constant GetValues
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Verify GetValues for Perlin and Random Gradients
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Standardized the assert format for GetValues().
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* More GetValues unit tests and test cleanup
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed typos
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* GetValues() unit tests for surface gradients.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Benchmarks for ShapeAreaFalloff Gradient
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added benchmarks for all remaining gradients and cleaned up the helper methods.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Renamed class for better report formatting.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added missing Mocks dependencies for the Editor tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* First batch of specific GetValues() overrides.
Each one is measurably faster than the generic version. Also, in ShapeAreaFalloffGradient, I optimized and simplified the logic a bit, so GetValue() is marginally faster too.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
All of the component headers in the gem have been moved to the Include directory to make them public to other gems. This allows "upstream" unit tests and benchmarks to easily create real non-mocked-out versions of these components to do more integration-level and system-level testing and benchmarking.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Change flow so that TerrainSystem stops responding during deactivation.
Some systems might accidentally try to call back to the TerrainSystem inside a DestroyBegin notification, so make sure it stops listening before sending out the notification.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Change gradients to cache and use a GradientTransform instance.
In my local test case, calling EBus on every call took 337 ms, using a lambda to wrap the calls took 197 ms, and using the fully cached version took 170 ms.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Remove the wrappingTransform function and go back to the switch statement.
There was a bit of overhead to each function call due to using AZStd::function that just isn't necessary for this use case.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add profile markers to the heightfield updates so that they're more visible.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Cleared state while component is deactivated.
The state was getting refreshed even while the component was in a deactivated state, which meant that it wasn't properly notifying of state changes when it became active since it wasn't detecting an actual change. By clearing the state when deactivated, and ensuring the state isn't getting refreshed *while* deactivated, the notifications work properly.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed compile warning on unit test.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Addressed PR feedback - changed comments, reduced mutex scope
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* First version of GradientTransform class.
The gradient transform logic is getting encapsulated into a class so that it can be cached and used by components in a much more optimal way than making ebus calls to the GradientTransform component on every transformed point.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Moved GradientTransform into its own source files.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Clean up and simplify GradientTransform logic.
Added extensive commenting and split TransformPositionToUVW into a separate method for normalizing (TransformPositionToUVWNormalized) so that there doesn't need to be any conditional logic. There's no runtime variance as to which one needs to be called from a given call site.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added unit tests for GradientTransform.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add comparison operators to GradientTransform so we can easily tell when it has changed.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Updated comments to be more Doxygen-friendly.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Improve lock contention by switching to a shared_lock.
ImageGradient is accessed via a many-reader-one-writer pattern, so a shared_lock causes less contention in the common "read" case.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Remove chatty profile marker.
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>
* Final update copyright headers to reference license files at the repo root
Signed-off-by: spham <spham@amazon.com>
* Fix copyright validator unit tests to support the stale O3DE header scenario
Signed-off-by: spham <spham@amazon.com>