Open 3D Engine AzFramework API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzPhysics::SystemInterface Class Referenceabstract

#include <PhysicsSystem.h>

Public Member Functions

 AZ_RTTI (SystemInterface, "{B6F4D92A-061B-4CB3-AAB5-984B599A53AE}")
 
 AZ_DISABLE_COPY_MOVE (SystemInterface)
 
virtual void Initialize (const SystemConfiguration *config)=0
 
virtual void Reinitialize ()=0
 
virtual void Shutdown ()=0
 
virtual void Simulate (float deltaTime)=0
 
virtual SceneHandle AddScene (const SceneConfiguration &config)=0
 
virtual SceneHandleList AddScenes (const SceneConfigurationList &configs)=0
 
virtual SceneHandle GetSceneHandle (const AZStd::string &sceneName)=0
 
virtual SceneGetScene (SceneHandle handle)=0
 
virtual SceneList GetScenes (const SceneHandleList &handles)=0
 
virtual SceneList & GetAllScenes ()=0
 
virtual void RemoveScene (SceneHandle handle)=0
 
virtual void RemoveScenes (const SceneHandleList &handles)=0
 
virtual void RemoveAllScenes ()=0
 Removes All Scenes.
 
virtual AZStd::pair< SceneHandle, SimulatedBodyHandle > FindAttachedBodyHandleFromEntityId (AZ::EntityId entityId)=0
 
virtual const SystemConfigurationGetConfiguration () const =0
 Get the current SystemConfiguration used to initialize the Physics system.
 
virtual void UpdateConfiguration (const SystemConfiguration *newConfig, bool forceReinitialization=false)=0
 
virtual void UpdateDefaultSceneConfiguration (const SceneConfiguration &sceneConfiguration)=0
 
virtual const SceneConfigurationGetDefaultSceneConfiguration () const =0
 Gets the current default scene configuration.
 
void RegisterSystemInitializedEvent (SystemEvents::OnInitializedEvent::Handler &handler)
 
void RegisterSystemReInitializedEvent (SystemEvents::OnReinitializedEvent::Handler &handler)
 
void RegisterSystemShutdownEvent (SystemEvents::OnShutdownEvent::Handler &handler)
 
void RegisterPreSimulateEvent (SystemEvents::OnPresimulateEvent::Handler &handler)
 
void RegisterPostSimulateEvent (SystemEvents::OnPostsimulateEvent::Handler &handler)
 
void RegisterSceneAddedEvent (SystemEvents::OnSceneAddedEvent::Handler &handler)
 
void RegisterSceneRemovedEvent (SystemEvents::OnSceneAddedEvent::Handler &handler)
 
void RegisterSystemConfigurationChangedEvent (SystemEvents::OnConfigurationChangedEvent::Handler &handler)
 
void RegisterOnDefaultSceneConfigurationChangedEventHandler (SystemEvents::OnDefaultSceneConfigurationChangedEvent::Handler &handler)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Protected Attributes

SystemEvents::OnInitializedEvent m_initializeEvent
 
SystemEvents::OnReinitializedEvent m_reinitializeEvent
 
SystemEvents::OnShutdownEvent m_shutdownEvent
 
SystemEvents::OnPresimulateEvent m_preSimulateEvent
 
SystemEvents::OnPostsimulateEvent m_postSimulateEvent
 
SystemEvents::OnSceneAddedEvent m_sceneAddedEvent
 
SystemEvents::OnSceneRemovedEvent m_sceneRemovedEvent
 
SystemEvents::OnConfigurationChangedEvent m_configChangeEvent
 
SystemEvents::OnDefaultSceneConfigurationChangedEvent m_onDefaultSceneConfigurationChangedEvent
 

Detailed Description

Interface to access the Physics System.

Member Function Documentation

◆ AddScene()

virtual SceneHandle AzPhysics::SystemInterface::AddScene ( const SceneConfiguration config)
pure virtual

Add a scene to the physics simulation.

Parameters
configThis is the Configuration of the scene to add.
Returns
Returns a SceneHandle of the Scene created or InvalidSceneHandle if it fails.

◆ AddScenes()

virtual SceneHandleList AzPhysics::SystemInterface::AddScenes ( const SceneConfigurationList &  configs)
pure virtual

Add multiple scenes to the physics simulation.

