|
RigsofRods
Soft-body Physics Simulation
|
Go to the documentation of this file.
62 const ActorPtr ActorManager::ACTORPTR_NULL;
64 ActorManager::ActorManager()
65 : m_dt_remainder(0.0f)
66 , m_forced_awake(false)
67 , m_physics_steps(2000)
68 , m_simulation_speed(1.0f)
88 LOG(
" == Spawning vehicle: " + def->name);
113 float max_dimension = std::max(1.0f, aabb_size.x);
114 max_dimension = std::max(max_dimension, aabb_size.y);
115 max_dimension = std::max(max_dimension, aabb_size.z);
132 vehicle_position.x += vehicle_position.x - actor->
ar_bounding_box.getCenter().x;
133 vehicle_position.z += vehicle_position.z - actor->
ar_bounding_box.getCenter().z;
139 miny = vehicle_position.y;
150 actor->
resetPosition(vehicle_position.x, vehicle_position.z,
true, miny);
161 Vector3 gpos = Vector3(vehicle_position.x, 0.0f, vehicle_position.z);
209 if (!subMeshGroundModelName.empty())
325 for (
RigDef::Script const& script_def : def->root_module->scripts)
330 LOG(
" ===== DONE LOADING VEHICLE");
351 if (actor->ar_net_source_id == sourceid)
362 std::stable_sort(packet_buffer.begin(), packet_buffer.end(),
364 { return a.header.source > b.header.source; });
366 auto it = std::unique(packet_buffer.rbegin(), packet_buffer.rend(),
368 { return !memcmp(&a.header, &b.header, sizeof(RoRnet::Header)) &&
369 a.header.command == RoRnet::MSG2_STREAM_DATA; });
370 packet_buffer.erase(packet_buffer.begin(), it.base());
371 for (
auto& packet : packet_buffer)
387 else if (filename.empty())
395 text <<
_L(
"spawned a new vehicle: ") << filename;
405 _L(
"Mod not installed: ") + filename);
406 RoR::LogFormat(
"[RoR] Cannot create remote actor (not installed), filename: '%s'", filename.c_str());
422 if (
strnlen(actor_reg->skin, 60) < 60 && actor_reg->skin[0] !=
'\0')
426 if (
strnlen(actor_reg->sectionconfig, 60) < 60)
452 int sourceid = packet.header.source;
453 actor->ar_net_stream_results[sourceid] = reg->
status;
458 case 1: message =
"successfully loaded stream";
break;
459 case -2: message =
"detected mismatch stream";
break;
460 default: message =
"could not load stream";
break;
490 if (packet.header.source == actor->ar_net_source_id && packet.header.streamid == actor->ar_net_stream_id)
492 actor->pushNetwork(packet.buffer, packet.header.size);
499 #endif // USE_SOCKETW
506 return search->second;
529 if (actor->ar_net_source_id == sourceid)
547 int stream_result = actor->ar_net_stream_results[sourceid];
548 if (stream_result == -1 || stream_result == -2)
550 if (stream_result == 1)
561 if (actor->ar_net_source_id == source_id && actor->ar_net_stream_id == stream_id)
572 if (
m_actors[a]->ar_collision_bounding_boxes.empty() &&
m_actors[b]->ar_collision_bounding_boxes.empty())
574 return m_actors[a]->ar_bounding_box.intersects(
m_actors[b]->ar_bounding_box);
576 else if (
m_actors[a]->ar_collision_bounding_boxes.empty())
578 for (
const auto& bbox_b :
m_actors[b]->ar_collision_bounding_boxes)
579 if (bbox_b.intersects(
m_actors[a]->ar_bounding_box))
582 else if (
m_actors[b]->ar_collision_bounding_boxes.empty())
584 for (
const auto& bbox_a :
m_actors[a]->ar_collision_bounding_boxes)
585 if (bbox_a.intersects(
m_actors[b]->ar_bounding_box))
590 for (
const auto& bbox_a :
m_actors[a]->ar_collision_bounding_boxes)
591 for (
const auto& bbox_b :
m_actors[b]->ar_collision_bounding_boxes)
592 if (bbox_a.intersects(bbox_b))
601 if (
m_actors[a]->ar_predicted_coll_bounding_boxes.empty() &&
m_actors[b]->ar_predicted_coll_bounding_boxes.empty())
603 return m_actors[a]->ar_predicted_bounding_box.intersects(
m_actors[b]->ar_predicted_bounding_box);
605 else if (
m_actors[a]->ar_predicted_coll_bounding_boxes.empty())
607 for (
const auto& bbox_b :
m_actors[b]->ar_predicted_coll_bounding_boxes)
608 if (bbox_b.intersects(
m_actors[a]->ar_predicted_bounding_box))
611 else if (
m_actors[b]->ar_predicted_coll_bounding_boxes.empty())
613 for (
const auto& bbox_a :
m_actors[a]->ar_predicted_coll_bounding_boxes)
614 if (bbox_a.intersects(
m_actors[b]->ar_predicted_bounding_box))
619 for (
const auto& bbox_a :
m_actors[a]->ar_predicted_coll_bounding_boxes)
620 for (
const auto& bbox_b :
m_actors[b]->ar_predicted_coll_bounding_boxes)
621 if (bbox_a.intersects(bbox_b))
635 for (
unsigned int t = 0; t <
m_actors.size(); t++)
637 if (t == j || visited[t])
641 m_actors[t]->ar_sleep_counter = 0.0f;
646 m_actors[t]->ar_sleep_counter = 0.0f;
662 (actor->getPosition().distance(source_actor->
getPosition()) <
668 actor->ar_sleep_counter = 0.0f;
674 if (std::find(linked_actors.begin(), linked_actors.end(), actor) == linked_actors.end())
681 actor->ar_command_key[j].playerInputValue = std::max(source_actor->
ar_command_key[j].playerInputValue,
706 for (
auto hook : source_actor->
ar_hooks)
708 if (!hook.hk_locked_actor || hook.hk_locked_actor == source_actor)
712 hook.hk_locked_actor->ar_brake = source_actor->
ar_brake;
715 hook.hk_locked_actor->parkingbrakeToggle();
728 auto& actor_pair = entry.second;
729 if ((actor_pair.first == a1 && actor_pair.second == a2) ||
730 (actor_pair.first == a2 && actor_pair.second == a1))
746 if (actor->ar_driveable ==
AI)
748 if (actor->getVelocity().squaredLength() > 0.01f)
750 actor->ar_sleep_counter = 0.0f;
754 actor->ar_sleep_counter += dt;
756 if (actor->ar_sleep_counter >= 10.0f)
768 std::vector<bool> visited(
m_actors.size());
776 for (
unsigned int t = 0; t <
m_actors.size(); t++)
790 actor->ar_sleep_counter = 0.0f;
813 if (collisions->
isInside(actor->ar_nodes[0].AbsPosition, inst, box))
829 if (actor !=
nullptr)
844 actor->muteAllSounds();
852 actor->unmuteAllSounds();
859 float min_squared_distance = std::numeric_limits<float>::max();
862 float squared_distance = position.squaredDistance(actor->ar_nodes[0].AbsPosition);
863 if (squared_distance < min_squared_distance)
865 min_squared_distance = squared_distance;
866 nearest_actor = actor;
869 return std::make_pair(nearest_actor, std::sqrt(min_squared_distance));
900 { return b->ar_net_source_id == actor->ar_net_source_id; }) == 1)
906 #endif // USE_SOCKETW
909 std::vector<ScriptUnitId_t> unload_list;
912 if (pair.second.associatedActor == actor)
913 unload_list.push_back(pair.first);
925 [actor](
FreeForce& item) { return item.ffc_base_actor == actor || item.ffc_target_actor == actor; }),
934 for (
unsigned int i = 0; i <
m_actors.size(); i++)
943 if (player !=
nullptr)
945 else if (prev_player !=
nullptr)
970 for (
int i = pivot_index + 1; i <
m_actors.size(); i++)
976 for (
int i = 0; i < pivot_index; i++)
982 if (pivot_index >= 0)
995 for (
int i = pivot_index - 1; i >= 0; i--)
1001 for (
int i =
static_cast<int>(
m_actors.size()) - 1; i > pivot_index; i--)
1007 if (pivot_index >= 0)
1022 if (actor->ar_rescuer_flag)
1035 dt = std::min(dt, 1.0f / 20.0f);
1055 actor->HandleInputEvents(dt);
1056 actor->HandleAngelScriptEvents(dt);
1058 #ifdef USE_ANGELSCRIPT
1059 if (actor->ar_vehicle_ai && actor->ar_vehicle_ai->isActive())
1060 actor->ar_vehicle_ai->update(dt, 0);
1061 #endif // USE_ANGELSCRIPT
1063 if (actor->ar_engine)
1065 if (actor->ar_driveable ==
TRUCK)
1071 actor->ar_engine->UpdateEngineSim(dt, 1);
1073 actor->ar_engine->UpdateEngineAudio();
1077 actor->updateDashBoards(dt);
1080 actor->updateFlareStates(dt);
1084 actor->updateVisual(dt);
1087 actor->updateSkidmarks();
1094 actor->calcNetwork();
1096 actor->sendStreamData();
1100 if (player_actor !=
nullptr)
1134 auto func = std::function<void()>([
this]()
1150 if (actor->ar_instance_id == actor_id)
1162 actor->UpdatePhysicsOrigin();
1167 std::vector<std::function<void()>> tasks;
1170 if (actor->ar_update_physics = actor->CalcForcesEulerPrepare(i == 0))
1172 auto func = std::function<void()>([
this, i, &actor]()
1176 tasks.push_back(func);
1182 if (actor->ar_update_physics)
1184 actor->CalcBeamsInterActor();
1189 std::vector<std::function<void()>> tasks;
1192 if (actor->m_inter_point_col_detector !=
nullptr && (actor->ar_update_physics ||
1195 auto func = std::function<void()>([
this, &actor]()
1197 actor->m_inter_point_col_detector->UpdateInterPoint();
1198 if (actor->ar_collision_relevant)
1200 ResolveInterActorCollisions(PHYSICS_DT,
1201 *actor->m_inter_point_col_detector,
1202 actor->ar_num_collcabs,
1205 actor->ar_inter_collcabrate,
1207 actor->ar_collision_range,
1208 *actor->ar_submesh_ground_model);
1211 tasks.push_back(func);
1222 actor->m_ongoing_reset =
false;
1225 Vector3 camera_gforces = actor->m_camera_gforces_accu /
m_physics_steps;
1226 actor->m_camera_gforces_accu = Vector3::ZERO;
1227 actor->m_camera_gforces = actor->m_camera_gforces * 0.5f + camera_gforces * 0.5f;
1228 actor->calculateLocalGForces();
1229 actor->calculateAveragePosition();
1230 actor->m_avg_node_velocity = actor->m_avg_node_position - actor->m_avg_node_position_prev;
1232 actor->m_avg_node_position_prev = actor->m_avg_node_position;
1233 actor->ar_top_speed = std::max(actor->ar_top_speed, actor->ar_nodes[0].Velocity.length());
1247 msg <<
"Failed to load '" << filename <<
"' (type: '" << type <<
"'), message: " << exception_msg;
1261 if (cache_entry ==
nullptr)
1276 Ogre::String resource_filename = filename;
1277 Ogre::String resource_groupname;
1283 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(resource_filename, resource_groupname);
1285 if (stream.isNull() || !stream->isReadable())
1291 RoR::LogFormat(
"[RoR] Parsing truckfile '%s'", resource_filename.c_str());
1300 LOG(
" == Validating vehicle: " + def->name);
1303 validator.
Setup(def);
1305 if (predefined_on_terrain)
1311 std::string file_extension = filename.substr(filename.find_last_of(
'.'));
1312 Ogre::StringUtil::toLowerCase(file_extension);
1313 if ((file_extension ==
".load") | (file_extension ==
".fixed"))
1321 def->hash =
Sha1Hash(stream->getAsString());
1326 catch (Ogre::Exception& oex)
1331 catch (std::exception& stex)
1345 std::vector<ActorPtr> actors;
1349 actors.push_back(actor);
1364 String ssmsg =
_L(
"New simulation speed: ") +
TOSTRING(
Round(simulation_speed * 100.0f, 1)) +
"%";
1373 String ssmsg =
_L(
"New simulation speed: ") +
TOSTRING(
Round(simulation_speed * 100.0f, 1)) +
"%";
1381 if (simulation_speed != 1.0f)
1385 UTFString ssmsg =
_L(
"Simulation speed reset.");
1411 String ssmsg =
_L(
"Physics paused");
1416 String ssmsg =
_L(
"Physics unpaused");
1448 #ifdef USE_ANGELSCRIPT
1451 #endif // USE_ANGELSCRIPT
1460 Ogre::Degree pitchAngle = Ogre::Radian(asin(dirDiff.dotProduct(Ogre::Vector3::UNIT_Y)));
1462 if (std::abs(pitchAngle.valueDegrees()) > 2.0f)
1470 float downhill_force = std::abs(sin(pitchAngle.valueRadians()) * vehicle->
getTotalMass()) * g;
1472 float ratio = std::max(0.0f, 1.0f - (engine_force / downhill_force));
1494 if (engine && engine->
GetGear() != 0)
1510 ROR_ASSERT(freeforce.ffc_base_actor !=
nullptr);
1513 ROR_ASSERT(freeforce.ffc_base_node <= freeforce.ffc_base_actor->ar_num_nodes);
1516 switch (freeforce.ffc_type)
1519 freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * freeforce.ffc_force_const_direction;
1524 const Vector3 force_direction = (freeforce.ffc_target_coords - freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].AbsPosition).normalisedCopy();
1525 freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * force_direction;
1532 ROR_ASSERT(freeforce.ffc_target_actor !=
nullptr);
1535 ROR_ASSERT(freeforce.ffc_target_node <= freeforce.ffc_target_actor->ar_num_nodes);
1537 const Vector3 force_direction = (freeforce.ffc_target_actor->ar_nodes[freeforce.ffc_target_node].AbsPosition - freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].AbsPosition).normalisedCopy();
1538 freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * force_direction;
1590 fmt::format(
"Cannot add free force of type 'TOWARDS_NODE' with ID {} to actor {}: Target actor not found or disposed", freeforce.
ffc_id, rq->
ffr_target_actor));
1621 fmt::format(
"Cannot add free force with ID {}: ID already in use", rq->
ffr_id));
1655 fmt::format(
"Cannot remove free force with ID {}: ID not found",
id));
#define ROR_ASSERT(_EXPR)
Game state manager and message-queue provider.
float ar_avg_wheel_speed
Physics state; avg wheel speed in m/s.
static const int MAX_COMMANDS
maximum number of commands per actor
void SetDebugView(DebugViewType dv)
void resetPosition(Ogre::Vector3 translation, bool setInitPosition)
Moves the actor to given world coords.
bool cc_mode
Cruise Control.
float GetSimulationSpeed() const
int CheckNetworkStreamsOk(int sourceid)
Softbody object; can be anything from soda can to a space shuttle Constructed from a truck definition...
VehicleAIPtr ar_vehicle_ai
bool asr_free_position
Disables the automatic spawn position adjustment.
@ MSG2_STREAM_UNREGISTER
remove stream
void BITMASK_SET(BitMask_t &mask, BitMask_t flag, bool val)
Ogre::String m_section_config
@ NETWORK
Remote controlled.
@ MSG_SIM_MODIFY_ACTOR_REQUESTED
Payload = RoR::ActorModifyRequest* (owner)
NodeNum_t ffc_target_node
bool ar_physics_paused
Sim state.
int32_t time
initial time stamp
void UpdateSimDataBuffer()
Copies sim. data from Actor to GfxActor for later update.
@ TRUCK
its a truck (or other land vehicle)
std::string ar_filename
Attribute; filled at spawn.
int GetNetTimeOffset(int sourceid)
static const ActorPtr ACTORPTR_NULL
void ConfigureSections(Ogre::String const §ionconfig, RigDef::DocumentPtr def)
bool ModifyTyrePressure(float v)
@ CONFIG_FILE
'Preselected vehicle' in RoR.cfg or command line
unsigned int ar_vector_index
Sim attr; actor element index in std::vector<m_actors>
Ogre::Vector3 AbsPosition
absolute position in the world (shaky)
Estabilishing a physics linkage between 2 actors modifies a global linkage table and triggers immedia...
ActorPtrVec ar_linked_actors
BEWARE: Includes indirect links, see DetermineLinkedActors(); Other actors linked using 'hooks/ties/r...
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
int m_net_first_wheel_node
Network attr; Determines data buffer layout; calculated on spawn.
CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string &filename)
Returns NULL if none found.
void HandleErrorLoadingTruckfile(std::string filename, std::string exception_msg)
Ogre::AxisAlignedBox ar_bounding_box
standard bounding box (surrounds all nodes of an actor)
RigDef::DocumentPtr GetFile()
CVar * gfx_skidmarks_mode
static const NodeNum_t NODENUM_INVALID
ground_model_t * defaultgm
Truck file format(technical spec)
void AddFreeForce(FreeForceRequest *rq)
void HandleErrorLoadingFile(std::string type, std::string filename, std::string exception_msg)
Ogre::Vector3 lo
absolute collision box
std::map< beam_t *, std::pair< ActorPtr, ActorPtr > > inter_actor_links
@ DISPOSED
removed from simulation, still in memory to satisfy pointers.
@ LIGHTMASK_REVERSE
reverse light on
void RemoveStreamSource(int sourceid)
ActorLinkingRequestType alr_type
Ogre::Real m_min_camera_radius
void TRIGGER_EVENT_ASYNC(scriptEvents type, int arg1, int arg2ex=0, int arg3ex=0, int arg4ex=0, std::string arg5ex="", std::string arg6ex="", std::string arg7ex="", std::string arg8ex="")
Asynchronously (via MSG_SIM_SCRIPT_EVENT_TRIGGERED) invoke script function eventCallbackEx(),...
Ogre::Real ar_brake
Physics state; braking intensity.
bool sl_enabled
Speed limiter;.
ActorPtr FindActorInsideBox(Collisions *collisions, const Ogre::String &inst, const Ogre::String &box)
Checks the rig-def file syntax and pulls data to File object.
bool CheckActorCollAabbIntersect(int a, int b)
Returns whether or not the bounding boxes of truck a and truck b intersect. Based on the truck collis...
Ogre::Real Round(Ogre::Real value, unsigned short ndigits=0)
float ffc_force_magnitude
void LogFormat(const char *format,...)
Improved logging utility. Uses fixed 2Kb buffer.
int32_t origin_sourceid
origin sourceid
Ogre::Vector3 hi
absolute collision box
bool ar_toggle_ropes
Sim state.
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
RigDef::DocumentPtr FetchActorDef(std::string filename, bool predefined_on_terrain=false)
std::vector< hook_t > ar_hooks
float m_net_node_compression
For incoming/outgoing traffic; calculated on spawn.
A land vehicle engine + transmission.
bool ar_trailer_parking_brake
ActorPtrVec & GetActors()
This creates a billboarding object that displays a text.
float sl_speed_limit
Speed limiter;.
void ConfigureAddonParts(TuneupDefPtr &tuneup_def)
const ActorPtr & GetActorByNetworkLinks(int source_id, int stream_id)
@ SE_GENERIC_NEW_TRUCK
triggered when the user spawns a new actor, the argument refers to the actor ID
const ActorPtr & FetchPreviousVehicleOnList(ActorPtr player, ActorPtr prev_player)
void FinishFlexbodyTasks()
ActorPtr ffc_target_actor
ScriptUnitId_t loadScript(Ogre::String scriptname, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, std::string buffer="")
Loads a script.
std::pair< ActorPtr, float > GetNearestActor(Ogre::Vector3 position)
void Setup(RigDef::DocumentPtr file)
Prepares the validation.
@ LOCAL_SIMULATED
simulated (local) actor
bool AreActorsDirectlyLinked(const ActorPtr &a1, const ActorPtr &a2)
Ogre::Vector3 RelPosition
relative to the local physics origin (one origin per actor) (shaky)
void SetAcceleration(float val)
std::map< int, int > m_stream_time_offsets
Networking: A network time offset for each stream source.
void ProcessOgreStream(Ogre::DataStream *stream, Ogre::String resource_group)
bool ar_forward_commands
Sim state.
static const NodeNum_t NODENUM_MAX
Ogre::Vector3 center
center of rotation
ScriptEngine * GetScriptEngine()
CVar * mp_cyclethru_net_actors
Include remote actors when cycling through with CTRL + [ and CTRL + ].
Processes a RigDef::Document (parsed from 'truck' file format) into a simulated gameplay object (Acto...
size_t m_net_wheel_buf_size
For incoming/outgoing traffic; calculated on spawn.
float ar_wheel_speed
Physics state; wheel speed in m/s.
void SendAllActorsSleeping()
float initial_beam_strength
for reset
void AddStreamMismatch(int sourceid, int streamid)
void FinishWheelUpdates()
Ogre::Vector3 ffr_force_const_direction
ActorInstanceID_t amr_actor
void UpdateProps(float dt, bool is_player_actor)
bool m_disable_default_sounds
Spawner context; TODO: remove.
float getAvgPropedWheelRadius()
bool isPreloadedWithTerrain() const
bool isActive()
Returns the status of the AI.
float m_simulation_speed
slow motion < 1.0 < fast motion
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.
@ TOWARDS_COORDS
Constant force directed towards ffc_target_coords
int ActorInstanceID_t
Unique sequentially generated ID of an actor in session. Use ActorManager::GetActorById()
void CalcFreeForces()
Apply FreeForces - intentionally as a separate pass over all actors.
void UpdateSleepingState(ActorPtr player_actor, float dt)
bool PredictActorCollAabbIntersect(int a, int b)
Returns whether or not the bounding boxes of truck a and truck b might intersect during the next fram...
@ MSG2_STREAM_DATA
stream data
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
float m_dt_remainder
Keeps track of the rounding error in the time step calculation.
ground_model_t * getGroundModelByString(const Ogre::String name)
void RemoveFreeForce(FreeForceID_t id)
Performs a formal validation of the file (missing required parts, conflicts of modules,...
FreeForceVec_t::iterator FindFreeForce(FreeForceID_t id)
Ogre::Vector3 ffc_force_const_direction
Expected to be normalized; only effective with FreeForceType::CONSTANT
void unloadScript(ScriptUnitId_t unique_id)
Unloads a script.
void RegisterGfxActor(RoR::GfxActor *gfx_actor)
A database of user-installed content alias 'mods' (vehicles, terrains...)
Ogre::Vector3 relo
relative collision box
std::shared_ptr< Task > m_sim_task
void ConfigureAssetPacks(ActorPtr actor, RigDef::DocumentPtr def)
void HandleActorStreamData(std::vector< RoR::NetRecvPacket > packet)
@ MSG2_STREAM_REGISTER
create new stream
TyrePressure & getTyrePressure()
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
std::vector< ActorPtr > GetLocalActors()
std::unique_ptr< ThreadPool > m_sim_thread_pool
Facilitates execution of (small) tasks on separate threads.
int ScriptUnitId_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
static ActorInstanceID_t m_actor_counter
void updateVisual(float dt=0)
void ProcessNewActor(ActorPtr actor, ActorSpawnRequest rq, RigDef::DocumentPtr def)
Ogre::Vector3 ar_origin
Physics state; base position for softbody nodes.
const char * ToCStr() const
@ LOCAL_SLEEPING
sleeping (local) actor
int FreeForceID_t
Unique sequentially generated ID of FreeForce; use ActorManager::GetFreeForceNextId().
RoR::SimGearboxMode GetAutoShiftMode()
CmdKeyArray ar_command_key
BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
@ CONSTANT
Constant force given by direction and magnitude.
Collisions * GetCollisions()
RigDef::DocumentPtr actor_def
Cached actor definition (aka truckfile) after first spawn.
Ogre::Vector3 getPosition()
Ogre::Vector3 ffr_target_coords
bool nd_tyre_node
Attr; This node is part of a tyre (note some wheel types don't use rim nodes at all)
void NotifyActorCameraChanged()
Logic: sound, display; Notify this vehicle that camera changed;.
void ForceFeedbackStep(int steps)
void WriteDiagnosticDump(std::string const &filename)
bool ar_import_commands
Sim state.
int FindPivotActorId(ActorPtr player, ActorPtr prev_player)
void UpdateNetTimeOffset(int sourceid, int offset)
Central state/object manager and communications hub.
size_t m_net_propanimkey_buf_size
For incoming/outgoing traffic; calculated on spawn.
@ MSG2_STREAM_REGISTER_RESULT
result of a stream creation
std::vector< std::pair< float, float > > ar_initial_beam_defaults
GameContext * GetGameContext()
void UpdateCruiseControl(float dt)
Defined in 'gameplay/CruiseControl.cpp'.
const ActorPtr & FetchRescueVehicle()
BitMask_t m_lightmask
RoRnet::Lightmask.
float m_dry_mass
Physics attr;.
double ffr_force_magnitude
void SetCheckBeams(bool check_beams)
Global force affecting particular (base) node of particular (base) actor; added ad-hoc by scripts.
std::vector< PropAnimKeyState > m_prop_anim_key_states
float ar_initial_total_mass
float ar_sleep_counter
Sim state; idle time counter.
Ogre::Vector3 getDirection()
average actor velocity, calculated using the actor positions of the last two frames
CacheEntryPtr asr_skin_entry
@ LIGHTMASK_BRAKES
brake lights on
float m_simulation_time
Amount of time the physics simulation is going to be advanced.
void SetSimulationSpeed(float speed)
bool m_preloaded_with_terrain
Spawn context (TODO: remove!)
Replay * m_replay_handler
float getTotalMass(bool withLocked=true)
int GetGear()
low level gear changing
size_t m_net_total_buffer_size
For incoming/outgoing traffic; calculated on spawn.
float m_last_simulation_speed
previously used time ratio between real time (evt.timeSinceLastFrame) and physics time ('dt' used in ...
void RecalculateNodeMasses(Ogre::Real total)
Previously 'calc_masses2()'.
int ar_num_cinecams
Sim attr;.
int32_t status
initial stream status
void RecursiveActivation(int j, std::vector< bool > &visited)
std::string SanitizeUtf8CString(const char *start, const char *end=nullptr)
float m_total_mass
Physics state; total mass in Kg.
void DeleteActorInternal(ActorPtr actor)
Do not call directly; use GameContext::DeleteActor()
size_t m_net_node_buf_size
For incoming/outgoing traffic; calculated on spawn.
CVar * sim_realistic_commands
std::vector< Ogre::Vector3 > ar_initial_node_positions
CacheSystem * GetCacheSystem()
std::string Sha1Hash(std::string const &data)
CacheEntryPtr FetchSkinByName(std::string const &skin_name)
static bool ProcessFreeForce(FreeForceRequest *rq, FreeForce &freeforce)
int32_t colournum
colour set by server
char name[128]
the actor filename
Common for ADD and MODIFY requests; tailored for use with AngelScript thru GameScript::pushMessage().
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
bool ar_toggle_ties
Sim state.
bool nd_rim_node
Attr; This node is part of a rim (only wheel types with separate rim nodes)
@ MSG_SIM_ACTOR_LINKING_REQUESTED
Payload = RoR::ActorLinkingRequest* (owner)
Unified game event system - all requests and state changes are reported using a message.
std::vector< float > ar_initial_node_masses
void putNetMessage(int user_id, MessageType type, const char *text)
#define SOUND_PLAY_ONCE(_ACTOR_, _TRIG_)
void dispose()
Effectively destroys the object but keeps it in memory to satisfy shared pointers.
Ogre::UTFString asr_net_username
void StartEngine()
Quick engine start. Plays sounds.
Ogre::UTFString m_net_username
void UpdateInputEvents(float dt)
TuneupDefPtr m_working_tuneup_def
Each actor gets unique instance, even if loaded from .tuneup file in modcache.
@ TOWARDS_NODE
Constant force directed towards ffc_target_node
@ MSG_SIM_SPAWN_ACTOR_REQUESTED
Payload = RoR::ActorSpawnRequest* (owner)
int32_t origin_streamid
origin streamid
InputEngine * GetInputEngine()
void ModifyFreeForce(FreeForceRequest *rq)
void EraseIf(std::vector< T, A > &c, Predicate pred)
Ogre::Vector3 m_avg_node_position
average node position
RefCountingObjectPtr< Actor > ActorPtr
ActorInstanceID_t alr_actor_instance_id
@ MSG_SIM_DELETE_ACTOR_REQUESTED
Payload = RoR::ActorPtr* (owner)
bool ShouldIncludeActorInList(const ActorPtr &actor)
@ ACTOR
Defined in truck file under 'scripts', contains global variable BeamClass@ thisActor.
void UpdateTruckFeatures(ActorPtr vehicle, float dt)
void ForwardCommands(ActorPtr source_actor)
Fowards things to trailers.
bool isInside(Ogre::Vector3 pos, const Ogre::String &inst, const Ogre::String &box, float border=0)
ground_model_t * ar_submesh_ground_model
void OffStart()
Quick start of vehicle engine.
@ NETWORKED_HIDDEN
not simulated, not updated (remote)
int m_wheel_node_count
Static attr; filled at spawn.
static void SetupDefaultSoundSources(ActorPtr const &actor)
void RepairActor(Collisions *collisions, const Ogre::String &inst, const Ogre::String &box, bool keepPosition=false)
std::shared_ptr< Document > DocumentPtr
@ CONSOLE_MSGTYPE_INFO
Generic message.
void calculateAveragePosition()
bool m_forced_awake
disables sleep counters
Ogre::Vector3 asr_position
std::string GetSubmeshGroundmodelName()
int ar_net_source_id
Unique ID of remote player who spawned this actor.
@ NETWORKED_OK
not simulated (remote) actor
void Parallelize(const std::vector< std::function< void()>> &task_funcs)
Run collection of tasks in parallel and wait until all have finished.
ThreadPool * GetThreadPool()
void UpdateActors(ActorPtr player_actor)
Ogre::UTFString tryConvertUTF(const char *buffer)
const ActorPtr & FetchNextVehicleOnList(ActorPtr player, ActorPtr prev_player)
BitMask_t getLightStateMask() const
void UpdateWheelVisuals()
@ AI
machine controlled by an Artificial Intelligence
ActorMemoryRequirements const & GetMemoryRequirements()
Ogre::Vector3 ffc_target_coords
void AddPacket(int streamid, int type, int len, const char *content)
collision_box_t * asr_spawnbox
Ogre::Quaternion asr_rotation
void UpdateBoundingBoxes()
const ActorPtr & GetActorById(ActorInstanceID_t actor_id)
FreeForceVec_t m_free_forces
Global forces added ad-hoc by scripts.
float default_beam_deform
for reset
void CleanUpSimulation()
Call this after simulation loop finishes.
ActorManager * GetActorManager()
@ MSG2_USER_LEAVE
user leaves
ActorPtr CreateNewActor(ActorSpawnRequest rq, RigDef::DocumentPtr def)
void UpdatePhysicsSimulation()
CVar * sim_replay_enabled
int CheckNetRemoteStreamsOk(int sourceid)
CVar * mp_pseudo_collisions
bool isBeingReset() const
const TerrainPtr & GetTerrain()
void calcNodeConnectivityGraph()
< Sent from the client to server and vice versa, to broadcast a new stream