RigsofRods
Soft-body Physics Simulation
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
RoR::ActorManager Class Reference

Builds and manages softbody actors (physics on background thread, networking) More...

#include <ActorManager.h>

+ Collaboration diagram for RoR::ActorManager:

Public Member Functions

 ActorManager ()
 
 ~ActorManager ()
 
void UpdateActors (ActorPtr player_actor)
 
void SyncWithSimThread ()
 
void UpdatePhysicsSimulation ()
 
void WakeUpAllActors ()
 
void SendAllActorsSleeping ()
 
unsigned long GetNetTime ()
 
int GetNetTimeOffset (int sourceid)
 
void UpdateNetTimeOffset (int sourceid, int offset)
 
void AddStreamMismatch (int sourceid, int streamid)
 
int CheckNetworkStreamsOk (int sourceid)
 
int CheckNetRemoteStreamsOk (int sourceid)
 
void MuteAllActors ()
 
void UnmuteAllActors ()
 
void SetTrucksForcedAwake (bool forced)
 
bool AreTrucksForcedAwake () const
 
void SetSimulationSpeed (float speed)
 
float GetSimulationSpeed () const
 
bool IsSimulationPaused () const
 
void SetSimulationPaused (bool v)
 
float GetTotalTime () const
 
RoR::CmdKeyInertiaConfigGetInertiaConfig ()
 
void CleanUpSimulation ()
 Call this after simulation loop finishes. More...
 
void RepairActor (Collisions *collisions, const Ogre::String &inst, const Ogre::String &box, bool keepPosition=false)
 
void UpdateSleepingState (ActorPtr player_actor, float dt)
 
void UpdateInputEvents (float dt)
 
RigDef::DocumentPtr FetchActorDef (std::string filename, bool predefined_on_terrain=false)
 
void HandleActorStreamData (std::vector< RoR::NetRecvPacket > packet)
 
bool LoadScene (Ogre::String filename)
 
bool SaveScene (Ogre::String filename)
 
void RestoreSavedState (ActorPtr actor, rapidjson::Value const &j_entry)
 
ActorPtrVecGetActors ()
 
std::vector< ActorPtrGetLocalActors ()
 
std::pair< ActorPtr, float > GetNearestActor (Ogre::Vector3 position)
 
Lifetime
ActorPtr CreateNewActor (ActorSpawnRequest rq, RigDef::DocumentPtr def)
 
void DeleteActorInternal (ActorPtr actor)
 Do not call directly; use GameContext::DeleteActor() More...
 
Lookup
const ActorPtrGetActorById (ActorInstanceID_t actor_id)
 
const ActorPtrGetActorByNetworkLinks (int source_id, int stream_id)
 
ActorPtr FindActorInsideBox (Collisions *collisions, const Ogre::String &inst, const Ogre::String &box)
 
const ActorPtrFetchNextVehicleOnList (ActorPtr player, ActorPtr prev_player)
 
const ActorPtrFetchPreviousVehicleOnList (ActorPtr player, ActorPtr prev_player)
 
const ActorPtrFetchRescueVehicle ()
 

Static Public Attributes

static const ActorPtr ACTORPTR_NULL
 

Private Member Functions

bool CheckActorCollAabbIntersect (int a, int b)
 Returns whether or not the bounding boxes of truck a and truck b intersect. Based on the truck collision bounding boxes. More...
 
bool PredictActorCollAabbIntersect (int a, int b)
 Returns whether or not the bounding boxes of truck a and truck b might intersect during the next framestep. Based on the truck collision bounding boxes. More...
 
void RemoveStreamSource (int sourceid)
 
void RecursiveActivation (int j, std::vector< bool > &visited)
 
void ForwardCommands (ActorPtr source_actor)
 Fowards things to trailers. More...
 
void UpdateTruckFeatures (ActorPtr vehicle, float dt)
 

Private Attributes

std::map< int, std::set< int > > m_stream_mismatches
 Networking: A set of streams without a corresponding actor in the actor-array for each stream source. More...
 
std::map< int, int > m_stream_time_offsets
 Networking: A network time offset for each stream source. More...
 
Ogre::Timer m_net_timer
 
ActorPtrVec m_actors
 
bool m_forced_awake = false
 disables sleep counters More...
 
int m_physics_steps = 0
 
float m_dt_remainder = 0.f
 Keeps track of the rounding error in the time step calculation. More...
 
float m_simulation_speed = 1.f
 slow motion < 1.0 < fast motion More...
 
float m_last_simulation_speed = 0.1f
 previously used time ratio between real time (evt.timeSinceLastFrame) and physics time ('dt' used in calcPhysics) More...
 
float m_simulation_time = 0.f
 Amount of time the physics simulation is going to be advanced. More...
 
bool m_simulation_paused = false
 
float m_total_sim_time = 0.f
 
std::unique_ptr< ThreadPoolm_sim_thread_pool
 
std::shared_ptr< Taskm_sim_task
 
RoR::CmdKeyInertiaConfig m_inertia_config
 

Actor grouping

std::map< beam_t *, std::pair< ActorPtr, ActorPtr > > inter_actor_links
 
void SyncLinkedActors ()
 

Detailed Description

Builds and manages softbody actors (physics on background thread, networking)

Definition at line 43 of file ActorManager.h.

Constructor & Destructor Documentation

◆ ActorManager()

ActorManager::ActorManager ( )

Definition at line 64 of file ActorManager.cpp.

◆ ~ActorManager()

ActorManager::~ActorManager ( )

Definition at line 74 of file ActorManager.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddStreamMismatch()

void RoR::ActorManager::AddStreamMismatch ( int  sourceid,
int  streamid 
)
inline

Definition at line 74 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ AreTrucksForcedAwake()

bool RoR::ActorManager::AreTrucksForcedAwake ( ) const
inline

Definition at line 80 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ CheckActorCollAabbIntersect()

bool ActorManager::CheckActorCollAabbIntersect ( int  a,
int  b 
)
private

Returns whether or not the bounding boxes of truck a and truck b intersect. Based on the truck collision bounding boxes.

Definition at line 570 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ CheckNetRemoteStreamsOk()

int ActorManager::CheckNetRemoteStreamsOk ( int  sourceid)

Definition at line 538 of file ActorManager.cpp.

◆ CheckNetworkStreamsOk()

int ActorManager::CheckNetworkStreamsOk ( int  sourceid)

Definition at line 519 of file ActorManager.cpp.

◆ CleanUpSimulation()

void ActorManager::CleanUpSimulation ( )

Call this after simulation loop finishes.

Definition at line 913 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateNewActor()

ActorPtr ActorManager::CreateNewActor ( ActorSpawnRequest  rq,
RigDef::DocumentPtr  def 
)

Definition at line 79 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteActorInternal()

void ActorManager::DeleteActorInternal ( ActorPtr  actor)

Do not call directly; use GameContext::DeleteActor()

Definition at line 926 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FetchActorDef()

RigDef::DocumentPtr ActorManager::FetchActorDef ( std::string  filename,
bool  predefined_on_terrain = false 
)

Definition at line 1275 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FetchNextVehicleOnList()

const ActorPtr & ActorManager::FetchNextVehicleOnList ( ActorPtr  player,
ActorPtr  prev_player 
)

Definition at line 987 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FetchPreviousVehicleOnList()

const ActorPtr & ActorManager::FetchPreviousVehicleOnList ( ActorPtr  player,
ActorPtr  prev_player 
)

Definition at line 1012 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FetchRescueVehicle()

const ActorPtr & ActorManager::FetchRescueVehicle ( )

Definition at line 1039 of file ActorManager.cpp.

◆ FindActorInsideBox()

ActorPtr ActorManager::FindActorInsideBox ( Collisions collisions,
const Ogre::String &  inst,
const Ogre::String &  box 
)

Definition at line 848 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ForwardCommands()

void ActorManager::ForwardCommands ( ActorPtr  source_actor)
private