Parameters
configsThis is the list of SceneConfiguration objects to add.
Returns
Returns a list of SceneHandle objects for each created Scene. Order will be the same as the SceneConfigurationList provided.

◆ FindAttachedBodyHandleFromEntityId()

virtual AZStd::pair< SceneHandle, SimulatedBodyHandle > AzPhysics::SystemInterface::FindAttachedBodyHandleFromEntityId ( AZ::EntityId  entityId)
pure virtual

Helper to find the SceneHandle and SimulatedBodyHandle of a body related to the requested EntityId.

Note
This will search all scenes and maybe slow if there are many Scenes.
Parameters
entityIdThe entity to search for.
Returns
Will return a AZStd::pair of SceneHandle and SimulatedBodyHandle of the requested entityid, otherwise will return AzPhysics::InvalidSceneHandle, AzPhysics::SimulatedBodyHandle.

◆ GetAllScenes()

virtual SceneList & AzPhysics::SystemInterface::GetAllScenes ( )
pure virtual

Retrieve all current Scenes.

Returns
Returns a list of SceneInterface pointers.

◆ GetScene()

virtual Scene * AzPhysics::SystemInterface::GetScene ( SceneHandle  handle)
pure virtual

Get the Scene of the requested SceneHandle.

Parameters
handleThe SceneHandle of the requested scene.
Returns
Returns a Scene pointer if found, otherwise nullptr.

◆ GetSceneHandle()

virtual SceneHandle AzPhysics::SystemInterface::GetSceneHandle ( const AZStd::string &  sceneName)
pure virtual

Returns a Scene Handle connected to the given scene name.

Parameters
sceneNameThe name of the scene to look up.
Returns
Will return a SceneHandle to a Scene connected with the given name, otherwise will return InvalidSceneHandle.

◆ GetScenes()

virtual SceneList AzPhysics::SystemInterface::GetScenes ( const SceneHandleList &  handles)
pure virtual

Get multiple Scenes.

Parameters
handlesA list of SceneHandle objects to retrieve.
Returns
Returns a list of SceneInterface pointers. The order is the same as supplied. Pointer may be null if not a valid SceneHandle.

◆ Initialize()

virtual void AzPhysics::SystemInterface::Initialize ( const SystemConfiguration config)
pure virtual

Initialize the Physics system with the given configuration.

Parameters
configContains the configuration options

◆ RegisterOnDefaultSceneConfigurationChangedEventHandler()

void AzPhysics::SystemInterface::RegisterOnDefaultSceneConfigurationChangedEventHandler ( SystemEvents::OnDefaultSceneConfigurationChangedEvent::Handler &  handler)
inline

Register a handler to receive an event when the default SceneConfiguration changes.

Parameters
handlerThe handler to receive the event.

◆ RegisterPostSimulateEvent()

void AzPhysics::SystemInterface::RegisterPostSimulateEvent ( SystemEvents::OnPostsimulateEvent::Handler &  handler)
inline

Register to receive notifications when the Physics System simulation ends.

Parameters
handlerThe handler to receive the event.

◆ RegisterPreSimulateEvent()

void AzPhysics::SystemInterface::RegisterPreSimulateEvent ( SystemEvents::OnPresimulateEvent::Handler &  handler)
inline

Register to receive notifications when the Physics System simulation begins.

Parameters
handlerThe handler to receive the event.

◆ RegisterSceneAddedEvent()

void AzPhysics::SystemInterface::RegisterSceneAddedEvent ( SystemEvents::OnSceneAddedEvent::Handler &  handler)
inline

Register to receive notifications when the a new Scene is added to the simulation.

Parameters
handlerThe handler to receive the event.

◆ RegisterSceneRemovedEvent()

void AzPhysics::SystemInterface::RegisterSceneRemovedEvent ( SystemEvents::OnSceneAddedEvent::Handler &  handler)
inline

Register to receive notifications when the a Scene is removed from the simulation.

Parameters
handlerThe handler to receive the event.

◆ RegisterSystemConfigurationChangedEvent()

void AzPhysics::SystemInterface::RegisterSystemConfigurationChangedEvent ( SystemEvents::OnConfigurationChangedEvent::Handler &  handler)
inline

Register to receive notifications when the SystemConfiguration changes.

Parameters
handlerThe handler to receive the event.

