2fe4524458
* 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>
97 lines
3.3 KiB
C++
97 lines
3.3 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#ifdef HAVE_BENCHMARK
|
|
|
|
#include <Benchmarks/PhysXBenchmarksCommon.h>
|
|
#include <Material.h>
|
|
#include <PhysXTestUtil.h>
|
|
#include <PhysXTestCommon.h>
|
|
|
|
namespace PhysX::Benchmarks
|
|
{
|
|
PhysXBenchmarkEnvironment::~PhysXBenchmarkEnvironment()
|
|
{
|
|
//within our scene queries we use thread_locals, as a result the allocator needs to be around until the module is cleaned up.
|
|
//having the allocator cleaned up here rather then in TeardownInternal() allows it to be around long enough to clean up resource nicely.
|
|
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
|
|
}
|
|
|
|
void PhysXBenchmarkEnvironment::SetUpBenchmark()
|
|
{
|
|
PhysX::Environment::SetupInternal();
|
|
}
|
|
void PhysXBenchmarkEnvironment::TearDownBenchmark()
|
|
{
|
|
PhysX::Environment::TeardownInternal();
|
|
}
|
|
|
|
AzPhysics::SceneHandle PhysXBaseBenchmarkFixture::GetDefaultSceneHandle() const
|
|
{
|
|
return m_testSceneHandle;
|
|
}
|
|
|
|
void PhysXBaseBenchmarkFixture::UpdateSimulation(unsigned int numFrames, float timeStep /*= DefaultTimeStep*/)
|
|
{
|
|
if (auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get())
|
|
{
|
|
for (AZ::u32 i = 0; i < numFrames; i++)
|
|
{
|
|
physicsSystem->Simulate(timeStep);
|
|
}
|
|
}
|
|
}
|
|
|
|
void PhysXBaseBenchmarkFixture::StepScene1Tick(float timeStep /*= DefaultTimeStep*/)
|
|
{
|
|
m_defaultScene->StartSimulation(timeStep);
|
|
m_defaultScene->FinishSimulation();
|
|
}
|
|
|
|
void PhysXBaseBenchmarkFixture::SetUpInternal()
|
|
{
|
|
m_testSceneHandle = CreateDefaultTestScene(); //create the default scene
|
|
if (auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get())
|
|
{
|
|
m_defaultScene = physicsSystem->GetScene(m_testSceneHandle);
|
|
}
|
|
|
|
Physics::DefaultWorldBus::Handler::BusConnect();
|
|
}
|
|
|
|
void PhysXBaseBenchmarkFixture::TearDownInternal()
|
|
{
|
|
//cleanup materials in case some where created
|
|
PhysX::MaterialManagerRequestsBus::Broadcast(&PhysX::MaterialManagerRequestsBus::Events::ReleaseAllMaterials);
|
|
Physics::DefaultWorldBus::Handler::BusDisconnect();
|
|
|
|
//Clean up the test scene
|
|
m_defaultScene = nullptr;
|
|
if (auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get())
|
|
{
|
|
physicsSystem->RemoveScene(m_testSceneHandle);
|
|
}
|
|
m_testSceneHandle = AzPhysics::InvalidSceneHandle;
|
|
|
|
TestUtils::ResetPhysXSystem();
|
|
}
|
|
|
|
AzPhysics::SceneHandle PhysXBaseBenchmarkFixture::CreateDefaultTestScene()
|
|
{
|
|
if (auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get())
|
|
{
|
|
AzPhysics::SceneConfiguration sceneConfiguration = GetDefaultSceneConfiguration();
|
|
sceneConfiguration.m_sceneName = "BenchmarkWorld";
|
|
AzPhysics::SceneHandle sceneHandle = physicsSystem->AddScene(sceneConfiguration);
|
|
return sceneHandle;
|
|
}
|
|
return AzPhysics::InvalidSceneHandle;
|
|
}
|
|
} //namespace PhysX::Benchmarks
|
|
#endif //HAVE_BENCHMARK
|