First batch of GetValues() overrides (#6852)
* 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>
This commit is contained in:
@@ -219,6 +219,39 @@ namespace GradientSignal
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void ImageGradientComponent::GetValues(AZStd::array_view<AZ::Vector3> positions, AZStd::array_view<float> outValues) const
|
||||
{
|
||||
if (positions.size() != outValues.size())
|
||||
{
|
||||
AZ_Assert(false, "input and output lists are different sizes (%zu vs %zu).", positions.size(), outValues.size());
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::Vector3 uvw;
|
||||
bool wasPointRejected = false;
|
||||
|
||||
AZStd::shared_lock<decltype(m_imageMutex)> imageLock(m_imageMutex);
|
||||
|
||||
for (size_t index = 0; index < positions.size(); index++)
|
||||
{
|
||||
// The const_cast is necessary for now since array_view currently only supports const entries.
|
||||
// If/when array_view is fixed to support non-const, or AZStd::span gets created, the const_cast can get removed.
|
||||
auto& outValue = const_cast<float&>(outValues[index]);
|
||||
|
||||
m_gradientTransform.TransformPositionToUVWNormalized(positions[index], uvw, wasPointRejected);
|
||||
|
||||
if (!wasPointRejected)
|
||||
{
|
||||
outValue = GetValueFromImageAsset(
|
||||
m_configuration.m_imageAsset, uvw, m_configuration.m_tilingX, m_configuration.m_tilingY, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
outValue = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::string ImageGradientComponent::GetImageAssetPath() const
|
||||
{
|
||||
AZStd::string assetPathString;
|
||||
|
||||
Reference in New Issue
Block a user