Base object interface for solver objects. 更多...
#include <PhysicsProxy.h>
继承自 IPhysicsProxyBase .
Public 成员函数 | |
| void | BindParticleCallbackMapping (Chaos::TArrayCollectionArray< PhysicsProxyWrapper > &PhysicsProxyReverseMap, Chaos::TArrayCollectionArray< int32 > &ParticleIDReverseMap) |
| The Particle Binding creates a connection between the particles in the simulation and the solver objects dataset. | |
| template<typename Traits > | |
| void | BufferCommand (Chaos::TPBDRigidsSolver< Traits > *InSolver, const FFieldSystemCommand &InCommand) |
| Called to buffer a command to be processed at the next available safe opportunity | |
| void | BufferPhysicsResults () |
| CONTEXT: PHYSICSTHREAD Called per-tick after the simulation has completed. 更多... | |
| void | ClearAccumulatedData () |
| CONTEXT: GAMETHREAD Returns a new unmanaged allocation of the data saved on the handle, otherwise nullptr 更多... | |
| EPhysicsProxyType | ConcreteType () |
| Returns the concrete type of the derived class | |
| void | FlipBuffer () |
| CONTEXT: PHYSICSTHREAD (Write Locked) Called by the physics thread to signal that it is safe to perform any double-buffer flips here. 更多... | |
| virtual UObject * | GetOwner () const override |
| Gets the owning external object for this solver object, never used internally | |
| bool | IsSimulating () const |
| The following functions are to be implemented by all solver objects as we're using CRTP / F-Bound to statically dispatch the calls. 更多... | |
| void | OnRemoveFromScene () |
| CONTEXT: PHYSICSTHREAD Called on the physics thread when the engine is shutting down the proxy and we need to remove it from any active simulations. 更多... | |
| bool | PullFromPhysicsState (const int32 SolverSyncTimestamp) |
| CONTEXT: GAMETHREAD (Read Locked) Perform a similar operation to Sync, but take the data from a gamethread-safe buffer. 更多... | |
| void | SyncBeforeDestroy () |
| CONTEXT: GAMETHREAD Called during the gamethread sync after the proxy has been removed from its solver intended for final handoff of any data the proxy has that the gamethread may be interested in | |
| virtual | ~TPhysicsProxy () |
| Virtual destructor for derived objects, ideally no other virtuals should exist in this chain | |
Base object interface for solver objects.
Defines the expected API for objects uses CRTP for static dispatch, entire API considered "pure-virtual" and must be* defined. Forgetting to implement any of the interface functions will give errors regarding recursion on all control paths for TPhysicsProxy<T> where T will be the type that has not correctly implemented the API.
PersistentTask uses IPhysicsProxyBase, so when implementing a new specialized type it is necessary to include its header file in PersistentTask.cpp allowing the linker to properly resolve the new type.
May not be necessary overall once the engine has solidified - we can just use the final concrete objects but this gives us almost the same flexibility as the old callbacks while solving most of the drawbacks (virtual dispatch, cross-object interaction)
#BG TODO - rename the callbacks functions, document for the base solver object
|
inline |
CONTEXT: PHYSICSTHREAD Called per-tick after the simulation has completed.
The proxy should cache the results of their simulation into the local buffer.
|
inline |
CONTEXT: GAMETHREAD Returns a new unmanaged allocation of the data saved on the handle, otherwise nullptr
CONTEXT: GAMETHREAD -> to -> PHYSICSTHREAD Called on the game thread when the solver is about to advance forward. This callback should Enqueue commands on the PhysicsThread to update the state of the solver CONTEXT: GAMETHREAD Called on game thread after NewData has been called to buffer the particle data for physics. The purpose of this method is to clear data, such as external force and torque, which have been accumulated over a game tick. Buffering these values once means they'll be accounted for in physics. If they are not cleared, then they may "overaccumulate".
|
inline |
CONTEXT: PHYSICSTHREAD (Write Locked) Called by the physics thread to signal that it is safe to perform any double-buffer flips here.
The physics thread has pre-locked an RW lock for this operation so the game thread won't be reading the data
|
inline |
The following functions are to be implemented by all solver objects as we're using CRTP / F-Bound to statically dispatch the calls.
Any common functions should be added here and to the derived solver objects
|
inline |
CONTEXT: PHYSICSTHREAD Called on the physics thread when the engine is shutting down the proxy and we need to remove it from any active simulations.
Proxies are expected to entirely clean up their simulation state within this method. This is run in the task command step by the scene so the simulation will currently be idle
|
inline |
CONTEXT: GAMETHREAD (Read Locked) Perform a similar operation to Sync, but take the data from a gamethread-safe buffer.
This will be called from the game thread when it cannot sync to the physics thread. The simulation is very likely to be running when this happens so never read any physics thread data here!
SyncTimestamp indicates which inputs the solver used to generate these results. Proxy can stomp results if needed For example of particle has been deleted, or a position was set manually by game thread, the proxy ignores the solver results Returns true if the data was pulled. If false is returned the proxy's particle pointer may be dangling so do not read from it. Skip sync entirely
Note: A read lock will have been acquired for this - so the physics thread won't force a buffer flip while this sync is ongoing