Switched Gradient Surface benchmarks to use actual surface components. (#7468)
* 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>
This commit is contained in:
@@ -102,7 +102,7 @@ TEST_F(FastNoiseTest, FastNoise_VerifyGetValueAndGetValuesMatch)
|
||||
noiseEntity->Activate();
|
||||
|
||||
// Create a gradient sampler and run through a series of points to see if they match expectations.
|
||||
UnitTest::GradientSignalTestHelpers::CompareGetValueAndGetValues(noiseEntity->GetId(), shapeHalfBounds);
|
||||
UnitTest::GradientSignalTestHelpers::CompareGetValueAndGetValues(noiseEntity->GetId(), -shapeHalfBounds, shapeHalfBounds);
|
||||
}
|
||||
|
||||
// This uses custom test / benchmark hooks so that we can load LmbrCentral and GradientSignal Gems.
|
||||
|
||||
@@ -140,27 +140,18 @@ namespace UnitTest
|
||||
|
||||
BENCHMARK_DEFINE_F(GradientGetValues, BM_SurfaceAltitudeGradient)(benchmark::State& state)
|
||||
{
|
||||
auto mockSurfaceDataSystem =
|
||||
CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds)));
|
||||
|
||||
auto entity = BuildTestSurfaceAltitudeGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::RunGetValueOrGetValuesBenchmark(state, entity->GetId());
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(GradientGetValues, BM_SurfaceMaskGradient)(benchmark::State& state)
|
||||
{
|
||||
auto mockSurfaceDataSystem =
|
||||
CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds)));
|
||||
|
||||
auto entity = BuildTestSurfaceMaskGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::RunGetValueOrGetValuesBenchmark(state, entity->GetId());
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(GradientGetValues, BM_SurfaceSlopeGradient)(benchmark::State& state)
|
||||
{
|
||||
auto mockSurfaceDataSystem =
|
||||
CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds)));
|
||||
|
||||
auto entity = BuildTestSurfaceSlopeGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::RunGetValueOrGetValuesBenchmark(state, entity->GetId());
|
||||
}
|
||||
|
||||
@@ -24,31 +24,33 @@ namespace UnitTest
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, ImageGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto entity = BuildTestImageGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, PerlinGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto entity = BuildTestPerlinGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, RandomGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto entity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, ConstantGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto entity = BuildTestConstantGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, ShapeAreaFalloffGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto entity = BuildTestShapeAreaFalloffGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
|
||||
// Use a query range larger than our shape to ensure that we're getting falloff values within our query bounds.
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), -TestShapeHalfBounds, TestShapeHalfBounds * 3.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, DitherGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
@@ -56,21 +58,21 @@ namespace UnitTest
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
|
||||
auto entity = BuildTestDitherGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, InvertGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestInvertGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, LevelsGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestLevelsGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, MixedGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
@@ -78,62 +80,53 @@ namespace UnitTest
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto mixedEntity = BuildTestConstantGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestMixedGradient(TestShapeHalfBounds, baseEntity->GetId(), mixedEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, PosterizeGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestPosterizeGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, ReferenceGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestReferenceGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, SmoothStepGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestSmoothStepGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, ThresholdGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds);
|
||||
auto entity = BuildTestThresholdGradient(TestShapeHalfBounds, baseEntity->GetId());
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, SurfaceAltitudeGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto mockSurfaceDataSystem =
|
||||
CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds)));
|
||||
|
||||
auto entity = BuildTestSurfaceAltitudeGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, SurfaceMaskGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto mockSurfaceDataSystem =
|
||||
CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds)));
|
||||
|
||||
auto entity = BuildTestSurfaceMaskGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
|
||||
TEST_F(GradientSignalGetValuesTestsFixture, SurfaceSlopeGradientComponent_VerifyGetValueAndGetValuesMatch)
|
||||
{
|
||||
auto mockSurfaceDataSystem =
|
||||
CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds)));
|
||||
|
||||
auto entity = BuildTestSurfaceSlopeGradient(TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds);
|
||||
GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,11 @@ namespace UnitTest
|
||||
float slopeMin, float slopeMax, GradientSignal::SurfaceSlopeGradientConfig::RampType rampType,
|
||||
float falloffMidpoint, float falloffRange, float falloffStrength)
|
||||
{
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
auto surfaceEntity = CreateEntity();
|
||||
auto mockSurface = surfaceEntity->CreateComponent<MockSurfaceProviderComponent>();
|
||||
mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(aznumeric_cast<float>(dataSize)));
|
||||
mockSurface->m_tags.emplace_back("test_mask");
|
||||
|
||||
AzFramework::SurfaceData::SurfacePoint point;
|
||||
|
||||
// Fill our mock surface with the correct normal value for each point based on our test angle set.
|
||||
@@ -75,9 +79,10 @@ namespace UnitTest
|
||||
{
|
||||
float angle = AZ::DegToRad(inputAngles[(y * dataSize) + x]);
|
||||
point.m_normal = AZ::Vector3(sinf(angle), 0.0f, cosf(angle));
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(static_cast<float>(x), static_cast<float>(y))] = { { point } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(static_cast<float>(x), static_cast<float>(y))] = { { point } };
|
||||
}
|
||||
}
|
||||
ActivateEntity(surfaceEntity.get());
|
||||
|
||||
GradientSignal::SurfaceSlopeGradientConfig config;
|
||||
config.m_slopeMin = slopeMin;
|
||||
@@ -538,11 +543,14 @@ namespace UnitTest
|
||||
mockShapeComponentHandler.m_GetEncompassingAabb = AZ::Aabb::CreateFromMinMax(AZ::Vector3::CreateZero(), AZ::Vector3(10.0f));
|
||||
|
||||
// Set a different altitude for each point we're going to test. We'll use 0, 2, 5, 10 to test various points along the range.
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } };
|
||||
auto surfaceEntity = CreateEntity();
|
||||
auto mockSurface = surfaceEntity->CreateComponent<MockSurfaceProviderComponent>();
|
||||
mockSurface->m_bounds = mockShapeComponentHandler.m_GetEncompassingAabb;
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } };
|
||||
ActivateEntity(surfaceEntity.get());
|
||||
|
||||
// We set the min/max to values other than 0-10 to help validate that they aren't used in the case of the pinned shape.
|
||||
GradientSignal::SurfaceAltitudeGradientConfig config;
|
||||
@@ -572,11 +580,14 @@ namespace UnitTest
|
||||
auto entityShape = CreateEntity();
|
||||
|
||||
// Set a different altitude for each point we're going to test. We'll use 0, 2, 5, 10 to test various points along the range.
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } };
|
||||
auto surfaceEntity = CreateEntity();
|
||||
auto mockSurface = surfaceEntity->CreateComponent<MockSurfaceProviderComponent>();
|
||||
mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(1.0f));
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } };
|
||||
ActivateEntity(surfaceEntity.get());
|
||||
|
||||
// We set the min/max to 0-10, but don't set a shape.
|
||||
GradientSignal::SurfaceAltitudeGradientConfig config;
|
||||
@@ -603,9 +614,6 @@ namespace UnitTest
|
||||
|
||||
auto entityShape = CreateEntity();
|
||||
|
||||
// Don't set any points.
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
|
||||
// We set the min/max to -5 - 15 so that a height of 0 would produce a non-zero value.
|
||||
GradientSignal::SurfaceAltitudeGradientConfig config;
|
||||
config.m_altitudeMin = -5.0f;
|
||||
@@ -631,16 +639,18 @@ namespace UnitTest
|
||||
|
||||
auto entityShape = CreateEntity();
|
||||
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
|
||||
auto surfaceEntity = CreateEntity();
|
||||
auto mockSurface = surfaceEntity->CreateComponent<MockSurfaceProviderComponent>();
|
||||
mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(1.0f));
|
||||
// Altitude value below min - should result in 0.0f.
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -10.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -10.0f), AZ::Vector3::CreateZero() } };
|
||||
// Altitude value at exactly min - should result in 0.0f.
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -5.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -5.0f), AZ::Vector3::CreateZero() } };
|
||||
// Altitude value at exactly max - should result in 1.0f.
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 15.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 15.0f), AZ::Vector3::CreateZero() } };
|
||||
// Altitude value above max - should result in 1.0f.
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 20.0f), AZ::Vector3::CreateZero() } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 20.0f), AZ::Vector3::CreateZero() } };
|
||||
ActivateEntity(surfaceEntity.get());
|
||||
|
||||
// We set the min/max to -5 - 15. By using a range without 0 at either end, and not having 0 as the midpoint,
|
||||
// it should be easier to verify that we're successfully clamping to 0 and 1.
|
||||
@@ -667,7 +677,11 @@ namespace UnitTest
|
||||
0.5f, 1.0f,
|
||||
};
|
||||
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
auto surfaceEntity = CreateEntity();
|
||||
auto mockSurface = surfaceEntity->CreateComponent<MockSurfaceProviderComponent>();
|
||||
mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(aznumeric_cast<float>(dataSize)));
|
||||
mockSurface->m_tags.emplace_back("test_mask");
|
||||
|
||||
AzFramework::SurfaceData::SurfacePoint point;
|
||||
|
||||
// Fill our mock surface with the test_mask set and the expected gradient value at each point.
|
||||
@@ -677,9 +691,10 @@ namespace UnitTest
|
||||
{
|
||||
point.m_surfaceTags.clear();
|
||||
point.m_surfaceTags.emplace_back(AZ_CRC_CE("test_mask"), expectedOutput[(y * dataSize) + x]);
|
||||
mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(static_cast<float>(x), static_cast<float>(y))] = { { point } };
|
||||
mockSurface->m_surfacePoints[AZStd::make_pair(static_cast<float>(x), static_cast<float>(y))] = { { point } };
|
||||
}
|
||||
}
|
||||
ActivateEntity(surfaceEntity.get());
|
||||
|
||||
GradientSignal::SurfaceMaskGradientConfig config;
|
||||
config.m_surfaceTagList.push_back(AZ_CRC("test_mask", 0x7a16e9ff));
|
||||
@@ -706,8 +721,6 @@ namespace UnitTest
|
||||
0.0f, 0.0f,
|
||||
};
|
||||
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
|
||||
GradientSignal::SurfaceMaskGradientConfig config;
|
||||
config.m_surfaceTagList.push_back(AZ_CRC("test_mask", 0x7a16e9ff));
|
||||
|
||||
|
||||
@@ -67,9 +67,6 @@ namespace UnitTest
|
||||
const AzFramework::SurfaceData::SurfacePoint& input,
|
||||
const AzFramework::SurfaceData::SurfacePoint& expectedOutput)
|
||||
{
|
||||
// This lets our component register with surfaceData successfully.
|
||||
MockSurfaceDataSystem mockSurfaceDataSystem;
|
||||
|
||||
// Create a mock shape entity in case our gradient test uses shape constraints.
|
||||
// The mock shape is a cube that goes from -0.5 to 0.5 in space.
|
||||
auto mockShapeEntity = CreateTestEntity(0.5f);
|
||||
@@ -105,7 +102,9 @@ namespace UnitTest
|
||||
ActivateEntity(entity.get());
|
||||
|
||||
// Get our registered modifier handle (and verify that it's valid)
|
||||
auto modifierHandle = mockSurfaceDataSystem.GetSurfaceModifierHandle(entity->GetId());
|
||||
SurfaceData::SurfaceDataRegistryHandle modifierHandle = SurfaceData::InvalidSurfaceDataRegistryHandle;
|
||||
SurfaceData::SurfaceDataSystemRequestBus::BroadcastResult(
|
||||
modifierHandle, &SurfaceData::SurfaceDataSystemRequestBus::Events::GetSurfaceDataModifierHandle, entity->GetId());
|
||||
EXPECT_TRUE(modifierHandle != SurfaceData::InvalidSurfaceDataRegistryHandle);
|
||||
|
||||
// Call ModifySurfacePoints and verify the results
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include <GradientSignal/Components/GradientSurfaceDataComponent.h>
|
||||
#include <GradientSignal/Components/GradientTransformComponent.h>
|
||||
#include <LmbrCentral/Shape/BoxShapeComponentBus.h>
|
||||
#include <LmbrCentral/Shape/SphereShapeComponentBus.h>
|
||||
#include <SurfaceData/Components/SurfaceDataShapeComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
|
||||
// Base gradient components
|
||||
#include <GradientSignal/Components/ConstantGradientComponent.h>
|
||||
@@ -40,7 +43,7 @@ namespace UnitTest
|
||||
{
|
||||
void GradientSignalTestEnvironment::AddGemsAndComponents()
|
||||
{
|
||||
AddDynamicModulePaths({ "LmbrCentral" });
|
||||
AddDynamicModulePaths({ "LmbrCentral", "SurfaceData" });
|
||||
|
||||
AddComponentDescriptors({
|
||||
AzFramework::TransformComponent::CreateDescriptor(),
|
||||
@@ -65,6 +68,7 @@ namespace UnitTest
|
||||
GradientSignal::ThresholdGradientComponent::CreateDescriptor(),
|
||||
|
||||
MockShapeComponent::CreateDescriptor(),
|
||||
MockSurfaceProviderComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,35 +86,6 @@ namespace UnitTest
|
||||
AzFramework::LegacyAssetEventBus::ClearQueuedEvents();
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<MockSurfaceDataSystem> GradientSignalBaseFixture::CreateMockSurfaceDataSystem(const AZ::Aabb& spawnerBox)
|
||||
{
|
||||
AzFramework::SurfaceData::SurfacePoint point;
|
||||
AZStd::unique_ptr<MockSurfaceDataSystem> mockSurfaceDataSystem = AZStd::make_unique<MockSurfaceDataSystem>();
|
||||
|
||||
// Give the mock surface data a bunch of fake point values to return.
|
||||
for (float y = spawnerBox.GetMin().GetY(); y < spawnerBox.GetMax().GetY(); y+= 1.0f)
|
||||
{
|
||||
for (float x = spawnerBox.GetMin().GetX(); x < spawnerBox.GetMax().GetX(); x += 1.0f)
|
||||
{
|
||||
// Use our x distance into the spawnerBox as an arbitrary percentage value that we'll use to calculate
|
||||
// our other arbitrary values below.
|
||||
float arbitraryPercentage = AZStd::abs(x / spawnerBox.GetExtents().GetX());
|
||||
|
||||
// Create a position that's between min and max Z of the box.
|
||||
point.m_position = AZ::Vector3(x, y, AZ::Lerp(spawnerBox.GetMin().GetZ(), spawnerBox.GetMax().GetZ(), arbitraryPercentage));
|
||||
// Create an arbitrary normal value.
|
||||
point.m_normal = point.m_position.GetNormalized();
|
||||
// Create an arbitrary surface value.
|
||||
point.m_surfaceTags.clear();
|
||||
point.m_surfaceTags.emplace_back(AZ_CRC_CE("test_mask"), arbitraryPercentage);
|
||||
|
||||
mockSurfaceDataSystem->m_GetSurfacePoints[AZStd::make_pair(x, y)] = { { point } };
|
||||
}
|
||||
}
|
||||
|
||||
return mockSurfaceDataSystem;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AZ::Entity> GradientSignalBaseFixture::CreateTestEntity(float shapeHalfBounds)
|
||||
{
|
||||
// Create the base entity
|
||||
@@ -120,7 +95,7 @@ namespace UnitTest
|
||||
auto boxComponent = testEntity->CreateComponent(LmbrCentral::AxisAlignedBoxShapeComponentTypeId);
|
||||
boxComponent->SetConfiguration(boxConfig);
|
||||
|
||||
// Create a transform that locates our gradient in the center of our desired mock Shape.
|
||||
// Create a transform that locates our gradient in the center of our desired Shape.
|
||||
auto transform = testEntity->CreateComponent<AzFramework::TransformComponent>();
|
||||
transform->SetLocalTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeHalfBounds)));
|
||||
transform->SetWorldTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeHalfBounds)));
|
||||
@@ -128,6 +103,23 @@ namespace UnitTest
|
||||
return testEntity;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AZ::Entity> GradientSignalBaseFixture::CreateTestSphereEntity(float shapeRadius)
|
||||
{
|
||||
// Create the base entity
|
||||
AZStd::unique_ptr<AZ::Entity> testEntity = CreateEntity();
|
||||
|
||||
LmbrCentral::SphereShapeConfig sphereConfig(shapeRadius);
|
||||
auto sphereComponent = testEntity->CreateComponent(LmbrCentral::SphereShapeComponentTypeId);
|
||||
sphereComponent->SetConfiguration(sphereConfig);
|
||||
|
||||
// Create a transform that locates our gradient in the center of our desired Shape.
|
||||
auto transform = testEntity->CreateComponent<AzFramework::TransformComponent>();
|
||||
transform->SetLocalTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeRadius)));
|
||||
transform->SetWorldTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeRadius)));
|
||||
|
||||
return testEntity;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AZ::Entity> GradientSignalBaseFixture::BuildTestConstantGradient(float shapeHalfBounds)
|
||||
{
|
||||
// Create a Constant Gradient Component with arbitrary parameters.
|
||||
@@ -349,12 +341,18 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<AZ::Entity> GradientSignalBaseFixture::BuildTestSurfaceAltitudeGradient(float shapeHalfBounds)
|
||||
{
|
||||
// Create a Surface Altitude Gradient Component with arbitrary parameters.
|
||||
auto entity = CreateTestEntity(shapeHalfBounds);
|
||||
auto entity = CreateTestSphereEntity(shapeHalfBounds);
|
||||
GradientSignal::SurfaceAltitudeGradientConfig config;
|
||||
config.m_altitudeMin = -5.0f;
|
||||
config.m_altitudeMax = 15.0f;
|
||||
config.m_altitudeMax = 15.0f + (shapeHalfBounds * 2.0f);
|
||||
entity->CreateComponent<GradientSignal::SurfaceAltitudeGradientComponent>(config);
|
||||
|
||||
// Create a SurfaceDataShape component to provide surface points from this component.
|
||||
SurfaceData::SurfaceDataShapeConfig shapeConfig;
|
||||
shapeConfig.m_providerTags.emplace_back("test_mask");
|
||||
auto surfaceShapeComponent = entity->CreateComponent(azrtti_typeid<SurfaceData::SurfaceDataShapeComponent>());
|
||||
surfaceShapeComponent->SetConfiguration(shapeConfig);
|
||||
|
||||
ActivateEntity(entity.get());
|
||||
return entity;
|
||||
}
|
||||
@@ -362,11 +360,17 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<AZ::Entity> GradientSignalBaseFixture::BuildTestSurfaceMaskGradient(float shapeHalfBounds)
|
||||
{
|
||||
// Create a Surface Mask Gradient Component with arbitrary parameters.
|
||||
auto entity = CreateTestEntity(shapeHalfBounds);
|
||||
auto entity = CreateTestSphereEntity(shapeHalfBounds);
|
||||
GradientSignal::SurfaceMaskGradientConfig config;
|
||||
config.m_surfaceTagList.push_back(AZ_CRC_CE("test_mask"));
|
||||
entity->CreateComponent<GradientSignal::SurfaceMaskGradientComponent>(config);
|
||||
|
||||
// Create a SurfaceDataShape component to provide surface points from this component.
|
||||
SurfaceData::SurfaceDataShapeConfig shapeConfig;
|
||||
shapeConfig.m_providerTags.emplace_back("test_mask");
|
||||
auto surfaceShapeComponent = entity->CreateComponent(azrtti_typeid<SurfaceData::SurfaceDataShapeComponent>());
|
||||
surfaceShapeComponent->SetConfiguration(shapeConfig);
|
||||
|
||||
ActivateEntity(entity.get());
|
||||
return entity;
|
||||
}
|
||||
@@ -374,7 +378,7 @@ namespace UnitTest
|
||||
AZStd::unique_ptr<AZ::Entity> GradientSignalBaseFixture::BuildTestSurfaceSlopeGradient(float shapeHalfBounds)
|
||||
{
|
||||
// Create a Surface Slope Gradient Component with arbitrary parameters.
|
||||
auto entity = CreateTestEntity(shapeHalfBounds);
|
||||
auto entity = CreateTestSphereEntity(shapeHalfBounds);
|
||||
GradientSignal::SurfaceSlopeGradientConfig config;
|
||||
config.m_slopeMin = 5.0f;
|
||||
config.m_slopeMax = 50.0f;
|
||||
@@ -384,6 +388,12 @@ namespace UnitTest
|
||||
config.m_smoothStep.m_falloffStrength = 0.25f;
|
||||
entity->CreateComponent<GradientSignal::SurfaceSlopeGradientComponent>(config);
|
||||
|
||||
// Create a SurfaceDataShape component to provide surface points from this component.
|
||||
SurfaceData::SurfaceDataShapeConfig shapeConfig;
|
||||
shapeConfig.m_providerTags.emplace_back("test_mask");
|
||||
auto surfaceShapeComponent = entity->CreateComponent(azrtti_typeid<SurfaceData::SurfaceDataShapeComponent>());
|
||||
surfaceShapeComponent->SetConfiguration(shapeConfig);
|
||||
|
||||
ActivateEntity(entity.get());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace UnitTest
|
||||
entity->Activate();
|
||||
}
|
||||
|
||||
// Create a mock SurfaceDataSystem that will respond to requests for surface points with mock responses for points inside
|
||||
// the given input box.
|
||||
AZStd::unique_ptr<MockSurfaceDataSystem> CreateMockSurfaceDataSystem(const AZ::Aabb& spawnerBox);
|
||||
|
||||
// Create an entity with a mock shape and a transform. It won't be activated yet though, because we expect a gradient component
|
||||
// Create an entity with a box shape and a transform. It won't be activated yet though, because we expect a gradient component
|
||||
// to also get added to it first before activation.
|
||||
AZStd::unique_ptr<AZ::Entity> CreateTestEntity(float shapeHalfBounds);
|
||||
|
||||
// Create an entity with a sphere shape and a transform. It won't be activated yet though, because we expect a gradient component
|
||||
// to also get added to it first before activation.
|
||||
AZStd::unique_ptr<AZ::Entity> CreateTestSphereEntity(float shapeRadius);
|
||||
|
||||
// Create and activate an entity with a gradient component of the requested type, initialized with test data.
|
||||
AZStd::unique_ptr<AZ::Entity> BuildTestConstantGradient(float shapeHalfBounds);
|
||||
AZStd::unique_ptr<AZ::Entity> BuildTestImageGradient(float shapeHalfBounds);
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
void GradientSignalTestHelpers::CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float shapeHalfBounds)
|
||||
void GradientSignalTestHelpers::CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float queryMin, float queryMax)
|
||||
{
|
||||
// Create a gradient sampler and run through a series of points to see if they match expectations.
|
||||
|
||||
const AZ::Aabb queryRegion = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-shapeHalfBounds), AZ::Vector3(shapeHalfBounds));
|
||||
const AZ::Aabb queryRegion = AZ::Aabb::CreateFromMinMax(AZ::Vector3(queryMin), AZ::Vector3(queryMax));
|
||||
const AZ::Vector2 stepSize(1.0f, 1.0f);
|
||||
|
||||
GradientSignal::GradientSampler gradientSampler;
|
||||
@@ -118,6 +118,7 @@ namespace UnitTest
|
||||
AZStd::vector<float> results(totalQueryPoints);
|
||||
GradientSignal::GradientRequestBus::Event(
|
||||
gradientId, &GradientSignal::GradientRequestBus::Events::GetValues, positions, results);
|
||||
benchmark::DoNotOptimize(results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +175,7 @@ namespace UnitTest
|
||||
// Query and get the results.
|
||||
AZStd::vector<float> results(totalQueryPoints);
|
||||
gradientSampler.GetValues(positions, results);
|
||||
benchmark::DoNotOptimize(results);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace UnitTest
|
||||
class GradientSignalTestHelpers
|
||||
{
|
||||
public:
|
||||
static void CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float shapeHalfBounds);
|
||||
static void CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float queryMin, float queryMax);
|
||||
|
||||
#ifdef HAVE_BENCHMARK
|
||||
// We use an enum to list out the different types of GetValue() benchmarks to run so that way we can condense our test cases
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <GradientSignal/GradientSampler.h>
|
||||
#include <GradientSignal/ImageAsset.h>
|
||||
#include <LmbrCentral/Shape/ShapeComponentBus.h>
|
||||
#include <SurfaceData/SurfaceDataProviderRequestBus.h>
|
||||
#include <SurfaceData/SurfaceDataSystemRequestBus.h>
|
||||
#include <SurfaceData/Tests/SurfaceDataTestMocks.h>
|
||||
|
||||
@@ -162,4 +163,64 @@ namespace UnitTest
|
||||
bool m_constrainToShape;
|
||||
};
|
||||
|
||||
// Mock out a SurfaceProvider component so that we can control exactly what surface weights get returned
|
||||
// at which points for our unit tests.
|
||||
struct MockSurfaceProviderComponent
|
||||
: public AZ::Component
|
||||
, public SurfaceData::SurfaceDataProviderRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(MockSurfaceProviderComponent, "{18C71877-DB29-4CEC-B34C-B4B44E05203D}", AZ::Component);
|
||||
|
||||
void Activate() override
|
||||
{
|
||||
SurfaceData::SurfaceDataRegistryEntry providerRegistryEntry;
|
||||
providerRegistryEntry.m_entityId = GetEntityId();
|
||||
providerRegistryEntry.m_bounds = m_bounds;
|
||||
providerRegistryEntry.m_tags = m_tags;
|
||||
|
||||
SurfaceData::SurfaceDataSystemRequestBus::BroadcastResult(
|
||||
m_providerHandle, &SurfaceData::SurfaceDataSystemRequestBus::Events::RegisterSurfaceDataProvider, providerRegistryEntry);
|
||||
SurfaceData::SurfaceDataProviderRequestBus::Handler::BusConnect(m_providerHandle);
|
||||
}
|
||||
|
||||
void Deactivate() override
|
||||
{
|
||||
SurfaceData::SurfaceDataSystemRequestBus::Broadcast(
|
||||
&SurfaceData::SurfaceDataSystemRequestBus::Events::UnregisterSurfaceDataProvider, m_providerHandle);
|
||||
m_providerHandle = SurfaceData::InvalidSurfaceDataRegistryHandle;
|
||||
SurfaceData::SurfaceDataProviderRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
static void Reflect([[maybe_unused]] AZ::ReflectContext* reflect)
|
||||
{
|
||||
}
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC_CE("SurfaceDataProviderService"));
|
||||
}
|
||||
|
||||
void GetSurfacePoints(const AZ::Vector3& inPosition, SurfaceData::SurfacePointList& surfacePointList) const override
|
||||
{
|
||||
auto surfacePoints = m_surfacePoints.find(AZStd::make_pair(inPosition.GetX(), inPosition.GetY()));
|
||||
|
||||
if (surfacePoints != m_surfacePoints.end())
|
||||
{
|
||||
surfacePointList = surfacePoints->second;
|
||||
}
|
||||
}
|
||||
|
||||
// m_surfacePoints is a mapping of locations to surface tags / weights that should be returned.
|
||||
AZStd::unordered_map<AZStd::pair<float, float>, SurfaceData::SurfacePointList> m_surfacePoints;
|
||||
|
||||
// m_bounds is the AABB to use for our mock surface provider.
|
||||
AZ::Aabb m_bounds;
|
||||
|
||||
// m_tags are the possible set of tags that this provider will return.
|
||||
SurfaceData::SurfaceTagVector m_tags;
|
||||
|
||||
SurfaceData::SurfaceDataRegistryHandle m_providerHandle = SurfaceData::InvalidSurfaceDataRegistryHandle;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -57,6 +57,10 @@ namespace SurfaceData
|
||||
void UpdateSurfaceDataModifier(const SurfaceDataRegistryHandle& handle, const SurfaceDataRegistryEntry& entry) override;
|
||||
|
||||
void RefreshSurfaceData(const AZ::Aabb& dirtyArea) override;
|
||||
|
||||
SurfaceDataRegistryHandle GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) override;
|
||||
SurfaceDataRegistryHandle GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) override;
|
||||
|
||||
private:
|
||||
SurfaceDataRegistryHandle RegisterSurfaceDataProviderInternal(const SurfaceDataRegistryEntry& entry);
|
||||
SurfaceDataRegistryEntry UnregisterSurfaceDataProviderInternal(const SurfaceDataRegistryHandle& handle);
|
||||
@@ -58,6 +58,10 @@ namespace SurfaceData
|
||||
|
||||
// Notify any dependent systems that they need to refresh their surface data for the provided area.
|
||||
virtual void RefreshSurfaceData(const AZ::Aabb& dirtyArea) = 0;
|
||||
|
||||
// Get the SurfaceDataRegistryHandle for a given entityId.
|
||||
virtual SurfaceDataRegistryHandle GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) = 0;
|
||||
virtual SurfaceDataRegistryHandle GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) = 0;
|
||||
};
|
||||
|
||||
typedef AZ::EBus<SurfaceDataSystemRequests> SurfaceDataSystemRequestBus;
|
||||
|
||||
@@ -250,6 +250,16 @@ namespace UnitTest
|
||||
{
|
||||
}
|
||||
|
||||
SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) override
|
||||
{
|
||||
return GetSurfaceProviderHandle(providerEntityId);
|
||||
}
|
||||
|
||||
SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) override
|
||||
{
|
||||
return GetSurfaceModifierHandle(modifierEntityId);
|
||||
}
|
||||
|
||||
SurfaceData::SurfaceDataRegistryHandle GetSurfaceProviderHandle(AZ::EntityId id)
|
||||
{
|
||||
return GetEntryHandle(id, m_providers);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "SurfaceDataColliderComponent.h"
|
||||
#include <SurfaceData/Components/SurfaceDataColliderComponent.h>
|
||||
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "SurfaceDataShapeComponent.h"
|
||||
#include <SurfaceData/Components/SurfaceDataShapeComponent.h>
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzCore/Debug/Profiler.h>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <AzCore/Module/Module.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
||||
#include <Components/SurfaceDataColliderComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataColliderComponent.h>
|
||||
#include <LmbrCentral/Component/EditorWrappedComponentBase.h>
|
||||
|
||||
namespace SurfaceData
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <AzCore/Module/Module.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
|
||||
#include <Components/SurfaceDataShapeComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataShapeComponent.h>
|
||||
#include <LmbrCentral/Component/EditorWrappedComponentBase.h>
|
||||
|
||||
namespace SurfaceData
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <SurfaceDataEditorModule.h>
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
#include <Editor/EditorSurfaceDataSystemComponent.h>
|
||||
#include <Editor/EditorSurfaceDataColliderComponent.h>
|
||||
#include <Editor/EditorSurfaceDataShapeComponent.h>
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
#include <SurfaceDataModule.h>
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <Components/SurfaceDataColliderComponent.h>
|
||||
#include <Components/SurfaceDataShapeComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataColliderComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataShapeComponent.h>
|
||||
|
||||
namespace SurfaceData
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/std/sort.h>
|
||||
|
||||
#include "SurfaceDataSystemComponent.h"
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceData/SurfaceDataConstants.h>
|
||||
#include <SurfaceData/SurfaceTag.h>
|
||||
#include <SurfaceData/SurfaceDataSystemNotificationBus.h>
|
||||
@@ -175,6 +175,34 @@ namespace SurfaceData
|
||||
SurfaceDataSystemNotificationBus::Broadcast(&SurfaceDataSystemNotificationBus::Events::OnSurfaceChanged, AZ::EntityId(), dirtyBounds, dirtyBounds);
|
||||
}
|
||||
|
||||
SurfaceDataRegistryHandle SurfaceDataSystemComponent::GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId)
|
||||
{
|
||||
AZStd::shared_lock<decltype(m_registrationMutex)> registrationLock(m_registrationMutex);
|
||||
|
||||
for (auto& [providerHandle, providerEntry] : m_registeredSurfaceDataProviders)
|
||||
{
|
||||
if (providerEntry.m_entityId == providerEntityId)
|
||||
{
|
||||
return providerHandle;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
SurfaceDataRegistryHandle SurfaceDataSystemComponent::GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId)
|
||||
{
|
||||
AZStd::shared_lock<decltype(m_registrationMutex)> registrationLock(m_registrationMutex);
|
||||
|
||||
for (auto& [modifierHandle, modifierEntry] : m_registeredSurfaceDataModifiers)
|
||||
{
|
||||
if (modifierEntry.m_entityId == modifierEntityId)
|
||||
{
|
||||
return modifierHandle;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void SurfaceDataSystemComponent::GetSurfacePoints(const AZ::Vector3& inPosition, const SurfaceTagVector& desiredTags, SurfacePointList& surfacePointList) const
|
||||
{
|
||||
const bool useTagFilters = HasValidTags(desiredTags);
|
||||
|
||||
@@ -226,9 +226,7 @@ namespace SurfaceData
|
||||
|
||||
void SurfacePointList::ReserveSpace(size_t maxPointsPerInput)
|
||||
{
|
||||
AZ_Assert(
|
||||
m_surfacePositionList.size() < maxPointsPerInput,
|
||||
"Trying to reserve space on a list that is already using more points than requested.");
|
||||
AZ_Assert(m_surfacePositionList.empty(), "Trying to reserve space on a list that is already being used.");
|
||||
|
||||
m_surfaceCreatorIdList.reserve(maxPointsPerInput);
|
||||
m_surfacePositionList.reserve(maxPointsPerInput);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <LmbrCentral/Shape/BoxShapeComponentBus.h>
|
||||
#include <LmbrCentral/Shape/CylinderShapeComponentBus.h>
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <Components/SurfaceDataShapeComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataShapeComponent.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
|
||||
#include <Source/Components/SurfaceDataColliderComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataColliderComponent.h>
|
||||
|
||||
#include <AzFramework/Physics/Common/PhysicsSceneQueries.h>
|
||||
#include <AzFramework/Physics/Shape.h>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Script/ScriptContext.h>
|
||||
#include <AzCore/std/chrono/clocks.h>
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceDataModule.h>
|
||||
#include <SurfaceData/SurfaceDataProviderRequestBus.h>
|
||||
#include <SurfaceData/SurfaceDataModifierRequestBus.h>
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <SurfaceData/Tests/SurfaceDataTestMocks.h>
|
||||
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
#include <SurfaceDataSystemComponent.h>
|
||||
#include <Components/SurfaceDataColliderComponent.h>
|
||||
#include <Components/SurfaceDataShapeComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataSystemComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataColliderComponent.h>
|
||||
#include <SurfaceData/Components/SurfaceDataShapeComponent.h>
|
||||
|
||||
|
||||
namespace UnitTest
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Include/SurfaceData/Components/SurfaceDataColliderComponent.h
|
||||
Include/SurfaceData/Components/SurfaceDataShapeComponent.h
|
||||
Include/SurfaceData/Components/SurfaceDataSystemComponent.h
|
||||
Include/SurfaceData/SurfaceDataConstants.h
|
||||
Include/SurfaceData/SurfaceDataTypes.h
|
||||
Include/SurfaceData/SurfaceDataSystemRequestBus.h
|
||||
@@ -18,12 +21,9 @@ set(FILES
|
||||
Include/SurfaceData/SurfaceTag.h
|
||||
Include/SurfaceData/Utility/SurfaceDataUtility.h
|
||||
Source/SurfaceDataSystemComponent.cpp
|
||||
Source/SurfaceDataSystemComponent.h
|
||||
Source/SurfaceDataTypes.cpp
|
||||
Source/SurfaceTag.cpp
|
||||
Source/Components/SurfaceDataColliderComponent.cpp
|
||||
Source/Components/SurfaceDataColliderComponent.h
|
||||
Source/Components/SurfaceDataShapeComponent.cpp
|
||||
Source/Components/SurfaceDataShapeComponent.h
|
||||
Source/SurfaceDataUtility.cpp
|
||||
)
|
||||
|
||||
@@ -384,6 +384,16 @@ namespace UnitTest
|
||||
{
|
||||
++m_count;
|
||||
}
|
||||
|
||||
SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataProviderHandle([[maybe_unused]] const AZ::EntityId& providerEntityId) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataModifierHandle([[maybe_unused]] const AZ::EntityId& modifierEntityId) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
struct MockMeshAsset
|
||||
|
||||
Reference in New Issue
Block a user