Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions | Private Attributes
RoR::ActorManager Class Reference

Description

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

Definition at line 44 of file ActorManager.h.

Public Types

typedef std::vector< FreeForce > FreeForceVec_t
 

Public Member Functions

 ActorManager ()
 
 ~ActorManager ()
 
void UpdateActors (ActorPtr player_actor)
 
void SyncWithSimThread ()
 
void UpdatePhysicsSimulation ()
 
void WakeUpAllActors ()
 
void SendAllActorsSleeping ()
 
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::CmdKeyInertiaConfig & GetInertiaConfig ()
 
void CleanUpSimulation ()
 
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 (RoR::ActorSpawnRequest &rq)
 
void ExportActorDef (RigDef::DocumentPtr def, std::string filename, std::string rg_name)
 
bool LoadScene (Ogre::String filename)
 
bool SaveScene (Ogre::String filename)
 
void RestoreSavedState (ActorPtr actor, rapidjson::Value const &j_entry)
 
ActorPtrVec & GetActors ()
 
std::vector< ActorPtr > GetLocalActors ()
 
std::pair< ActorPtr, float > GetNearestActor (Ogre::Vector3 position)
 
bool AreActorsDirectlyLinked (const ActorPtr &a1, const ActorPtr &a2)
 
Actor lifetime
ActorPtr CreateNewActor (ActorSpawnRequest rq, RigDef::DocumentPtr def)
 
void DeleteActorInternal (ActorPtr actor)
 
Actor lookup
const ActorPtr & GetActorById (ActorInstanceID_t actor_id)
 
const ActorPtr & GetActorByNetworkLinks (int source_id, int stream_id)
 
ActorPtr FindActorInsideBox (Collisions *collisions, const Ogre::String &inst, const Ogre::String &box)
 
const ActorPtr & FetchNextVehicleOnList (ActorPtr player, ActorPtr prev_player)
 
const ActorPtr & FetchPreviousVehicleOnList (ActorPtr player, ActorPtr prev_player)
 
const ActorPtr & FetchRescueVehicle ()
 
ActorInstanceID_t GetActorNextInstanceId ()
 
Free forces
void AddFreeForce (FreeForceRequest *rq)
 
void ModifyFreeForce (FreeForceRequest *rq)
 
void RemoveFreeForce (FreeForceID_t id)
 
bool FindFreeForce (FreeForceID_t id, FreeForceVec_t::iterator &out_itor)
 
FreeForceID_t GetFreeForceNextId ()
 
FreeForceVec_t & GetFreeForces ()
 
Networking
void HandleActorStreamData (std::vector< RoR::NetRecvPacket > packet)
 
unsigned long GetNetTime ()
 
int GetNetTimeOffset (int sourceid)
 
void UpdateNetTimeOffset (int sourceid, int offset)
 
void AddStreamMismatch (RoRnet::ActorStreamRegister *reg)
 
void RetryFailedStreamRegistrations (ScriptEventArgs *args)
 
void RequestSpawnRemoteActor (RoRnet::ActorStreamRegister *reg, const CacheEntryPtr &cache_entry, const RoRnet::UserInfo &userinfo, BitMask_t peeropts)
 
RoRnet::UiStreamsHealth CheckNetworkStreamsOk (int sourceid)
 
RoRnet::UiStreamsHealth CheckNetRemoteStreamsOk (int sourceid)
 

Data Fields

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

Static Public Attributes

static const ActorPtr ACTORPTR_NULL
 

Private Member Functions

bool CheckActorCollAabbIntersect (int a, int b)
 
bool PredictActorCollAabbIntersect (int a, int b)
 
void RemoveStreamSource (int sourceid)
 
void RemoveStream (int sourceid, int streamid)
 
void RecursiveActivation (int j, std::vector< bool > &visited)
 
void ForwardCommands (ActorPtr source_actor)
 
void UpdateTruckFeatures (ActorPtr vehicle, float dt)
 