◆ RegisterSystemInitializedEvent()

void AzPhysics::SystemInterface::RegisterSystemInitializedEvent ( SystemEvents::OnInitializedEvent::Handler &  handler)
inline

Register to receive notifications when the Physics System is Initialized.

Parameters
handlerThe handler to receive the event.

◆ RegisterSystemReInitializedEvent()

void AzPhysics::SystemInterface::RegisterSystemReInitializedEvent ( SystemEvents::OnReinitializedEvent::Handler &  handler)
inline

Register to receive notifications when the Physics System is reinitialized.

Parameters
handlerThe handler to receive the event.

◆ RegisterSystemShutdownEvent()

void AzPhysics::SystemInterface::RegisterSystemShutdownEvent ( SystemEvents::OnShutdownEvent::Handler &  handler)
inline

Register to receive notifications when the Physics System shuts down.

Parameters
handlerThe handler to receive the event.

◆ Reinitialize()

virtual void AzPhysics::SystemInterface::Reinitialize ( )
pure virtual

Will re-initialize the physics backend. Will preserve Scene and Simulation Body data along with any existing Handles.

◆ RemoveScene()

virtual void AzPhysics::SystemInterface::RemoveScene ( SceneHandle  handle)
pure virtual

Remove the requested Scene if it exists.

Parameters
handleThe handle to the scene to remove.

◆ RemoveScenes()

virtual void AzPhysics::SystemInterface::RemoveScenes ( const SceneHandleList &  handles)
pure virtual

Remove many Scenes if they exist.

Parameters
handlesA list of handles to each scene to remove.

◆ Shutdown()

virtual void AzPhysics::SystemInterface::Shutdown ( )
pure virtual

Teardown the whole Physics system. This removes all Scene and Simulation Body data, then physics will stop running.

◆ Simulate()

virtual void AzPhysics::SystemInterface::Simulate ( float  deltaTime)
pure virtual

Advance the Physics state. This will iterate the Scene list, update All simulation bodies and advance the physics state by the given delta time. It is recommended to call this function to run the physics tick. Advanced users may manually update each scene, if required to have finer control. This function will also signal the OnPresimulateEvent and OnPostsimulateEvent. The OnPresimulateEvent will have a parameter that will be the total time executed by the simulation. When SystemConfiguration::m_fixedTimestep is greater than zero, the simulation will run at the fixed time step and may run multiple steps per frame. This time can range from 0.0f to SystemConfiguration::m_maxTimestep. Where 0.0 time indicates that the simulation did not execute any steps this frame. When SystemConfiguration::m_fixedTimestep equal to or less than zero, the simulation will step once with a time between deltaTime and SystemConfiguration::m_maxTimestep. Example Advanced users might do to self manage Advancing the physics state.

//The following would be somewhere in the client code game update loop.
{
SceneInterfaceList& sceneList = system->GetAllScenes();
//Here you may want to order the update of the scenes, or only update specific scenes.
for(auto scene : sceneList)
{
//StartSimulation + FinishSimulation must be called in order.
scene->StartSimulation(deltatime); //spawns physics jobs.
//here you can perform other actions that do not rely on up to date physics.
scene->FinishSimulation(); //blocks until jobs are complete and swap buffers.
}
}
Definition: IRemoteTools.h:32
Parameters
deltaTimeThis is the time in seconds to simulate physics for this tick (60fps = 0.01666667). Typically the frame deltaTime of the game loop.

◆ UpdateConfiguration()

virtual void AzPhysics::SystemInterface::UpdateConfiguration ( const SystemConfiguration newConfig,
bool  forceReinitialization = false 
)
pure virtual

Update the SystemConfiguration. This will apply the new configuration, some properties may require the reinitialization of the physics system and will tear down all Scenes and Simulation bodies.

Parameters
newConfigThe new configuration to apply.
forceReinitializationFlag to force a reinitialization of the physics system. Default false.

◆ UpdateDefaultSceneConfiguration()

virtual void AzPhysics::SystemInterface::UpdateDefaultSceneConfiguration ( const SceneConfiguration sceneConfiguration)
pure virtual

Update the current default scene configuration. This is the configuration used to to create scenes without a custom configuration.

Parameters
sceneConfigurationThe new configuration to apply.

The documentation for this class was generated from the following file: