From b17c5ca3e684fc1bb1a42adff141bd13e6993a08 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Fri, 18 Jun 2021 14:09:34 +0100 Subject: [PATCH] adding physics tick time to post simulate event (#1401) --- .../AzFramework/AzFramework/Physics/Common/PhysicsEvents.h | 3 ++- .../AzFramework/AzFramework/Physics/PhysicsSystem.cpp | 2 +- Gems/PhysX/Code/Source/System/PhysXSystem.cpp | 2 +- Gems/PhysX/Code/Tests/PhysXSystemTests.cpp | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsEvents.h b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsEvents.h index a3a34dc1df..e0a89e14ac 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsEvents.h +++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsEvents.h @@ -48,7 +48,8 @@ namespace AzPhysics using OnPresimulateEvent = AZ::Event; //! Event triggers at the end of the SystemInterface::Simulate call. - using OnPostsimulateEvent = AZ::Event<>; + //! Parameter is the total time that the physics system will run for during the Simulate call. + using OnPostsimulateEvent = AZ::Event; //! Event trigger when a Scene is added to the simulation. //! When triggered will send the handle to the new Scene. diff --git a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp index 289b5a940b..aa17b7ec83 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp @@ -43,7 +43,7 @@ namespace AzPhysics const AZ::BehaviorAzEventDescription postsimulateEventDescription = { "Postsimulate event", - {} // Parameters + {"Tick time"} // Parameters }; behaviorContext->Class("System Interface") diff --git a/Gems/PhysX/Code/Source/System/PhysXSystem.cpp b/Gems/PhysX/Code/Source/System/PhysXSystem.cpp index 92f68ea13b..0e4c72b77e 100644 --- a/Gems/PhysX/Code/Source/System/PhysXSystem.cpp +++ b/Gems/PhysX/Code/Source/System/PhysXSystem.cpp @@ -198,7 +198,7 @@ namespace PhysX simulateScenes(tickTime); } - m_postSimulateEvent.Signal(); + m_postSimulateEvent.Signal(tickTime); } AzPhysics::SceneHandle PhysXSystem::AddScene(const AzPhysics::SceneConfiguration& config) diff --git a/Gems/PhysX/Code/Tests/PhysXSystemTests.cpp b/Gems/PhysX/Code/Tests/PhysXSystemTests.cpp index 5c3636d040..910a421b65 100644 --- a/Gems/PhysX/Code/Tests/PhysXSystemTests.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSystemTests.cpp @@ -219,8 +219,9 @@ namespace PhysX preSimEventCount++; }); AzPhysics::SystemEvents::OnPostsimulateEvent::Handler postSimEvent( - [&postSimEventCount]() + [&expectedTickTime, &postSimEventCount](float deltaTime) { + EXPECT_NEAR(expectedTickTime, deltaTime, 0.001f); postSimEventCount++; }); physicsSystem->RegisterPreSimulateEvent(preSimEvent);