void CalcFreeForces ()
 

Private Attributes

std::map< int, std::set< int > > m_stream_mismatches
 
std::vector< RoRnet::ActorStreamRegister > m_stream_mismatched_regs
 
std::map< int, int > m_stream_time_offsets
 
Ogre::Timer m_net_timer
 
ActorPtrVec m_actors
 
ActorInstanceID_t m_actor_next_instance_id = 1
 
bool m_forced_awake = false
 
int m_physics_steps = 0
 
float m_dt_remainder = 0.f
 
float m_simulation_speed = 1.f
 
float m_last_simulation_speed = 0.1f
 
float m_simulation_time = 0.f
 
bool m_simulation_paused = false
 
float m_total_sim_time = 0.f
 
FreeForceVec_t m_free_forces
 
FreeForceID_t m_free_force_next_id = 0
 
std::unique_ptr< ThreadPool > m_sim_thread_pool
 
std::shared_ptr< Task > m_sim_task
 
RoR::CmdKeyInertiaConfig m_inertia_config
 

Member Typedef Documentation

◆ FreeForceVec_t

Definition at line 48 of file ActorManager.h.

Constructor & Destructor Documentation

◆ ActorManager()

ActorManager::ActorManager ( )

Definition at line 69 of file ActorManager.cpp.

◆ ~ActorManager()

ActorManager::~ActorManager ( )

Definition at line 79 of file ActorManager.cpp.

Member Function Documentation

◆ AddFreeForce()

void ActorManager::AddFreeForce ( FreeForceRequest *  rq)

Definition at line 1869 of file ActorManager.cpp.

◆ AddStreamMismatch()

void ActorManager::AddStreamMismatch ( RoRnet::ActorStreamRegister *  reg)

Definition at line 588 of file ActorManager.cpp.

◆ AreActorsDirectlyLinked()

bool ActorManager::AreActorsDirectlyLinked ( const ActorPtr &  a1,
const ActorPtr &  a2 
)

Definition at line 830 of file ActorManager.cpp.

◆ AreTrucksForcedAwake()

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

Definition at line 86 of file ActorManager.h.

◆ CalcFreeForces()

void ActorManager::CalcFreeForces ( )
private

Apply FreeForces - intentionally as a separate pass over all actors.

Definition at line 1624 of file ActorManager.cpp.

◆ 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 676 of file ActorManager.cpp.

◆ CheckNetRemoteStreamsOk()

RoRnet::UiStreamsHealth ActorManager::CheckNetRemoteStreamsOk ( int  sourceid)

Definition at line 644 of file ActorManager.cpp.

◆ CheckNetworkStreamsOk()

RoRnet::UiStreamsHealth ActorManager::CheckNetworkStreamsOk ( int  sourceid)

Definition at line 612 of file ActorManager.cpp.

◆ CleanUpSimulation()

void ActorManager::CleanUpSimulation ( )

Call this after simulation loop finishes.

Definition at line 962 of file ActorManager.cpp.

◆ CreateNewActor()

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

Definition at line 84 of file ActorManager.cpp.

◆ DeleteActorInternal()

void ActorManager::DeleteActorInternal ( ActorPtr  actor)

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

Definition at line 975 of file ActorManager.cpp.

◆ ExportActorDef()

void ActorManager::ExportActorDef ( RigDef::DocumentPtr  def,
std::string  filename,
std::string  rg_name 
)

Definition at line 1426 of file ActorManager.cpp.

◆ FetchActorDef()

RigDef::DocumentPtr ActorManager::FetchActorDef ( RoR::ActorSpawnRequest &  rq)

Definition at line 1347 of file ActorManager.cpp.

◆ FetchNextVehicleOnList()

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

Definition at line 1056 of file ActorManager.cpp.

◆ FetchPreviousVehicleOnList()

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

Definition at line 1081 of file ActorManager.cpp.

◆ FetchRescueVehicle()