Fowards things to trailers.

Definition at line 653 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetActorById()

const ActorPtr & ActorManager::GetActorById ( ActorInstanceID_t  actor_id)

Definition at line 1167 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ GetActorByNetworkLinks()

const ActorPtr & ActorManager::GetActorByNetworkLinks ( int  source_id,
int  stream_id 
)

Definition at line 557 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ GetActors()

ActorPtrVec& RoR::ActorManager::GetActors ( )
inline

Definition at line 107 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ GetInertiaConfig()

RoR::CmdKeyInertiaConfig& RoR::ActorManager::GetInertiaConfig ( )
inline

Definition at line 86 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ GetLocalActors()

std::vector< ActorPtr > ActorManager::GetLocalActors ( )

Definition at line 1361 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ GetNearestActor()

std::pair< ActorPtr, float > ActorManager::GetNearestActor ( Ogre::Vector3  position)

Definition at line 897 of file ActorManager.cpp.

◆ GetNetTime()

unsigned long RoR::ActorManager::GetNetTime ( )
inline

Definition at line 71 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ GetNetTimeOffset()

int ActorManager::GetNetTimeOffset ( int  sourceid)

Definition at line 501 of file ActorManager.cpp.

◆ GetSimulationSpeed()

float RoR::ActorManager::GetSimulationSpeed ( ) const
inline

Definition at line 82 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ GetTotalTime()

float RoR::ActorManager::GetTotalTime ( ) const
inline

Definition at line 85 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ HandleActorStreamData()

void ActorManager::HandleActorStreamData ( std::vector< RoR::NetRecvPacket packet)

Definition at line 359 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsSimulationPaused()

bool RoR::ActorManager::IsSimulationPaused ( ) const
inline

Definition at line 83 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ LoadScene()

bool ActorManager::LoadScene ( Ogre::String  filename)

Definition at line 239 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MuteAllActors()

void ActorManager::MuteAllActors ( )

Definition at line 881 of file ActorManager.cpp.

◆ PredictActorCollAabbIntersect()

bool ActorManager::PredictActorCollAabbIntersect ( int  a,
int  b 
)
private

Returns whether or not the bounding boxes of truck a and truck b might intersect during the next framestep. Based on the truck collision bounding boxes.

Definition at line 599 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ RecursiveActivation()

void ActorManager::RecursiveActivation ( int  j,
std::vector< bool > &  visited 
)
private

Definition at line 628 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveStreamSource()

void ActorManager::RemoveStreamSource ( int  sourceid)
private

Definition at line 342 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RepairActor()

void ActorManager::RepairActor ( Collisions collisions,
const Ogre::String &  inst,
const Ogre::String &  box,
bool  keepPosition = false 
)

Definition at line 867 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RestoreSavedState()

void ActorManager::RestoreSavedState ( ActorPtr  actor,
rapidjson::Value const &  j_entry 
)

Definition at line 783 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveScene()

bool ActorManager::SaveScene ( Ogre::String  filename)

Definition at line 421 of file Savegame.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendAllActorsSleeping()

void ActorManager::SendAllActorsSleeping ( )

Definition at line 836 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ SetSimulationPaused()

void RoR::ActorManager::SetSimulationPaused ( bool  v)
inline

Definition at line 84 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ SetSimulationSpeed()

void RoR::ActorManager::SetSimulationSpeed ( float  speed)
inline

Definition at line 81 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ SetTrucksForcedAwake()

void RoR::ActorManager::SetTrucksForcedAwake ( bool  forced)
inline

Definition at line 79 of file ActorManager.h.

+ Here is the caller graph for this function:

◆ SyncLinkedActors()

void ActorManager::SyncLinkedActors ( )

Definition at line 752 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SyncWithSimThread()

void ActorManager::SyncWithSimThread ( )

Definition at line 1256 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ UnmuteAllActors()

void ActorManager::UnmuteAllActors ( )

Definition at line 889 of file ActorManager.cpp.

◆ UpdateActors()

void ActorManager::UpdateActors ( ActorPtr  player_actor)

Definition at line 1051 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateInputEvents()

void ActorManager::UpdateInputEvents ( float  dt)

Definition at line 1372 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateNetTimeOffset()

void ActorManager::UpdateNetTimeOffset ( int  sourceid,
int  offset 
)

Definition at line 511 of file ActorManager.cpp.

+ Here is the caller graph for this function:

◆ UpdatePhysicsSimulation()

void ActorManager::UpdatePhysicsSimulation ( )

Definition at line 1179 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateSleepingState()

void ActorManager::UpdateSleepingState ( ActorPtr  player_actor,
float  dt 
)

Definition at line 779 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateTruckFeatures()

void ActorManager::UpdateTruckFeatures ( ActorPtr  vehicle,
float  dt 
)
private

Definition at line 1462 of file ActorManager.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WakeUpAllActors()

void ActorManager::WakeUpAllActors ( )

Definition at line 824 of file ActorManager.cpp.

+ Here is the caller graph for this function:

Field Documentation

◆ ACTORPTR_NULL

const ActorPtr ActorManager::ACTORPTR_NULL
static

Definition at line 119 of file ActorManager.h.

◆ inter_actor_links

std::map<beam_t*, std::pair<ActorPtr, ActorPtr> > RoR::ActorManager::inter_actor_links

Definition at line 115 of file ActorManager.h.

◆ m_actors

ActorPtrVec RoR::ActorManager::m_actors
private

Definition at line 136 of file ActorManager.h.

◆ m_dt_remainder

float RoR::ActorManager::m_dt_remainder = 0.f
private

Keeps track of the rounding error in the time step calculation.

Definition at line 139 of file ActorManager.h.

◆ m_forced_awake

bool RoR::ActorManager::m_forced_awake = false
private

disables sleep counters

Definition at line 137 of file ActorManager.h.

◆ m_inertia_config

RoR::CmdKeyInertiaConfig RoR::ActorManager::m_inertia_config
private

Definition at line 149 of file ActorManager.h.

◆ m_last_simulation_speed

float RoR::ActorManager::m_last_simulation_speed = 0.1f
private

previously used time ratio between real time (evt.timeSinceLastFrame) and physics time ('dt' used in calcPhysics)

Definition at line 141 of file ActorManager.h.

◆ m_net_timer

Ogre::Timer RoR::ActorManager::m_net_timer
private

Definition at line 133 of file ActorManager.h.

◆ m_physics_steps

int RoR::ActorManager::m_physics_steps = 0
private

Definition at line 138 of file ActorManager.h.

◆ m_sim_task

std::shared_ptr<Task> RoR::ActorManager::m_sim_task
private

Definition at line 148 of file ActorManager.h.

◆ m_sim_thread_pool

std::unique_ptr<ThreadPool> RoR::ActorManager::m_sim_thread_pool
private

Definition at line 147 of file ActorManager.h.

◆ m_simulation_paused

bool RoR::ActorManager::m_simulation_paused = false
private

Definition at line 143 of file ActorManager.h.

◆ m_simulation_speed

float RoR::ActorManager::m_simulation_speed = 1.f
private

slow motion < 1.0 < fast motion

Definition at line 140 of file ActorManager.h.

◆ m_simulation_time

float RoR::ActorManager::m_simulation_time = 0.f
private

Amount of time the physics simulation is going to be advanced.

Definition at line 142 of file ActorManager.h.

◆ m_stream_mismatches

std::map<int, std::set<int> > RoR::ActorManager::m_stream_mismatches
private

Networking: A set of streams without a corresponding actor in the actor-array for each stream source.

Definition at line 131 of file ActorManager.h.

◆ m_stream_time_offsets

std::map<int, int> RoR::ActorManager::m_stream_time_offsets
private

Networking: A network time offset for each stream source.

Definition at line 132 of file ActorManager.h.

◆ m_total_sim_time

float RoR::ActorManager::m_total_sim_time = 0.f
private

Definition at line 144 of file ActorManager.h.


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