const ActorPtr & ActorManager::FetchRescueVehicle ( )

Definition at line 1108 of file ActorManager.cpp.

◆ FindActorInsideBox()

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

Definition at line 913 of file ActorManager.cpp.

◆ FindFreeForce()

bool ActorManager::FindFreeForce ( FreeForceID_t  id,
FreeForceVec_t::iterator &  out_itor 
)

Definition at line 1863 of file ActorManager.cpp.

◆ ForwardCommands()

void ActorManager::ForwardCommands ( ActorPtr  source_actor)
private

Fowards things to trailers.

Definition at line 759 of file ActorManager.cpp.

◆ GetActorById()

const ActorPtr & ActorManager::GetActorById ( ActorInstanceID_t  actor_id)

Definition at line 1236 of file ActorManager.cpp.

◆ GetActorByNetworkLinks()

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

Definition at line 663 of file ActorManager.cpp.

◆ GetActorNextInstanceId()

ActorInstanceID_t RoR::ActorManager::GetActorNextInstanceId ( )
inline

Script proxy: game.getActorNextInstanceId()

Definition at line 67 of file ActorManager.h.

◆ GetActors()

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

Definition at line 127 of file ActorManager.h.

◆ GetFreeForceNextId()

FreeForceID_t RoR::ActorManager::GetFreeForceNextId ( )
inline

Script proxy: game.getFreeForceNextId()

Definition at line 76 of file ActorManager.h.

◆ GetFreeForces()

FreeForceVec_t & RoR::ActorManager::GetFreeForces ( )
inline

Definition at line 77 of file ActorManager.h.

◆ GetInertiaConfig()

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

Definition at line 92 of file ActorManager.h.

◆ GetLocalActors()

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

Definition at line 1457 of file ActorManager.cpp.

◆ GetNearestActor()

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

Definition at line 946 of file ActorManager.cpp.

◆ GetNetTime()

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

Definition at line 111 of file ActorManager.h.

◆ GetNetTimeOffset()

int ActorManager::GetNetTimeOffset ( int  sourceid)

Definition at line 594 of file ActorManager.cpp.

◆ GetSimulationSpeed()

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

Definition at line 88 of file ActorManager.h.

◆ GetTotalTime()

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

Definition at line 91 of file ActorManager.h.

◆ HandleActorStreamData()

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

Definition at line 439 of file ActorManager.cpp.

◆ IsSimulationPaused()

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

Definition at line 89 of file ActorManager.h.

◆ LoadScene()

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

Definition at line 240 of file Savegame.cpp.

◆ ModifyFreeForce()

void ActorManager::ModifyFreeForce ( FreeForceRequest *  rq)

Definition at line 1888 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 705 of file ActorManager.cpp.

◆ RecursiveActivation()

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

Definition at line 734 of file ActorManager.cpp.

◆ RemoveFreeForce()

void ActorManager::RemoveFreeForce ( FreeForceID_t  id)

Definition at line 1906 of file ActorManager.cpp.

◆ RemoveStream()

void ActorManager::RemoveStream ( int  sourceid,
int  streamid 
)
private

Definition at line 373 of file ActorManager.cpp.

◆ RemoveStreamSource()

void ActorManager::RemoveStreamSource ( int  sourceid)
private

Definition at line 352 of file ActorManager.cpp.

◆ RepairActor()

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

Definition at line 932 of file ActorManager.cpp.

◆ RequestSpawnRemoteActor()

void ActorManager::RequestSpawnRemoteActor ( RoRnet::ActorStreamRegister *  reg,
const CacheEntryPtr &  cache_entry,
const RoRnet::UserInfo &  userinfo,
BitMask_t  peeropts 
)

Definition at line 560 of file ActorManager.cpp.

◆ RestoreSavedState()

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

Definition at line 787 of file Savegame.cpp.

◆ RetryFailedStreamRegistrations()

void ActorManager::RetryFailedStreamRegistrations ( ScriptEventArgs *  args)

Definition at line 395 of file ActorManager.cpp.

◆ SaveScene()

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

Definition at line 418 of file Savegame.cpp.

◆ SendAllActorsSleeping()

void ActorManager::SendAllActorsSleeping ( )

Definition at line 901 of file ActorManager.cpp.

◆ SetSimulationPaused()

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

Definition at line 90 of file ActorManager.h.

◆ SetSimulationSpeed()

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

Definition at line 87 of file ActorManager.h.

◆ SetTrucksForcedAwake()

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

Definition at line 85 of file ActorManager.h.

◆ SyncWithSimThread()

void ActorManager::SyncWithSimThread ( )

Definition at line 1328 of file ActorManager.cpp.

◆ UpdateActors()

void ActorManager::UpdateActors ( ActorPtr  player_actor)

Definition at line 1120 of file ActorManager.cpp.

◆ UpdateInputEvents()

void ActorManager::UpdateInputEvents ( float  dt)

Definition at line 1468 of file ActorManager.cpp.

◆ UpdateNetTimeOffset()

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

Definition at line 604 of file ActorManager.cpp.

◆ UpdatePhysicsSimulation()

void ActorManager::UpdatePhysicsSimulation ( )

Definition at line 1248 of file ActorManager.cpp.

◆ UpdateSleepingState()

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

Definition at line 844 of file ActorManager.cpp.

◆ UpdateTruckFeatures()

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

Definition at line 1558 of file ActorManager.cpp.

◆ WakeUpAllActors()

void ActorManager::WakeUpAllActors ( )

Definition at line 889 of file ActorManager.cpp.

Field Documentation

◆ ACTORPTR_NULL

const ActorPtr ActorManager::ACTORPTR_NULL
static

Definition at line 135 of file ActorManager.h.

◆ inter_actor_links

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

Definition at line 132 of file ActorManager.h.

◆ m_actor_next_instance_id

ActorInstanceID_t RoR::ActorManager::m_actor_next_instance_id = 1
private

Unique sequential ID for each Actor.

Definition at line 156 of file ActorManager.h.

◆ m_actors

ActorPtrVec RoR::ActorManager::m_actors
private

Use MSG_SIM_{SPAWN/DELETE}_ACTOR_REQUESTED

Definition at line 155 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 159 of file ActorManager.h.

◆ m_forced_awake

bool RoR::ActorManager::m_forced_awake = false
private

disables sleep counters

Definition at line 157 of file ActorManager.h.

◆ m_free_force_next_id

FreeForceID_t RoR::ActorManager::m_free_force_next_id = 0
private

Unique ID for each FreeForce.

Definition at line 166 of file ActorManager.h.

◆ m_free_forces

FreeForceVec_t RoR::ActorManager::m_free_forces
private

Global forces added ad-hoc by scripts.

Definition at line 165 of file ActorManager.h.

◆ m_inertia_config

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

Definition at line 171 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 161 of file ActorManager.h.

◆ m_net_timer

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

Definition at line 152 of file ActorManager.h.

◆ m_physics_steps

int RoR::ActorManager::m_physics_steps = 0
private

Definition at line 158 of file ActorManager.h.

◆ m_sim_task

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

Definition at line 170 of file ActorManager.h.

◆ m_sim_thread_pool

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

Definition at line 169 of file ActorManager.h.

◆ m_simulation_paused

bool RoR::ActorManager::m_simulation_paused = false
private

Definition at line 163 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 160 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 162 of file ActorManager.h.

◆ m_stream_mismatched_regs

std::vector<RoRnet::ActorStreamRegister> RoR::ActorManager::m_stream_mismatched_regs
private

Networking: Remember mismatched stream regs to re-process after downloading the missing mods.

Definition at line 150 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 149 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 151 of file ActorManager.h.

◆ m_total_sim_time

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

Definition at line 164 of file ActorManager.h.


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