RigsofRods
Soft-body Physics Simulation
ActorManager.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
25 
26 #include "ActorManager.h"
27 
28 #include "Application.h"
29 #include "Actor.h"
30 #include "CacheSystem.h"
31 #include "ContentManager.h"
32 #include "ChatSystem.h"
33 #include "Collisions.h"
34 #include "DashBoardManager.h"
35 #include "DynamicCollisions.h"
36 #include "EngineSim.h"
37 #include "GameContext.h"
38 #include "GfxScene.h"
39 #include "GUIManager.h"
40 #include "Console.h"
41 #include "GUI_TopMenubar.h"
42 #include "InputEngine.h"
43 #include "Language.h"
44 #include "MovableText.h"
45 #include "Network.h"
46 #include "PointColDetector.h"
47 #include "Replay.h"
48 #include "RigDef_Validator.h"
49 #include "ActorSpawner.h"
50 #include "ScriptEngine.h"
51 #include "SoundScriptManager.h"
52 #include "Terrain.h"
53 #include "ThreadPool.h"
54 #include "TuneupFileFormat.h"
55 #include "Utils.h"
56 #include "VehicleAI.h"
57 
58 using namespace Ogre;
59 using namespace RoR;
60 
62 const ActorPtr ActorManager::ACTORPTR_NULL; // Dummy value to be returned as const reference.
63 
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)
69 {
70  // Create worker thread (used for physics calculations)
71  m_sim_thread_pool = std::unique_ptr<ThreadPool>(new ThreadPool(1));
72 }
73 
75 {
76  this->SyncWithSimThread(); // Wait for sim task to finish
77 }
78 
80 {
81  ActorPtr actor = new Actor(m_actor_counter++, static_cast<int>(m_actors.size()), def, rq);
82 
84  {
85  actor->sendStreamSetup();
86  }
87 
88  LOG(" == Spawning vehicle: " + def->name);
89 
90  ActorSpawner spawner;
91  spawner.ConfigureSections(actor->m_section_config, def);
93  spawner.ConfigureAssetPacks(actor, def);
94  spawner.ProcessNewActor(actor, rq, def);
95 
96  if (App::diag_actor_dump->getBool())
97  {
98  actor->WriteDiagnosticDump(actor->ar_filename + "_dump_raw.txt"); // Saves file to 'logs'
99  }
100 
101  /* POST-PROCESSING */
102 
103  actor->ar_initial_node_positions.resize(actor->ar_num_nodes);
104  actor->ar_initial_beam_defaults.resize(actor->ar_num_beams);
105  actor->ar_initial_node_masses.resize(actor->ar_num_nodes);
106 
107  actor->UpdateBoundingBoxes(); // (records the unrotated dimensions for 'veh_aab_size')
108 
109  // Apply spawn position & spawn rotation
110  for (int i = 0; i < actor->ar_num_nodes; i++)
111  {
112  actor->ar_nodes[i].AbsPosition = rq.asr_position + rq.asr_rotation * (actor->ar_nodes[i].AbsPosition - rq.asr_position);
113  actor->ar_nodes[i].RelPosition = actor->ar_nodes[i].AbsPosition - actor->ar_origin;
114  };
115 
116  /* Place correctly */
117  if (spawner.GetMemoryRequirements().num_fixes == 0)
118  {
119  Ogre::Vector3 vehicle_position = rq.asr_position;
120 
121  // check if over-sized
122  actor->UpdateBoundingBoxes();
123  vehicle_position.x += vehicle_position.x - actor->ar_bounding_box.getCenter().x;
124  vehicle_position.z += vehicle_position.z - actor->ar_bounding_box.getCenter().z;
125 
126  float miny = 0.0f;
127 
128  if (!actor->m_preloaded_with_terrain)
129  {
130  miny = vehicle_position.y;
131  }
132 
133  if (rq.asr_spawnbox != nullptr)
134  {
135  miny = rq.asr_spawnbox->relo.y + rq.asr_spawnbox->center.y;
136  }
137 
138  if (rq.asr_free_position)
139  actor->resetPosition(vehicle_position, true);
140  else
141  actor->resetPosition(vehicle_position.x, vehicle_position.z, true, miny);
142 
143  if (rq.asr_spawnbox != nullptr)
144  {
145  bool inside = true;
146 
147  for (int i = 0; i < actor->ar_num_nodes; i++)
148  inside = (inside && App::GetGameContext()->GetTerrain()->GetCollisions()->isInside(actor->ar_nodes[i].AbsPosition, rq.asr_spawnbox, 0.2f));
149 
150  if (!inside)
151  {
152  Vector3 gpos = Vector3(vehicle_position.x, 0.0f, vehicle_position.z);
153 
154  gpos -= rq.asr_rotation * Vector3((rq.asr_spawnbox->hi.x - rq.asr_spawnbox->lo.x + actor->ar_bounding_box.getMaximum().x - actor->ar_bounding_box.getMinimum().x) * 0.6f, 0.0f, 0.0f);
155 
156  actor->resetPosition(gpos.x, gpos.z, true, miny);
157  }
158  }
159  }
160  else
161  {
162  actor->resetPosition(rq.asr_position, true);
163  }
164  actor->UpdateBoundingBoxes();
165 
166  //compute final mass
167  actor->RecalculateNodeMasses(actor->m_dry_mass);
168  actor->ar_initial_total_mass = actor->m_total_mass;
169  for (int i = 0; i < actor->ar_num_nodes; i++)
170  {
171  actor->ar_initial_node_masses[i] = actor->ar_nodes[i].mass;
172  }
173 
174  //setup default sounds
175  if (!actor->m_disable_default_sounds)
176  {
178  }
179 
180  //compute node connectivity graph
181  actor->calcNodeConnectivityGraph();
182 
183  actor->UpdateBoundingBoxes();
184  actor->calculateAveragePosition();
185 
186  // calculate minimum camera radius
187  actor->calculateAveragePosition();
188  for (int i = 0; i < actor->ar_num_nodes; i++)
189  {
190  Real dist = actor->ar_nodes[i].AbsPosition.squaredDistance(actor->m_avg_node_position);
191  if (dist > actor->m_min_camera_radius)
192  {
193  actor->m_min_camera_radius = dist;
194  }
195  }
196  actor->m_min_camera_radius = std::sqrt(actor->m_min_camera_radius) * 1.2f; // twenty percent buffer
197 
198  // fix up submesh collision model
199  std::string subMeshGroundModelName = spawner.GetSubmeshGroundmodelName();
200  if (!subMeshGroundModelName.empty())
201  {
203  if (!actor->ar_submesh_ground_model)
204  {
206  }
207  }
208 
209  // Set beam defaults
210  for (int i = 0; i < actor->ar_num_beams; i++)
211  {
212  actor->ar_beams[i].initial_beam_strength = actor->ar_beams[i].strength;
214  actor->ar_initial_beam_defaults[i] = std::make_pair(actor->ar_beams[i].k, actor->ar_beams[i].d);
215  }
216 
217  actor->m_spawn_rotation = actor->getRotation();
218 
220 
221  actor->NotifyActorCameraChanged(); // setup sounds properly
222 
223  // calculate the number of wheel nodes
224  actor->m_wheel_node_count = 0;
225  for (int i = 0; i < actor->ar_num_nodes; i++)
226  {
227  if (actor->ar_nodes[i].nd_tyre_node)
228  actor->m_wheel_node_count++;
229  }
230 
231  // search m_net_first_wheel_node
232  actor->m_net_first_wheel_node = actor->ar_num_nodes;
233  for (int i = 0; i < actor->ar_num_nodes; i++)
234  {
235  if (actor->ar_nodes[i].nd_tyre_node || actor->ar_nodes[i].nd_rim_node)
236  {
237  actor->m_net_first_wheel_node = i;
238  break;
239  }
240  }
241 
242  // Initialize visuals
243  actor->updateVisual();
245 
246  // perform full visual update only if the vehicle won't be immediately driven by player.
247  if (actor->isPreloadedWithTerrain() || // .tobj file - Spawned sleeping somewhere on terrain
248  rq.asr_origin == ActorSpawnRequest::Origin::CONFIG_FILE || // RoR.cfg or commandline - not entered by default
249  actor->ar_num_cinecams == 0) // Not intended for player-controlling
250  {
251  actor->GetGfxActor()->UpdateSimDataBuffer(); // Initial fill of sim data buffers
252 
253  actor->GetGfxActor()->UpdateFlexbodies(); // Push tasks to threadpool
254  actor->GetGfxActor()->UpdateWheelVisuals(); // Push tasks to threadpool
255  actor->GetGfxActor()->UpdateCabMesh();
256  actor->GetGfxActor()->UpdateWingMeshes();
257  actor->GetGfxActor()->UpdateProps(0.f, false);
258  actor->GetGfxActor()->UpdateRods(); // beam visuals
259  actor->GetGfxActor()->FinishWheelUpdates(); // Sync tasks from threadpool
260  actor->GetGfxActor()->FinishFlexbodyTasks(); // Sync tasks from threadpool
261  }
262 
264 
265  if (actor->ar_engine)
266  {
268  actor->ar_engine->StartEngine();
269  else
270  actor->ar_engine->OffStart();
271  }
272  // pressurize tires
273  if (actor->getTyrePressure().IsEnabled())
274  {
275  actor->getTyrePressure().ModifyTyrePressure(0.f); // Initialize springiness of pressure-beams.
276  }
277 
279 
280  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
281  {
282  // network buffer layout (without RoRnet::VehicleState):
283  // -----------------------------------------------------
284 
285  // - 3 floats (x,y,z) for the reference node 0
286  // - ar_num_nodes - 1 times 3 short ints (compressed position info)
287  actor->m_net_node_buf_size = sizeof(float) * 3 + (actor->m_net_first_wheel_node - 1) * sizeof(short int) * 3;
289  // - ar_num_wheels times a float for the wheel rotation
290  actor->m_net_wheel_buf_size = actor->ar_num_wheels * sizeof(float);
292  // - bit array (made of ints) for the prop animation key states
294  (actor->m_prop_anim_key_states.size() / 8) + // whole chars
295  (size_t)(actor->m_prop_anim_key_states.size() % 8 != 0); // remainder: 0 or 1 chars
297 
299  {
301  if (actor->ar_engine)
302  {
303  actor->ar_engine->StartEngine();
304  }
305  }
306 
307  actor->m_net_username = rq.asr_net_username;
308  actor->m_net_color_num = rq.asr_net_color;
309  }
310  else if (App::sim_replay_enabled->getBool())
311  {
312  actor->m_replay_handler = new Replay(actor, App::sim_replay_length->getInt());
313  }
314 
315  // Launch scripts (FIXME: ignores sectionconfig)
316  for (RigDef::Script const& script_def : def->root_module->scripts)
317  {
319  }
320 
321  LOG(" ===== DONE LOADING VEHICLE");
322 
323  if (App::diag_actor_dump->getBool())
324  {
325  actor->WriteDiagnosticDump(actor->ar_filename + "_dump_recalc.txt"); // Saves file to 'logs'
326  }
327 
328  m_actors.push_back(ActorPtr(actor));
329 
330  return actor;
331 }
332 
334 {
335  m_stream_mismatches.erase(sourceid);
336 
337  for (ActorPtr& actor : m_actors)
338  {
339  if (actor->ar_state != ActorState::NETWORKED_OK)
340  continue;
341 
342  if (actor->ar_net_source_id == sourceid)
343  {
345  }
346  }
347 }
348 
349 #ifdef USE_SOCKETW
350 void ActorManager::HandleActorStreamData(std::vector<RoR::NetRecvPacket> packet_buffer)
351 {
352  // Sort by stream source
353  std::stable_sort(packet_buffer.begin(), packet_buffer.end(),
354  [](const RoR::NetRecvPacket& a, const RoR::NetRecvPacket& b)
355  { return a.header.source > b.header.source; });
356  // Compress data stream by eliminating all but the last update from every consecutive group of stream data updates
357  auto it = std::unique(packet_buffer.rbegin(), packet_buffer.rend(),
358  [](const RoR::NetRecvPacket& a, const RoR::NetRecvPacket& b)
359  { return !memcmp(&a.header, &b.header, sizeof(RoRnet::Header)) &&
360  a.header.command == RoRnet::MSG2_STREAM_DATA; });
361  packet_buffer.erase(packet_buffer.begin(), it.base());
362  for (auto& packet : packet_buffer)
363  {
364  if (packet.header.command == RoRnet::MSG2_STREAM_REGISTER)
365  {
366  RoRnet::StreamRegister* reg = (RoRnet::StreamRegister *)packet.buffer;
367  if (reg->type == 0)
368  {
369  reg->name[127] = 0;
370  // NOTE: The filename is by default in "Bundle-qualified" format, i.e. "mybundle.zip:myactor.truck"
371  std::string filename_maybe_bundlequalified = SanitizeUtf8CString(reg->name);
372  std::string filename;
373  std::string bundlename;
374  SplitBundleQualifiedFilename(filename_maybe_bundlequalified, /*out:*/ bundlename, /*out:*/ filename);
375 
376  RoRnet::UserInfo info;
377  if (!App::GetNetwork()->GetUserInfo(reg->origin_sourceid, info))
378  {
379  RoR::LogFormat("[RoR] Invalid STREAM_REGISTER, user id %d does not exist", reg->origin_sourceid);
380  reg->status = -1;
381  }
382  else if (filename.empty())
383  {
384  RoR::LogFormat("[RoR] Invalid STREAM_REGISTER (user '%s', ID %d), filename is empty string", info.username, reg->origin_sourceid);
385  reg->status = -1;
386  }
387  else
388  {
389  Str<200> text;
390  text << _L("spawned a new vehicle: ") << filename;
393 
394  LOG("[RoR] Creating remote actor for " + TOSTRING(reg->origin_sourceid) + ":" + TOSTRING(reg->origin_streamid));
395 
396  CacheEntryPtr actor_entry = App::GetCacheSystem()->FindEntryByFilename(LT_AllBeam, /*partial:*/false, filename_maybe_bundlequalified);
397 
398  if (!actor_entry)
399  {
402  _L("Mod not installed: ") + filename);
403  RoR::LogFormat("[RoR] Cannot create remote actor (not installed), filename: '%s'", filename_maybe_bundlequalified.c_str());
405  reg->status = -1;
406  }
407  else
408  {
409  auto actor_reg = reinterpret_cast<RoRnet::ActorStreamRegister*>(reg);
411  {
412  int offset = actor_reg->time - m_net_timer.getMilliseconds();
413  m_stream_time_offsets[reg->origin_sourceid] = offset - 100;
414  }
417  rq->asr_cache_entry = actor_entry;
418  if (strnlen(actor_reg->skin, 60) < 60 && actor_reg->skin[0] != '\0')
419  {
420  rq->asr_skin_entry = App::GetCacheSystem()->FetchSkinByName(actor_reg->skin); // FIXME: fetch skin by name+guid! ~ 03/2019
421  }
422  if (strnlen(actor_reg->sectionconfig, 60) < 60)
423  {
424  rq->asr_config = actor_reg->sectionconfig;
425  }
427  rq->asr_net_color = info.colournum;
428  rq->net_source_id = reg->origin_sourceid;
429  rq->net_stream_id = reg->origin_streamid;
430 
432  MSG_SIM_SPAWN_ACTOR_REQUESTED, (void*)rq));
433 
434  reg->status = 1;
435  }
436  }
437 
439  }
440  }
441  else if (packet.header.command == RoRnet::MSG2_STREAM_REGISTER_RESULT)
442  {
443  RoRnet::StreamRegister* reg = (RoRnet::StreamRegister *)packet.buffer;
444  for (ActorPtr& actor: m_actors)
445  {
446  if (actor->ar_net_source_id == reg->origin_sourceid && actor->ar_net_stream_id == reg->origin_streamid)
447  {
448  int sourceid = packet.header.source;
449  actor->ar_net_stream_results[sourceid] = reg->status;
450 
451  String message = "";
452  switch (reg->status)
453  {
454  case 1: message = "successfully loaded stream"; break;
455  case -2: message = "detected mismatch stream"; break;
456  default: message = "could not load stream"; break;
457  }
458  LOG("Client " + TOSTRING(sourceid) + " " + message + " " + TOSTRING(reg->origin_streamid) +
459  " with name '" + reg->name + "', result code: " + TOSTRING(reg->status));
460  break;
461  }
462  }
463  }
464  else if (packet.header.command == RoRnet::MSG2_STREAM_UNREGISTER)
465  {
466  ActorPtr b = this->GetActorByNetworkLinks(packet.header.source, packet.header.streamid);
467  if (b)
468  {
470  {
472  }
473  }
474  m_stream_mismatches[packet.header.source].erase(packet.header.streamid);
475  }
476  else if (packet.header.command == RoRnet::MSG2_USER_LEAVE)
477  {
478  this->RemoveStreamSource(packet.header.source);
479  }
480  else if (packet.header.command == RoRnet::MSG2_STREAM_DATA)
481  {
482  for (ActorPtr& actor: m_actors)
483  {
484  if (actor->ar_state != ActorState::NETWORKED_OK)
485  continue;
486  if (packet.header.source == actor->ar_net_source_id && packet.header.streamid == actor->ar_net_stream_id)
487  {
488  actor->pushNetwork(packet.buffer, packet.header.size);
489  break;
490  }
491  }
492  }
493  }
494 }
495 #endif // USE_SOCKETW
496 
498 {
499  auto search = m_stream_time_offsets.find(sourceid);
500  if (search != m_stream_time_offsets.end())
501  {
502  return search->second;
503  }
504  return 0;
505 }
506 
507 void ActorManager::UpdateNetTimeOffset(int sourceid, int offset)
508 {
509  if (m_stream_time_offsets.find(sourceid) != m_stream_time_offsets.end())
510  {
511  m_stream_time_offsets[sourceid] += offset;
512  }
513 }
514 
516 {
517  if (!m_stream_mismatches[sourceid].empty())
518  return 0;
519 
520  for (ActorPtr& actor: m_actors)
521  {
522  if (actor->ar_state != ActorState::NETWORKED_OK)
523  continue;
524 
525  if (actor->ar_net_source_id == sourceid)
526  {
527  return 1;
528  }
529  }
530 
531  return 2;
532 }
533 
535 {
536  int result = 2;
537 
538  for (ActorPtr& actor: m_actors)
539  {
540  if (actor->ar_state == ActorState::NETWORKED_OK)
541  continue;
542 
543  int stream_result = actor->ar_net_stream_results[sourceid];
544  if (stream_result == -1 || stream_result == -2)
545  return 0;
546  if (stream_result == 1)
547  result = 1;
548  }
549 
550  return result;
551 }
552 
553 const ActorPtr& ActorManager::GetActorByNetworkLinks(int source_id, int stream_id)
554 {
555  for (ActorPtr& actor: m_actors)
556  {
557  if (actor->ar_net_source_id == source_id && actor->ar_net_stream_id == stream_id)
558  {
559  return actor;
560  }
561  }
562 
563  return ACTORPTR_NULL;
564 }
565 
567 {
568  if (m_actors[a]->ar_collision_bounding_boxes.empty() && m_actors[b]->ar_collision_bounding_boxes.empty())
569  {
570  return m_actors[a]->ar_bounding_box.intersects(m_actors[b]->ar_bounding_box);
571  }
572  else if (m_actors[a]->ar_collision_bounding_boxes.empty())
573  {
574  for (const auto& bbox_b : m_actors[b]->ar_collision_bounding_boxes)
575  if (bbox_b.intersects(m_actors[a]->ar_bounding_box))
576  return true;
577  }
578  else if (m_actors[b]->ar_collision_bounding_boxes.empty())
579  {
580  for (const auto& bbox_a : m_actors[a]->ar_collision_bounding_boxes)
581  if (bbox_a.intersects(m_actors[b]->ar_bounding_box))
582  return true;
583  }
584  else
585  {
586  for (const auto& bbox_a : m_actors[a]->ar_collision_bounding_boxes)
587  for (const auto& bbox_b : m_actors[b]->ar_collision_bounding_boxes)
588  if (bbox_a.intersects(bbox_b))
589  return true;
590  }
591 
592  return false;
593 }
594 
596 {
597  if (m_actors[a]->ar_predicted_coll_bounding_boxes.empty() && m_actors[b]->ar_predicted_coll_bounding_boxes.empty())
598  {
599  return m_actors[a]->ar_predicted_bounding_box.intersects(m_actors[b]->ar_predicted_bounding_box);
600  }
601  else if (m_actors[a]->ar_predicted_coll_bounding_boxes.empty())
602  {
603  for (const auto& bbox_b : m_actors[b]->ar_predicted_coll_bounding_boxes)
604  if (bbox_b.intersects(m_actors[a]->ar_predicted_bounding_box))
605  return true;
606  }
607  else if (m_actors[b]->ar_predicted_coll_bounding_boxes.empty())
608  {
609  for (const auto& bbox_a : m_actors[a]->ar_predicted_coll_bounding_boxes)
610  if (bbox_a.intersects(m_actors[b]->ar_predicted_bounding_box))
611  return true;
612  }
613  else
614  {
615  for (const auto& bbox_a : m_actors[a]->ar_predicted_coll_bounding_boxes)
616  for (const auto& bbox_b : m_actors[b]->ar_predicted_coll_bounding_boxes)
617  if (bbox_a.intersects(bbox_b))
618  return true;
619  }
620 
621  return false;
622 }
623 
624 void ActorManager::RecursiveActivation(int j, std::vector<bool>& visited)
625 {
626  if (visited[j] || m_actors[j]->ar_state != ActorState::LOCAL_SIMULATED)
627  return;
628 
629  visited[j] = true;
630 
631  for (unsigned int t = 0; t < m_actors.size(); t++)
632  {
633  if (t == j || visited[t])
634  continue;
636  {
637  m_actors[t]->ar_sleep_counter = 0.0f;
638  this->RecursiveActivation(t, visited);
639  }
641  {
642  m_actors[t]->ar_sleep_counter = 0.0f;
643  m_actors[t]->ar_state = ActorState::LOCAL_SIMULATED;
644  this->RecursiveActivation(t, visited);
645  }
646  }
647 }
648 
650 {
651  if (source_actor->ar_forward_commands)
652  {
653  auto linked_actors = source_actor->ar_linked_actors;
654 
655  for (ActorPtr& actor : this->GetActors())
656  {
657  if (actor != source_actor && actor->ar_import_commands &&
658  (actor->getPosition().distance(source_actor->getPosition()) <
659  actor->m_min_camera_radius + source_actor->m_min_camera_radius))
660  {
661  // activate the truck
662  if (actor->ar_state == ActorState::LOCAL_SLEEPING)
663  {
664  actor->ar_sleep_counter = 0.0f;
665  actor->ar_state = ActorState::LOCAL_SIMULATED;
666  }
667 
668  if (App::sim_realistic_commands->getBool())
669  {
670  if (std::find(linked_actors.begin(), linked_actors.end(), actor) == linked_actors.end())
671  continue;
672  }
673 
674  // forward commands
675  for (int j = 1; j <= MAX_COMMANDS; j++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
676  {
677  actor->ar_command_key[j].playerInputValue = std::max(source_actor->ar_command_key[j].playerInputValue,
678  source_actor->ar_command_key[j].commandValue);
679  }
680  if (source_actor->ar_toggle_ties)
681  {
682  //actor->tieToggle();
685  rq->alr_actor_instance_id = actor->ar_instance_id;
686  rq->alr_tie_group = -1;
688 
689  }
690  if (source_actor->ar_toggle_ropes)
691  {
692  //actor->ropeToggle(-1);
695  rq->alr_actor_instance_id = actor->ar_instance_id;
696  rq->alr_rope_group = -1;
698  }
699  }
700  }
701  // just send brake and lights to the connected trucks, and no one else :)
702  for (auto hook : source_actor->ar_hooks)
703  {
704  if (!hook.hk_locked_actor || hook.hk_locked_actor == source_actor)
705  continue;
706 
707  // forward brakes
708  hook.hk_locked_actor->ar_brake = source_actor->ar_brake;
709  if (hook.hk_locked_actor->ar_parking_brake != source_actor->ar_trailer_parking_brake)
710  {
711  hook.hk_locked_actor->parkingbrakeToggle();
712  }
713 
714  // forward lights
715  hook.hk_locked_actor->setLightStateMask(source_actor->getLightStateMask());
716  }
717  }
718 }
719 
721 {
722  for (auto& entry: inter_actor_links)
723  {
724  auto& actor_pair = entry.second;
725  if ((actor_pair.first == a1 && actor_pair.second == a2) ||
726  (actor_pair.first == a2 && actor_pair.second == a1))
727  {
728  return true;
729  }
730  }
731  return false;
732 }
733 
734 void ActorManager::UpdateSleepingState(ActorPtr player_actor, float dt)
735 {
736  if (!m_forced_awake)
737  {
738  for (ActorPtr& actor: m_actors)
739  {
740  if (actor->ar_state != ActorState::LOCAL_SIMULATED)
741  continue;
742  if (actor->ar_driveable == AI)
743  continue;
744  if (actor->getVelocity().squaredLength() > 0.01f)
745  {
746  actor->ar_sleep_counter = 0.0f;
747  continue;
748  }
749 
750  actor->ar_sleep_counter += dt;
751 
752  if (actor->ar_sleep_counter >= 10.0f)
753  {
754  actor->ar_state = ActorState::LOCAL_SLEEPING;
755  }
756  }
757  }
758 
759  if (player_actor && player_actor->ar_state == ActorState::LOCAL_SLEEPING)
760  {
761  player_actor->ar_state = ActorState::LOCAL_SIMULATED;
762  }
763 
764  std::vector<bool> visited(m_actors.size());
765  // Recursivly activate all actors which can be reached from current actor
766  if (player_actor && player_actor->ar_state == ActorState::LOCAL_SIMULATED)
767  {
768  player_actor->ar_sleep_counter = 0.0f;
769  this->RecursiveActivation(player_actor->ar_vector_index, visited);
770  }
771  // Snowball effect (activate all actors which might soon get hit by a moving actor)
772  for (unsigned int t = 0; t < m_actors.size(); t++)
773  {
774  if (m_actors[t]->ar_state == ActorState::LOCAL_SIMULATED && m_actors[t]->ar_sleep_counter == 0.0f)
775  this->RecursiveActivation(t, visited);
776  }
777 }
778 
780 {
781  for (ActorPtr& actor: m_actors)
782  {
783  if (actor->ar_state == ActorState::LOCAL_SLEEPING)
784  {
785  actor->ar_state = ActorState::LOCAL_SIMULATED;
786  actor->ar_sleep_counter = 0.0f;
787  }
788  }
789 }
790 
792 {
793  m_forced_awake = false;
794  for (ActorPtr& actor: m_actors)
795  {
796  if (actor->ar_state == ActorState::LOCAL_SIMULATED)
797  {
798  actor->ar_state = ActorState::LOCAL_SLEEPING;
799  }
800  }
801 }
802 
803 ActorPtr ActorManager::FindActorInsideBox(Collisions* collisions, const Ogre::String& inst, const Ogre::String& box)
804 {
805  // try to find the desired actor (the one in the box)
806  ActorPtr ret = nullptr;
807  for (ActorPtr& actor: m_actors)
808  {
809  if (collisions->isInside(actor->ar_nodes[0].AbsPosition, inst, box))
810  {
811  if (ret == nullptr)
812  // first actor found
813  ret = actor;
814  else
815  // second actor found -> unclear which one was meant
816  return nullptr;
817  }
818  }
819  return ret;
820 }
821 
822 void ActorManager::RepairActor(Collisions* collisions, const Ogre::String& inst, const Ogre::String& box, bool keepPosition)
823 {
824  ActorPtr actor = this->FindActorInsideBox(collisions, inst, box);
825  if (actor != nullptr)
826  {
828 
830  rq->amr_actor = actor->ar_instance_id;
833  }
834 }
835 
837 {
838  for (ActorPtr& actor: m_actors)
839  {
840  actor->muteAllSounds();
841  }
842 }
843 
845 {
846  for (ActorPtr& actor: m_actors)
847  {
848  actor->unmuteAllSounds();
849  }
850 }
851 
852 std::pair<ActorPtr, float> ActorManager::GetNearestActor(Vector3 position)
853 {
854  ActorPtr nearest_actor = nullptr;
855  float min_squared_distance = std::numeric_limits<float>::max();
856  for (ActorPtr& actor : m_actors)
857  {
858  float squared_distance = position.squaredDistance(actor->ar_nodes[0].AbsPosition);
859  if (squared_distance < min_squared_distance)
860  {
861  min_squared_distance = squared_distance;
862  nearest_actor = actor;
863  }
864  }
865  return std::make_pair(nearest_actor, std::sqrt(min_squared_distance));
866 }
867 
868 void ActorManager::CleanUpSimulation() // Called after simulation finishes
869 {
870  while (m_actors.size() > 0)
871  {
872  this->DeleteActorInternal(m_actors.back()); // OK to invoke here - CleanUpSimulation() - processing `MSG_SIM_UNLOAD_TERRAIN_REQUESTED`
873  }
874 
875  m_total_sim_time = 0.f;
877  m_simulation_paused = false;
878  m_simulation_speed = 1.f;
879 }
880 
882 {
883  if (actor == nullptr || actor->ar_state == ActorState::DISPOSED)
884  return;
885 
886  this->SyncWithSimThread();
887 
888 #ifdef USE_SOCKETW
889  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
890  {
891  if (actor->ar_state != ActorState::NETWORKED_OK)
892  {
894  }
895  else if (std::count_if(m_actors.begin(), m_actors.end(), [actor](ActorPtr& b)
896  { return b->ar_net_source_id == actor->ar_net_source_id; }) == 1)
897  {
898  // We're deleting the last actor from this stream source, reset the stream time offset
900  }
901  }
902 #endif // USE_SOCKETW
903 
904  // Unload actor's scripts
905  std::vector<ScriptUnitId_t> unload_list;
906  for (auto& pair : App::GetScriptEngine()->getScriptUnits())
907  {
908  if (pair.second.associatedActor == actor)
909  unload_list.push_back(pair.first);
910  }
911  for (ScriptUnitId_t id : unload_list)
912  {
914  }
915 
916  // Remove FreeForces referencing this actor
917  m_free_forces.erase(
918  std::remove_if(
919  m_free_forces.begin(),
920  m_free_forces.end(),
921  [actor](FreeForce& item) { return item.ffc_base_actor == actor || item.ffc_target_actor == actor; }),
922  m_free_forces.end());
923 
924  // Only dispose(), do not `delete`; a script may still hold pointer to the object.
925  actor->dispose();
926 
927  EraseIf(m_actors, [actor](ActorPtr& curActor) { return actor == curActor; });
928 
929  // Upate actor indices
930  for (unsigned int i = 0; i < m_actors.size(); i++)
931  m_actors[i]->ar_vector_index = i;
932 }
933 
934 // ACTORLIST for cycling with hotkeys
935 // ----------------------------------
936 
937 int FindPivotActorId(ActorPtr player, ActorPtr prev_player)
938 {
939  if (player != nullptr)
940  return player->ar_vector_index;
941  else if (prev_player != nullptr)
942  return prev_player->ar_vector_index + 1;
943  return -1;
944 }
945 
947 {
948  bool retval = !actor->isPreloadedWithTerrain();
949 
950  // Exclude remote actors, if desired
951  if (!App::mp_cyclethru_net_actors->getBool())
952  {
954  {
955  retval = false;
956  }
957  }
958 
959  return retval;
960 }
961 
963 {
964  int pivot_index = FindPivotActorId(player, prev_player);
965 
966  for (int i = pivot_index + 1; i < m_actors.size(); i++)
967  {
969  return m_actors[i];
970  }
971 
972  for (int i = 0; i < pivot_index; i++)
973  {
975  return m_actors[i];
976  }
977 
978  if (pivot_index >= 0)
979  {
980  if (ShouldIncludeActorInList(m_actors[pivot_index]))
981  return m_actors[pivot_index];
982  }
983 
984  return ACTORPTR_NULL;
985 }
986 
988 {
989  int pivot_index = FindPivotActorId(player, prev_player);
990 
991  for (int i = pivot_index - 1; i >= 0; i--)
992  {
994  return m_actors[i];
995  }
996 
997  for (int i = static_cast<int>(m_actors.size()) - 1; i > pivot_index; i--)
998  {
1000  return m_actors[i];
1001  }
1002 
1003  if (pivot_index >= 0)
1004  {
1005  if (ShouldIncludeActorInList(m_actors[pivot_index]))
1006  return m_actors[pivot_index];
1007  }
1008 
1009  return ACTORPTR_NULL;
1010 }
1011 
1012 // END actorlist
1013 
1015 {
1016  for (ActorPtr& actor: m_actors)
1017  {
1018  if (actor->ar_rescuer_flag)
1019  {
1020  return actor;
1021  }
1022  }
1023  return ACTORPTR_NULL;
1024 }
1025 
1027 {
1028  float dt = m_simulation_time;
1029 
1030  // do not allow dt > 1/20
1031  dt = std::min(dt, 1.0f / 20.0f);
1032 
1033  dt *= m_simulation_speed;
1034 
1035  dt += m_dt_remainder;
1036  m_physics_steps = dt / PHYSICS_DT;
1037  if (m_physics_steps == 0)
1038  {
1039  return;
1040  }
1041 
1043  dt = PHYSICS_DT * m_physics_steps;
1044 
1045  this->SyncWithSimThread();
1046 
1047  this->UpdateSleepingState(player_actor, dt);
1048 
1049  for (ActorPtr& actor: m_actors)
1050  {
1051  actor->HandleInputEvents(dt);
1052  actor->HandleAngelScriptEvents(dt);
1053 
1054 #ifdef USE_ANGELSCRIPT
1055  if (actor->ar_vehicle_ai && actor->ar_vehicle_ai->isActive())
1056  actor->ar_vehicle_ai->update(dt, 0);
1057 #endif // USE_ANGELSCRIPT
1058 
1059  if (actor->ar_engine)
1060  {
1061  if (actor->ar_driveable == TRUCK)
1062  {
1063  this->UpdateTruckFeatures(actor, dt);
1064  }
1065  if (actor->ar_state == ActorState::LOCAL_SLEEPING)
1066  {
1067  actor->ar_engine->UpdateEngineSim(dt, 1);
1068  }
1069  actor->ar_engine->UpdateEngineAudio();
1070  }
1071 
1072  // Always update indicator states - used by 'u' type flares.
1073  actor->updateDashBoards(dt);
1074 
1075  // Blinkers (turn signals) must always be updated
1076  actor->updateFlareStates(dt);
1077 
1078  if (actor->ar_state != ActorState::LOCAL_SLEEPING)
1079  {
1080  actor->updateVisual(dt);
1081  if (actor->ar_update_physics && App::gfx_skidmarks_mode->getInt() > 0)
1082  {
1083  actor->updateSkidmarks();
1084  }
1085  }
1086  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
1087  {
1088  // FIXME: Hidden actors must also be updated to workaround a glitch, see https://github.com/RigsOfRods/rigs-of-rods/issues/2911
1089  if (actor->ar_state == ActorState::NETWORKED_OK || actor->ar_state == ActorState::NETWORKED_HIDDEN)
1090  actor->calcNetwork();
1091  else
1092  actor->sendStreamData();
1093  }
1094  }
1095 
1096  if (player_actor != nullptr)
1097  {
1098  this->ForwardCommands(player_actor);
1099  if (player_actor->ar_toggle_ties)
1100  {
1101  //player_actor->tieToggle();
1104  rq->alr_actor_instance_id = player_actor->ar_instance_id;
1105  rq->alr_tie_group = -1;
1107 
1108  player_actor->ar_toggle_ties = false;
1109  }
1110  if (player_actor->ar_toggle_ropes)
1111  {
1112  //player_actor->ropeToggle(-1);
1115  rq->alr_actor_instance_id = player_actor->ar_instance_id;
1116  rq->alr_rope_group = -1;
1118 
1119  player_actor->ar_toggle_ropes = false;
1120  }
1121 
1122  player_actor->ForceFeedbackStep(m_physics_steps);
1123 
1124  if (player_actor->ar_state == ActorState::LOCAL_REPLAY)
1125  {
1126  player_actor->getReplay()->replayStepActor();
1127  }
1128  }
1129 
1130  auto func = std::function<void()>([this]()
1131  {
1132  this->UpdatePhysicsSimulation();
1133  });
1134  m_sim_task = m_sim_thread_pool->RunTask(func);
1135 
1136  m_total_sim_time += dt;
1137 
1138  if (!App::app_async_physics->getBool())
1139  m_sim_task->join();
1140 }
1141 
1143 {
1144  for (ActorPtr& actor: m_actors)
1145  {
1146  if (actor->ar_instance_id == actor_id)
1147  {
1148  return actor;
1149  }
1150  }
1151  return ACTORPTR_NULL;
1152 }
1153 
1155 {
1156  for (ActorPtr& actor: m_actors)
1157  {
1158  actor->UpdatePhysicsOrigin();
1159  }
1160  for (int i = 0; i < m_physics_steps; i++)
1161  {
1162  {
1163  std::vector<std::function<void()>> tasks;
1164  for (ActorPtr& actor: m_actors)
1165  {
1166  if (actor->ar_update_physics = actor->CalcForcesEulerPrepare(i == 0))
1167  {
1168  auto func = std::function<void()>([this, i, &actor]()
1169  {
1170  actor->CalcForcesEulerCompute(i == 0, m_physics_steps);
1171  });
1172  tasks.push_back(func);
1173  }
1174  }
1175  App::GetThreadPool()->Parallelize(tasks);
1176  for (ActorPtr& actor: m_actors)
1177  {
1178  if (actor->ar_update_physics)
1179  {
1180  actor->CalcBeamsInterActor();
1181  }
1182  }
1183  }
1184  {
1185  std::vector<std::function<void()>> tasks;
1186  for (ActorPtr& actor: m_actors)
1187  {
1188  if (actor->m_inter_point_col_detector != nullptr && (actor->ar_update_physics ||
1189  (App::mp_pseudo_collisions->getBool() && actor->ar_state == ActorState::NETWORKED_OK)))
1190  {
1191  auto func = std::function<void()>([this, &actor]()
1192  {
1193  actor->m_inter_point_col_detector->UpdateInterPoint();
1194  if (actor->ar_collision_relevant)
1195  {
1196  ResolveInterActorCollisions(PHYSICS_DT,
1197  *actor->m_inter_point_col_detector,
1198  actor->ar_num_collcabs,
1199  actor->ar_collcabs,
1200  actor->ar_cabs,
1201  actor->ar_inter_collcabrate,
1202  actor->ar_nodes,
1203  actor->ar_collision_range,
1204  *actor->ar_submesh_ground_model);
1205  }
1206  });
1207  tasks.push_back(func);
1208  }
1209  }
1210  App::GetThreadPool()->Parallelize(tasks);
1211  }
1212 
1213  // Apply FreeForces - intentionally as a separate pass over all actors
1214  this->CalcFreeForces();
1215  }
1216  for (ActorPtr& actor: m_actors)
1217  {
1218  actor->m_ongoing_reset = false;
1219  if (actor->ar_update_physics && m_physics_steps > 0)
1220  {
1221  Vector3 camera_gforces = actor->m_camera_gforces_accu / m_physics_steps;
1222  actor->m_camera_gforces_accu = Vector3::ZERO;
1223  actor->m_camera_gforces = actor->m_camera_gforces * 0.5f + camera_gforces * 0.5f;
1224  actor->calculateLocalGForces();
1225  actor->calculateAveragePosition();
1226  actor->m_avg_node_velocity = actor->m_avg_node_position - actor->m_avg_node_position_prev;
1227  actor->m_avg_node_velocity /= (m_physics_steps * PHYSICS_DT);
1228  actor->m_avg_node_position_prev = actor->m_avg_node_position;
1229  actor->ar_top_speed = std::max(actor->ar_top_speed, actor->ar_nodes[0].Velocity.length());
1230  }
1231  }
1232 }
1233 
1235 {
1236  if (m_sim_task)
1237  m_sim_task->join();
1238 }
1239 
1240 void HandleErrorLoadingFile(std::string type, std::string filename, std::string exception_msg)
1241 {
1242  RoR::Str<200> msg;
1243  msg << "Failed to load '" << filename << "' (type: '" << type << "'), message: " << exception_msg;
1246 }
1247 
1248 void HandleErrorLoadingTruckfile(std::string filename, std::string exception_msg)
1249 {
1250  HandleErrorLoadingFile("actor", filename, exception_msg);
1251 }
1252 
1254 {
1255  // Check the actor exists in mod cache
1256  if (rq.asr_cache_entry == nullptr)
1257  {
1258  HandleErrorLoadingTruckfile(rq.asr_filename, "Truckfile not found in ModCache (probably not installed)");
1259  return nullptr;
1260  }
1261 
1262  // If already parsed, re-use
1263  if (rq.asr_cache_entry->actor_def != nullptr)
1264  {
1265  return rq.asr_cache_entry->actor_def;
1266  }
1267 
1268  // Load the 'truckfile'
1269  try
1270  {
1272  Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(rq.asr_cache_entry->fname, rq.asr_cache_entry->resource_group);
1273 
1274  if (stream.isNull() || !stream->isReadable())
1275  {
1276  HandleErrorLoadingTruckfile(rq.asr_cache_entry->fname, "Unable to open/read truckfile");
1277  return nullptr;
1278  }
1279 
1280  RoR::LogFormat("[RoR] Parsing truckfile '%s'", rq.asr_cache_entry->fname.c_str());
1281  RigDef::Parser parser;
1282  parser.Prepare();
1283  parser.ProcessOgreStream(stream.getPointer(), rq.asr_cache_entry->resource_group);
1284  parser.Finalize();
1285 
1286  auto def = parser.GetFile();
1287 
1288  // VALIDATING
1289  LOG(" == Validating vehicle: " + def->name);
1290 
1291  RigDef::Validator validator;
1292  validator.Setup(def);
1293 
1295  {
1296  // Workaround: Some terrains pre-load truckfiles with special purpose:
1297  // "soundloads" = play sound effect at certain spot
1298  // "fixes" = structures of N/B fixed to the ground
1299  // These files can have no beams. Possible extensions: .load or .fixed
1300  std::string file_extension = rq.asr_cache_entry->fname.substr(rq.asr_cache_entry->fname.find_last_of('.'));
1301  Ogre::StringUtil::toLowerCase(file_extension);
1302  if ((file_extension == ".load") || (file_extension == ".fixed"))
1303  {
1304  validator.SetCheckBeams(false);
1305  }
1306  }
1307 
1308  validator.Validate(); // Sends messages to console
1309 
1310  def->hash = Sha1Hash(stream->getAsString());
1311 
1312  rq.asr_cache_entry->actor_def = def;
1313  return def;
1314  }
1315  catch (Ogre::Exception& oex)
1316  {
1317  HandleErrorLoadingTruckfile(rq.asr_cache_entry->fname, oex.getDescription().c_str());
1318  return nullptr;
1319  }
1320  catch (std::exception& stex)
1321  {
1323  return nullptr;
1324  }
1325  catch (...)
1326  {
1327  HandleErrorLoadingTruckfile(rq.asr_cache_entry->fname, "<Unknown exception occurred>");
1328  return nullptr;
1329  }
1330 }
1331 
1332 std::vector<ActorPtr> ActorManager::GetLocalActors()
1333 {
1334  std::vector<ActorPtr> actors;
1335  for (ActorPtr& actor: m_actors)
1336  {
1337  if (actor->ar_state != ActorState::NETWORKED_OK)
1338  actors.push_back(actor);
1339  }
1340  return actors;
1341 }
1342 
1344 {
1345  // Simulation pace adjustment (slowmotion)
1346  if (!App::GetGameContext()->GetRaceSystem().IsRaceInProgress())
1347  {
1348  // EV_COMMON_ACCELERATE_SIMULATION
1349  if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_ACCELERATE_SIMULATION))
1350  {
1351  float simulation_speed = this->GetSimulationSpeed() * pow(2.0f, dt / 2.0f);
1352  this->SetSimulationSpeed(simulation_speed);
1353  String ssmsg = _L("New simulation speed: ") + TOSTRING(Round(simulation_speed * 100.0f, 1)) + "%";
1355  }
1356 
1357  // EV_COMMON_DECELERATE_SIMULATION
1358  if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_DECELERATE_SIMULATION))
1359  {
1360  float simulation_speed = this->GetSimulationSpeed() * pow(0.5f, dt / 2.0f);
1361  this->SetSimulationSpeed(simulation_speed);
1362  String ssmsg = _L("New simulation speed: ") + TOSTRING(Round(simulation_speed * 100.0f, 1)) + "%";
1364  }
1365 
1366  // EV_COMMON_RESET_SIMULATION_PACE
1367  if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_RESET_SIMULATION_PACE))
1368  {
1369  float simulation_speed = this->GetSimulationSpeed();
1370  if (simulation_speed != 1.0f)
1371  {
1372  m_last_simulation_speed = simulation_speed;
1373  this->SetSimulationSpeed(1.0f);
1374  UTFString ssmsg = _L("Simulation speed reset.");
1376  }
1377  else if (m_last_simulation_speed != 1.0f)
1378  {
1380  String ssmsg = _L("New simulation speed: ") + TOSTRING(Round(m_last_simulation_speed * 100.0f, 1)) + "%";
1382  }
1383  }
1384 
1385  // Special adjustment while racing
1386  if (App::GetGameContext()->GetRaceSystem().IsRaceInProgress() && this->GetSimulationSpeed() != 1.0f)
1387  {
1389  this->SetSimulationSpeed(1.f);
1390  }
1391  }
1392 
1393  // EV_COMMON_TOGGLE_PHYSICS - Freeze/unfreeze physics
1394  if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_PHYSICS))
1395  {
1397 
1398  if (m_simulation_paused)
1399  {
1400  String ssmsg = _L("Physics paused");
1402  }
1403  else
1404  {
1405  String ssmsg = _L("Physics unpaused");
1407  }
1408  }
1409 
1410  // Calculate simulation time
1411  if (m_simulation_paused)
1412  {
1413  m_simulation_time = 0.f;
1414 
1415  // Frozen physics stepping
1416  if (this->GetSimulationSpeed() > 0.0f)
1417  {
1418  // EV_COMMON_REPLAY_FAST_FORWARD - Advance simulation while pressed
1419  // EV_COMMON_REPLAY_FORWARD - Advanced simulation one step
1420  if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_REPLAY_FAST_FORWARD) ||
1421  App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_REPLAY_FORWARD))
1422  {
1424  }
1425  }
1426  }
1427  else
1428  {
1429  m_simulation_time = dt;
1430  }
1431 }
1432 
1434 {
1435  if (vehicle->isBeingReset() || vehicle->ar_physics_paused)
1436  return;
1437 #ifdef USE_ANGELSCRIPT
1438  if (vehicle->ar_vehicle_ai && vehicle->ar_vehicle_ai->isActive())
1439  return;
1440 #endif // USE_ANGELSCRIPT
1441 
1442  EngineSim* engine = vehicle->ar_engine;
1443 
1444  if (engine && engine->hasContact() &&
1445  engine->GetAutoShiftMode() == SimGearboxMode::AUTO &&
1446  engine->getAutoShift() != EngineSim::NEUTRAL)
1447  {
1448  Ogre::Vector3 dirDiff = vehicle->getDirection();
1449  Ogre::Degree pitchAngle = Ogre::Radian(asin(dirDiff.dotProduct(Ogre::Vector3::UNIT_Y)));
1450 
1451  if (std::abs(pitchAngle.valueDegrees()) > 2.0f)
1452  {
1453  if (engine->getAutoShift() > EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed < +0.02f && pitchAngle.valueDegrees() > 0.0f ||
1454  engine->getAutoShift() < EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed > -0.02f && pitchAngle.valueDegrees() < 0.0f)
1455  {
1456  // anti roll back in SimGearboxMode::AUTO (DRIVE, TWO, ONE) mode
1457  // anti roll forth in SimGearboxMode::AUTO (REAR) mode
1458  float g = std::abs(App::GetGameContext()->GetTerrain()->getGravity());
1459  float downhill_force = std::abs(sin(pitchAngle.valueRadians()) * vehicle->getTotalMass()) * g;
1460  float engine_force = std::abs(engine->GetTorque()) / vehicle->getAvgPropedWheelRadius();
1461  float ratio = std::max(0.0f, 1.0f - (engine_force / downhill_force));
1462  if (vehicle->ar_avg_wheel_speed * pitchAngle.valueDegrees() > 0.0f)
1463  {
1464  ratio *= sqrt((0.02f - vehicle->ar_avg_wheel_speed) / 0.02f);
1465  }
1466  vehicle->ar_brake = sqrt(ratio);
1467  }
1468  }
1469  else if (vehicle->ar_brake == 0.0f && !vehicle->ar_parking_brake && engine->GetTorque() == 0.0f)
1470  {
1471  float ratio = std::max(0.0f, 0.2f - std::abs(vehicle->ar_avg_wheel_speed)) / 0.2f;
1472  vehicle->ar_brake = ratio;
1473  }
1474  }
1475 
1476  if (vehicle->cc_mode)
1477  {
1478  vehicle->UpdateCruiseControl(dt);
1479  }
1480  if (vehicle->sl_enabled)
1481  {
1482  // check speed limit
1483  if (engine && engine->GetGear() != 0)
1484  {
1485  float accl = (vehicle->sl_speed_limit - std::abs(vehicle->ar_wheel_speed / 1.02f)) * 2.0f;
1486  engine->SetAcceleration(Ogre::Math::Clamp(accl, 0.0f, engine->GetAcceleration()));
1487  }
1488  }
1489 
1490  BITMASK_SET(vehicle->m_lightmask, RoRnet::LIGHTMASK_BRAKES, (vehicle->ar_brake > 0.01f && !vehicle->ar_parking_brake));
1491  BITMASK_SET(vehicle->m_lightmask, RoRnet::LIGHTMASK_REVERSE, (vehicle->ar_engine && vehicle->ar_engine->GetGear() < 0));
1492 }
1493 
1495 {
1496  for (FreeForce& freeforce: m_free_forces)
1497  {
1498  // Sanity checks
1499  ROR_ASSERT(freeforce.ffc_base_actor != nullptr);
1500  ROR_ASSERT(freeforce.ffc_base_actor->ar_state != ActorState::DISPOSED);
1501  ROR_ASSERT(freeforce.ffc_base_node != NODENUM_INVALID);
1502  ROR_ASSERT(freeforce.ffc_base_node <= freeforce.ffc_base_actor->ar_num_nodes);
1503 
1504 
1505  switch (freeforce.ffc_type)
1506  {
1508  freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * freeforce.ffc_force_const_direction;
1509  break;
1510 
1512  {
1513  const Vector3 force_direction = (freeforce.ffc_target_coords - freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].AbsPosition).normalisedCopy();
1514  freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * force_direction;
1515  }
1516  break;
1517 
1519  {
1520  // Sanity checks
1521  ROR_ASSERT(freeforce.ffc_target_actor != nullptr);
1522  ROR_ASSERT(freeforce.ffc_target_actor->ar_state != ActorState::DISPOSED);
1523  ROR_ASSERT(freeforce.ffc_target_node != NODENUM_INVALID);
1524  ROR_ASSERT(freeforce.ffc_target_node <= freeforce.ffc_target_actor->ar_num_nodes);
1525 
1526  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();
1527  freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * force_direction;
1528  }
1529  break;
1530 
1531  default:
1532  break;
1533  }
1534  }
1535 }
1536 
1537 static bool ProcessFreeForce(FreeForceRequest* rq, FreeForce& freeforce)
1538 {
1539  // internal helper for processing add/modify requests, with checks
1540  // ---------------------------------------------------------------
1541 
1542  // Unchecked stuff
1543  freeforce.ffc_id = (FreeForceID_t)rq->ffr_id;
1544  freeforce.ffc_type = (FreeForceType)rq->ffr_type;
1545  freeforce.ffc_force_magnitude = (float)rq->ffr_force_magnitude;
1547  freeforce.ffc_target_coords = rq->ffr_target_coords;
1548 
1549  // Base actor
1551  ROR_ASSERT(freeforce.ffc_base_actor != nullptr && freeforce.ffc_base_actor->ar_state != ActorState::DISPOSED);
1552  if (!freeforce.ffc_base_actor || freeforce.ffc_base_actor->ar_state == ActorState::DISPOSED)
1553  {
1555  fmt::format("Cannot add free force with ID {} to actor {}: Base actor not found or disposed", freeforce.ffc_id, rq->ffr_base_actor));
1556  return false;
1557  }
1558 
1559  // Base node
1560  ROR_ASSERT(rq->ffr_base_node >= 0);
1563  if (rq->ffr_base_node < 0 || rq->ffr_base_node >= NODENUM_MAX || rq->ffr_base_node >= freeforce.ffc_base_actor->ar_num_nodes)
1564  {
1566  fmt::format("Cannot add free force with ID {} to actor {}: Invalid base node number {}", freeforce.ffc_id, rq->ffr_base_actor, rq->ffr_base_node));
1567  return false;
1568  }
1569  freeforce.ffc_base_node = (NodeNum_t)rq->ffr_base_node;
1570 
1571  if (freeforce.ffc_type == FreeForceType::TOWARDS_NODE)
1572  {
1573  // Target actor
1575  ROR_ASSERT(freeforce.ffc_target_actor != nullptr && freeforce.ffc_target_actor->ar_state != ActorState::DISPOSED);
1576  if (!freeforce.ffc_target_actor || freeforce.ffc_target_actor->ar_state == ActorState::DISPOSED)
1577  {
1579  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));
1580  return false;
1581  }
1582 
1583  // Target node
1584  ROR_ASSERT(rq->ffr_target_node >= 0);
1587  if (rq->ffr_target_node < 0 || rq->ffr_target_node >= NODENUM_MAX || rq->ffr_target_node >= freeforce.ffc_target_actor->ar_num_nodes)
1588  {
1590  fmt::format("Cannot add free force of type 'TOWARDS_NODE' with ID {} to actor {}: Invalid target node number {}", freeforce.ffc_id, rq->ffr_target_actor, rq->ffr_target_node));
1591  return false;
1592  }
1593  freeforce.ffc_target_node = (NodeNum_t)rq->ffr_target_node;
1594  }
1595 
1596  return true;
1597 }
1598 
1599 ActorManager::FreeForceVec_t::iterator ActorManager::FindFreeForce(FreeForceID_t id)
1600 {
1601  return std::find_if(m_free_forces.begin(), m_free_forces.end(), [id](FreeForce& item) { return id == item.ffc_id; });
1602 }
1603 
1605 {
1606  // Make sure ID is unique
1607  if (this->FindFreeForce(rq->ffr_id) != m_free_forces.end())
1608  {
1610  fmt::format("Cannot add free force with ID {}: ID already in use", rq->ffr_id));
1611  return;
1612  }
1613 
1614  FreeForce freeforce;
1615  if (ProcessFreeForce(rq, freeforce))
1616  {
1617  m_free_forces.push_back(freeforce);
1618  }
1619 }
1620 
1622 {
1623  auto it = this->FindFreeForce(rq->ffr_id);
1624  if (it == m_free_forces.end())
1625  {
1627  fmt::format("Cannot modify free force with ID {}: ID not found", rq->ffr_id));
1628  return;
1629  }
1630 
1631  FreeForce& freeforce = *it;
1632  if (ProcessFreeForce(rq, freeforce))
1633  {
1634  *it = freeforce;
1635  }
1636 }
1637 
1639 {
1640  auto it = this->FindFreeForce(id);
1641  if (it == m_free_forces.end())
1642  {
1644  fmt::format("Cannot remove free force with ID {}: ID not found", id));
1645  return;
1646  }
1647 
1648  m_free_forces.erase(it);
1649 }
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
GameContext.h
Game state manager and message-queue provider.
RoR::Actor::ar_avg_wheel_speed
float ar_avg_wheel_speed
Physics state; avg wheel speed in m/s.
Definition: Actor.h:402
MAX_COMMANDS
static const int MAX_COMMANDS
maximum number of commands per actor
Definition: SimConstants.h:28
RoR::GfxActor::SetDebugView
void SetDebugView(DebugViewType dv)
Definition: GfxActor.cpp:1528
RoR::Actor::resetPosition
void resetPosition(Ogre::Vector3 translation, bool setInitPosition)
Moves the actor to given world coords.
Definition: Actor.cpp:1315
RoR::Actor::cc_mode
bool cc_mode
Cruise Control.
Definition: Actor.h:364
RoR::App::GetNetwork
Network * GetNetwork()
Definition: Application.cpp:284
RoRnet::ActorStreamRegister
< Must preserve mem. layout of RoRnet::StreamRegister
Definition: RoRnet.h:150
RoR::ActorManager::GetSimulationSpeed
float GetSimulationSpeed() const
Definition: ActorManager.h:93
RoR::ActorManager::CheckNetworkStreamsOk
int CheckNetworkStreamsOk(int sourceid)
Definition: ActorManager.cpp:515
RoR::EV_COMMON_REPLAY_FORWARD
@ EV_COMMON_REPLAY_FORWARD
Definition: InputEngine.h:255
RoR::Actor
Softbody object; can be anything from soda can to a space shuttle Constructed from a truck definition...
Definition: Actor.h:49
RoR::Actor::ar_vehicle_ai
VehicleAIPtr ar_vehicle_ai
Definition: Actor.h:397
RoR::ActorSpawnRequest::asr_net_color
int asr_net_color
Definition: SimData.h:860
RoR::ActorSpawnRequest::asr_free_position
bool asr_free_position
Disables the automatic spawn position adjustment.
Definition: SimData.h:863
RoRnet::MSG2_STREAM_UNREGISTER
@ MSG2_STREAM_UNREGISTER
remove stream
Definition: RoRnet.h:65
BITMASK_SET
void BITMASK_SET(BitMask_t &mask, BitMask_t flag, bool val)
Definition: BitFlags.h:19
RoR::Actor::m_section_config
Ogre::String m_section_config
Definition: Actor.h:539
RoR::ActorSpawnRequest::Origin::NETWORK
@ NETWORK
Remote controlled.
RoR::MSG_SIM_MODIFY_ACTOR_REQUESTED
@ MSG_SIM_MODIFY_ACTOR_REQUESTED
Payload = RoR::ActorModifyRequest* (owner)
Definition: Application.h:120
RoR::FreeForce::ffc_target_node
NodeNum_t ffc_target_node
Definition: SimData.h:800
RoR::EV_COMMON_TOGGLE_PHYSICS
@ EV_COMMON_TOGGLE_PHYSICS
toggle physics on/off
Definition: InputEngine.h:271
RoR::Actor::ar_physics_paused
bool ar_physics_paused
Sim state.
Definition: Actor.h:484
RoRnet::ActorStreamRegister::time
int32_t time
initial time stamp
Definition: RoRnet.h:160
RoR::FreeForceRequest::ffr_target_node
int64_t ffr_target_node
Definition: SimData.h:818
RoR::GfxActor::UpdateSimDataBuffer
void UpdateSimDataBuffer()
Copies sim. data from Actor to GfxActor for later update.
Definition: GfxActor.cpp:1727
RoR::TRUCK
@ TRUCK
its a truck (or other land vehicle)
Definition: SimData.h:93
RoR::Actor::ar_filename
std::string ar_filename
Attribute; filled at spawn.
Definition: Actor.h:425
RoR::MpState::CONNECTED
@ CONNECTED
RoR::ActorManager::GetNetTimeOffset
int GetNetTimeOffset(int sourceid)
Definition: ActorManager.cpp:497
RoR::ActorManager::ACTORPTR_NULL
static const ActorPtr ACTORPTR_NULL
Definition: ActorManager.h:127
RoR::ActorSpawner::ConfigureSections
void ConfigureSections(Ogre::String const &sectionconfig, RigDef::DocumentPtr def)
Definition: ActorSpawner.cpp:90
RoR::TyrePressure::ModifyTyrePressure
bool ModifyTyrePressure(float v)
Definition: TyrePressure.cpp:64
RoR::ActorSpawnRequest::Origin::CONFIG_FILE
@ CONFIG_FILE
'Preselected vehicle' in RoR.cfg or command line
RoR::ActorSpawnRequest::asr_origin
Origin asr_origin
Definition: SimData.h:857
RoR::ActorSpawner::ActorMemoryRequirements::num_fixes
size_t num_fixes
Definition: ActorSpawner.h:84
RoR::Actor::ar_vector_index
unsigned int ar_vector_index
Sim attr; actor element index in std::vector<m_actors>
Definition: Actor.h:377
RoR::node_t::AbsPosition
Ogre::Vector3 AbsPosition
absolute position in the world (shaky)
Definition: SimData.h:294
RoR::ActorManager::m_actors
ActorPtrVec m_actors
Definition: ActorManager.h:145
VehicleAI.h
Simple waypoint AI.
RoR::App::diag_actor_dump
CVar * diag_actor_dump
Definition: Application.cpp:158
RoR::Actor::ar_parking_brake
bool ar_parking_brake
Definition: Actor.h:414
RoR::Collisions
Definition: Collisions.h:80
RoRnet::UserInfo
Definition: RoRnet.h:170
RoR::ActorLinkingRequest
Estabilishing a physics linkage between 2 actors modifies a global linkage table and triggers immedia...
Definition: SimData.h:917
DashBoardManager.h
RoR::Actor::ar_linked_actors
ActorPtrVec ar_linked_actors
BEWARE: Includes indirect links, see DetermineLinkedActors(); Other actors linked using 'hooks/ties/r...
Definition: Actor.h:447
RoR::Actor::ar_instance_id
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
Definition: Actor.h:376
RoR::Actor::m_net_first_wheel_node
int m_net_first_wheel_node
Network attr; Determines data buffer layout; calculated on spawn.
Definition: Actor.h:607
RoR::Actor::ar_num_nodes
int ar_num_nodes
Definition: Actor.h:283
HandleErrorLoadingTruckfile
void HandleErrorLoadingTruckfile(std::string filename, std::string exception_msg)
Definition: ActorManager.cpp:1248
RoR::Actor::ar_bounding_box
Ogre::AxisAlignedBox ar_bounding_box
standard bounding box (surrounds all nodes of an actor)
Definition: Actor.h:306
RigDef::Parser::GetFile
RigDef::DocumentPtr GetFile()
Definition: RigDef_Parser.h:77
RigDef::Parser::Finalize
void Finalize()
Definition: RigDef_Parser.cpp:2824
ContentManager.h
GUI_TopMenubar.h
RoR::App::gfx_skidmarks_mode
CVar * gfx_skidmarks_mode
Definition: Application.cpp:235
ThreadPool.h
RoR::NODENUM_INVALID
static const NodeNum_t NODENUM_INVALID
Definition: ForwardDeclarations.h:53
RoR::ActorState::LOCAL_REPLAY
@ LOCAL_REPLAY
RoR::GfxActor::UpdateRods
void UpdateRods()
Definition: GfxActor.cpp:1598
RoR::Collisions::defaultgm
ground_model_t * defaultgm
Definition: Collisions.h:174
format
Truck file format(technical spec)
RoR::ActorManager::AddFreeForce
void AddFreeForce(FreeForceRequest *rq)
Definition: ActorManager.cpp:1604
HandleErrorLoadingFile
void HandleErrorLoadingFile(std::string type, std::string filename, std::string exception_msg)
Definition: ActorManager.cpp:1240
RoR::collision_box_t::lo
Ogre::Vector3 lo
absolute collision box
Definition: SimData.h:723
RoR::ActorManager::inter_actor_links
std::map< beam_t *, std::pair< ActorPtr, ActorPtr > > inter_actor_links
Definition: ActorManager.h:124
RoR::Actor::sendStreamSetup
void sendStreamSetup()
Definition: Actor.cpp:1943
RoR::DebugViewType
DebugViewType
Definition: GfxData.h:101
RoR::ActorState::DISPOSED
@ DISPOSED
removed from simulation, still in memory to satisfy pointers.
RoRnet::LIGHTMASK_REVERSE
@ LIGHTMASK_REVERSE
reverse light on
Definition: RoRnet.h:119
RoR::ActorManager::RemoveStreamSource
void RemoveStreamSource(int sourceid)
Definition: ActorManager.cpp:333
RoR::ActorLinkingRequest::alr_type
ActorLinkingRequestType alr_type
Definition: SimData.h:920
RoR::Actor::m_min_camera_radius
Ogre::Real m_min_camera_radius
Definition: Actor.h:552
RoR::CVar::getBool
bool getBool() const
Definition: CVar.h:98
RoR::TRIGGER_EVENT_ASYNC
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(),...
Definition: ScriptEngine.h:51
RoR::Actor::ar_brake
Ogre::Real ar_brake
Physics state; braking intensity.
Definition: Actor.h:399
RoR::Actor::sl_enabled
bool sl_enabled
Speed limiter;.
Definition: Actor.h:370
RoR::ActorManager::FindActorInsideBox
ActorPtr FindActorInsideBox(Collisions *collisions, const Ogre::String &inst, const Ogre::String &box)
Definition: ActorManager.cpp:803
RoR::Actor::ar_engine
EngineSim * ar_engine
Definition: Actor.h:379
RoR::Replay::replayStepActor
void replayStepActor()
Definition: Replay.cpp:215
RigDef::Parser
Checks the rig-def file syntax and pulls data to File object.
Definition: RigDef_Parser.h:56
RoR::beam_t::strength
float strength
Definition: SimData.h:343
RoR::ActorManager::CheckActorCollAabbIntersect
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...
Definition: ActorManager.cpp:566
RoR::Round
Ogre::Real Round(Ogre::Real value, unsigned short ndigits=0)
Definition: Utils.cpp:98
RoR::FreeForce::ffc_force_magnitude
float ffc_force_magnitude
Definition: SimData.h:793
RoR::LogFormat
void LogFormat(const char *format,...)
Improved logging utility. Uses fixed 2Kb buffer.
Definition: Application.cpp:424
DynamicCollisions.h
RoR::SplitBundleQualifiedFilename
void SplitBundleQualifiedFilename(const std::string &bundleQualifiedFilename, std::string &out_bundleName, std::string &out_filename)
Definition: Utils.cpp:228
RoRnet::StreamRegister::origin_sourceid
int32_t origin_sourceid
origin sourceid
Definition: RoRnet.h:144
RoR::App::sim_replay_length
CVar * sim_replay_length
Definition: Application.cpp:102
RoR::collision_box_t::hi
Ogre::Vector3 hi
absolute collision box
Definition: SimData.h:724
RoR::Actor::ar_toggle_ropes
bool ar_toggle_ropes
Sim state.
Definition: Actor.h:482
Console.h
RoR::Console::putMessage
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
Definition: Console.cpp:97
RoR::Actor::ar_hooks
std::vector< hook_t > ar_hooks
Definition: Actor.h:302
RoR::EngineSim
A land vehicle engine + transmission.
Definition: EngineSim.h:35
RoR::Actor::ar_trailer_parking_brake
bool ar_trailer_parking_brake
Definition: Actor.h:415
RoR::CacheEntry::resource_group
Ogre::String resource_group
Resource group of the loaded bundle. Empty if not loaded yet.
Definition: CacheSystem.h:89
RoR::ActorManager::GetActors
ActorPtrVec & GetActors()
Definition: ActorManager.h:119
MovableText.h
This creates a billboarding object that displays a text.
RoR::Actor::sl_speed_limit
float sl_speed_limit
Speed limiter;.
Definition: Actor.h:371
RoR::ActorSpawner::ConfigureAddonParts
void ConfigureAddonParts(TuneupDefPtr &tuneup_def)
Definition: ActorSpawner.cpp:109
RoR::ActorManager::GetActorByNetworkLinks
const ActorPtr & GetActorByNetworkLinks(int source_id, int stream_id)
Definition: ActorManager.cpp:553
RoR::SE_GENERIC_NEW_TRUCK
@ SE_GENERIC_NEW_TRUCK
triggered when the user spawns a new actor, the argument refers to the actor ID
Definition: ScriptEvents.h:47
RoR::ActorManager::FetchPreviousVehicleOnList
const ActorPtr & FetchPreviousVehicleOnList(ActorPtr player, ActorPtr prev_player)
Definition: ActorManager.cpp:987
RoR::GfxActor::UpdateCabMesh
void UpdateCabMesh()
Definition: GfxActor.cpp:1901
TuneupFileFormat.h
The vehicle tuning system; applies addonparts and user overrides to vehicles.
RoR::GfxActor::FinishFlexbodyTasks
void FinishFlexbodyTasks()
Definition: GfxActor.cpp:3154
RoR::FreeForce::ffc_target_actor
ActorPtr ffc_target_actor
Definition: SimData.h:799
RoR::FreeForceType
FreeForceType
Definition: SimData.h:779
RoR::Actor::GetGfxActor
GfxActor * GetGfxActor()
Definition: Actor.h:269
RoR::ScriptEngine::loadScript
ScriptUnitId_t loadScript(Ogre::String scriptname, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, std::string buffer="")
Loads a script.
Definition: ScriptEngine.cpp:759
RoR::ActorManager::GetNearestActor
std::pair< ActorPtr, float > GetNearestActor(Ogre::Vector3 position)
Definition: ActorManager.cpp:852
RigDef::Validator::Setup
void Setup(RigDef::DocumentPtr file)
Prepares the validation.
Definition: RigDef_Validator.cpp:85
RoR::ActorManager::SyncWithSimThread
void SyncWithSimThread()
Definition: ActorManager.cpp:1234
RoR::ActorLinkingRequestType::ROPE_TOGGLE
@ ROPE_TOGGLE
RoR::ActorState::LOCAL_SIMULATED
@ LOCAL_SIMULATED
simulated (local) actor
Utils.h
RoR::ActorManager::AreActorsDirectlyLinked
bool AreActorsDirectlyLinked(const ActorPtr &a1, const ActorPtr &a2)
Definition: ActorManager.cpp:720
RoR::ActorSpawnRequest::asr_filename
std::string asr_filename
Can be in "Bundle-qualified" format, i.e. "mybundle.zip:myactor.truck".
Definition: SimData.h:849
RoR::node_t::RelPosition
Ogre::Vector3 RelPosition
relative to the local physics origin (one origin per actor) (shaky)
Definition: SimData.h:293
RoR::EngineSim::SetAcceleration
void SetAcceleration(float val)
Definition: EngineSim.cpp:852
Language.h
RoR::FreeForceRequest::ffr_base_actor
int64_t ffr_base_actor
Definition: SimData.h:812
RoR::ActorManager::m_stream_time_offsets
std::map< int, int > m_stream_time_offsets
Networking: A network time offset for each stream source.
Definition: ActorManager.h:141
RefCountingObjectPtr< Actor >
ActorSpawner.h
Vehicle spawning logic.
RoR::Console::CONSOLE_SYSTEM_ERROR
@ CONSOLE_SYSTEM_ERROR
Definition: Console.h:52
RigDef::Parser::ProcessOgreStream
void ProcessOgreStream(Ogre::DataStream *stream, Ogre::String resource_group)
Definition: RigDef_Parser.cpp:3379
RoR::FreeForce::ffc_base_node
NodeNum_t ffc_base_node
Definition: SimData.h:795
GUIManager.h
RoR::Actor::ar_forward_commands
bool ar_forward_commands
Sim state.
Definition: Actor.h:480
RoR::NODENUM_MAX
static const NodeNum_t NODENUM_MAX
Definition: ForwardDeclarations.h:54
ActorManager.h
Actor.h
RoR::collision_box_t::center
Ogre::Vector3 center
center of rotation
Definition: SimData.h:725
RoR::App::GetScriptEngine
ScriptEngine * GetScriptEngine()
Definition: Application.cpp:279
RoR::App::mp_cyclethru_net_actors
CVar * mp_cyclethru_net_actors
Include remote actors when cycling through with CTRL + [ and CTRL + ].
Definition: Application.cpp:127
RoR::ActorSpawner
Processes a RigDef::Document (parsed from 'truck' file format) into a simulated gameplay object (Acto...
Definition: ActorSpawner.h:70
RoR::Console::CONSOLE_SYSTEM_NOTICE
@ CONSOLE_SYSTEM_NOTICE
Definition: Console.h:51
RoR::Actor::m_net_wheel_buf_size
size_t m_net_wheel_buf_size
For incoming/outgoing traffic; calculated on spawn.
Definition: Actor.h:603
RoR::ActorSpawnRequest
Definition: SimData.h:832
EngineSim.h
RoR::Actor::ar_wheel_speed
float ar_wheel_speed
Physics state; wheel speed in m/s.
Definition: Actor.h:400
RoR::ActorManager::SendAllActorsSleeping
void SendAllActorsSleeping()
Definition: ActorManager.cpp:791
RoR::SimGearboxMode::AUTO
@ AUTO
Automatic shift.
RoR::beam_t::initial_beam_strength
float initial_beam_strength
for reset
Definition: SimData.h:360
RoR::FreeForce::ffc_id
FreeForceID_t ffc_id
Definition: SimData.h:791
RoR::ActorManager::AddStreamMismatch
void AddStreamMismatch(int sourceid, int streamid)
Definition: ActorManager.h:85
RoR::GfxActor::FinishWheelUpdates
void FinishWheelUpdates()
Definition: GfxActor.cpp:1927
RoR::App::mp_state
CVar * mp_state
Definition: Application.cpp:115
RoR::FreeForceRequest::ffr_force_const_direction
Ogre::Vector3 ffr_force_const_direction
Definition: SimData.h:815
Replay.h
RoR::ActorModifyRequest::amr_actor
ActorInstanceID_t amr_actor
Definition: SimData.h:886
RoR::Actor::getReplay
Replay * getReplay()
Definition: Actor.cpp:4566
RoR::EV_COMMON_ACCELERATE_SIMULATION
@ EV_COMMON_ACCELERATE_SIMULATION
accelerate the simulation speed
Definition: InputEngine.h:223
RoR::GfxActor::UpdateProps
void UpdateProps(float dt, bool is_player_actor)
Definition: GfxActor.cpp:2226
RoR::FreeForce::ffc_type
FreeForceType ffc_type
Definition: SimData.h:792
RoR::Actor::m_disable_default_sounds
bool m_disable_default_sounds
Spawner context; TODO: remove.
Definition: Actor.h:633
RoR::ActorSpawnRequest::asr_config
Ogre::String asr_config
Definition: SimData.h:850
TOSTRING
#define TOSTRING(x)
Definition: Application.h:56
RoR::Actor::getAvgPropedWheelRadius
float getAvgPropedWheelRadius()
Definition: Actor.h:257
RoR::Actor::isPreloadedWithTerrain
bool isPreloadedWithTerrain() const
Definition: Actor.h:238
RoR::VehicleAI::isActive
bool isActive()
Returns the status of the AI.
Definition: VehicleAI.cpp:58
RoR::ActorManager::m_simulation_speed
float m_simulation_speed
slow motion < 1.0 < fast motion
Definition: ActorManager.h:149
RoR::ActorManager::m_stream_mismatches
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.
Definition: ActorManager.h:140
RoR::FreeForceType::TOWARDS_COORDS
@ TOWARDS_COORDS
Constant force directed towards ffc_target_coords
RoR::ActorInstanceID_t
int ActorInstanceID_t
Unique sequentially generated ID of an actor in session. Use ActorManager::GetActorById()
Definition: ForwardDeclarations.h:37
RoR::ActorManager::CalcFreeForces
void CalcFreeForces()
Apply FreeForces - intentionally as a separate pass over all actors.
Definition: ActorManager.cpp:1494
RoR::ActorManager::UpdateSleepingState
void UpdateSleepingState(ActorPtr player_actor, float dt)
Definition: ActorManager.cpp:734
RoR::Actor::ar_beams
beam_t * ar_beams
Definition: Actor.h:287
RoR::ActorManager::PredictActorCollAabbIntersect
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...
Definition: ActorManager.cpp:595
RoR::ActorManager::m_simulation_paused
bool m_simulation_paused
Definition: ActorManager.h:152
RoRnet::MSG2_STREAM_DATA
@ MSG2_STREAM_DATA
stream data
Definition: RoRnet.h:66
RoR::NodeNum_t
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
Definition: ForwardDeclarations.h:52
RoR::ActorManager::m_dt_remainder
float m_dt_remainder
Keeps track of the rounding error in the time step calculation.
Definition: ActorManager.h:148
RoR::Str< 200 >
RoR::FreeForceRequest::ffr_base_node
int64_t ffr_base_node
Definition: SimData.h:813
RoR::CacheSystem::FindEntryByFilename
CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string &_filename_maybe_bundlequalified)
Returns NULL if none found; "Bundle-qualified" format also specifies the ZIP/directory in modcache,...
Definition: CacheSystem.cpp:184
RoR::Collisions::getGroundModelByString
ground_model_t * getGroundModelByString(const Ogre::String name)
Definition: Collisions.cpp:365
RoR::ActorManager::RemoveFreeForce
void RemoveFreeForce(FreeForceID_t id)
Definition: ActorManager.cpp:1638
RigDef::Validator
Performs a formal validation of the file (missing required parts, conflicts of modules,...
Definition: RigDef_Validator.h:47
RoR::beam_t::d
float d
damping factor
Definition: SimData.h:338
RoR::ActorManager::FindFreeForce
FreeForceVec_t::iterator FindFreeForce(FreeForceID_t id)
Definition: ActorManager.cpp:1599
RigDef_Validator.h
.truck format validator
RoR::ActorManager::UnmuteAllActors
void UnmuteAllActors()
Definition: ActorManager.cpp:844
RoR::ActorModifyRequest
Definition: SimData.h:870
RoR::FreeForce::ffc_force_const_direction
Ogre::Vector3 ffc_force_const_direction
Expected to be normalized; only effective with FreeForceType::CONSTANT
Definition: SimData.h:797
RoR::ScriptEngine::unloadScript
void unloadScript(ScriptUnitId_t unique_id)
Unloads a script.
Definition: ScriptEngine.cpp:964
RoR::GfxScene::RegisterGfxActor
void RegisterGfxActor(RoR::GfxActor *gfx_actor)
Definition: GfxScene.cpp:276
CacheSystem.h
A database of user-installed content alias 'mods' (vehicles, terrains...)
RoR::collision_box_t::relo
Ogre::Vector3 relo
relative collision box
Definition: SimData.h:731
RoR::ActorManager::m_sim_task
std::shared_ptr< Task > m_sim_task
Definition: ActorManager.h:159
RoR::ActorSpawner::ConfigureAssetPacks
void ConfigureAssetPacks(ActorPtr actor, RigDef::DocumentPtr def)
Definition: ActorSpawner.cpp:143
RoR::ActorManager::HandleActorStreamData
void HandleActorStreamData(std::vector< RoR::NetRecvPacket > packet)
Definition: ActorManager.cpp:350
RoRnet::MSG2_STREAM_REGISTER
@ MSG2_STREAM_REGISTER
create new stream
Definition: RoRnet.h:63
RoR::ActorSpawnRequest::asr_cache_entry
CacheEntryPtr asr_cache_entry
Optional, overrides 'asr_filename' and 'asr_cache_entry_num'.
Definition: SimData.h:848
ScriptEngine.h
RoR::Actor::getTyrePressure
TyrePressure & getTyrePressure()
Definition: Actor.h:220
RoR::GameContext::PushMessage
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
Definition: GameContext.cpp:65
strnlen
#define strnlen(str, len)
Definition: InputEngine.cpp:397
RoR::ActorManager::GetLocalActors
std::vector< ActorPtr > GetLocalActors()
Definition: ActorManager.cpp:1332
RoR::ActorManager::m_sim_thread_pool
std::unique_ptr< ThreadPool > m_sim_thread_pool
Definition: ActorManager.h:158
RoR::Replay
Definition: Replay.h:39
RoR::ThreadPool
Facilitates execution of (small) tasks on separate threads.
Definition: ThreadPool.h:105
RoR::ScriptUnitId_t
int ScriptUnitId_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
Definition: ForwardDeclarations.h:40
m_actor_counter
static ActorInstanceID_t m_actor_counter
Definition: ActorManager.cpp:61
RoR::Actor::updateVisual
void updateVisual(float dt=0)
Definition: Actor.cpp:3215
RoR::EngineSim::GetTorque
float GetTorque()
Definition: EngineSim.cpp:913
ChatSystem.h
RoR::ActorSpawner::ProcessNewActor
void ProcessNewActor(ActorPtr actor, ActorSpawnRequest rq, RigDef::DocumentPtr def)
Definition: ActorSpawnerFlow.cpp:59
RoR::Actor::ar_origin
Ogre::Vector3 ar_origin
Physics state; base position for softbody nodes.
Definition: Actor.h:385
RoR::Str::ToCStr
const char * ToCStr() const
Definition: Str.h:46
RoR::ActorState::LOCAL_SLEEPING
@ LOCAL_SLEEPING
sleeping (local) actor
RoR::FreeForceID_t
int FreeForceID_t
Unique sequentially generated ID of FreeForce; use ActorManager::GetFreeForceNextId().
Definition: ForwardDeclarations.h:65
RoR::EngineSim::GetAutoShiftMode
RoR::SimGearboxMode GetAutoShiftMode()
Definition: EngineSim.cpp:842
RoR::Actor::ar_command_key
CmdKeyArray ar_command_key
BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
Definition: Actor.h:305
RoR::FreeForceType::CONSTANT
@ CONSTANT
Constant force given by direction and magnitude.
RoR::Terrain::GetCollisions
Collisions * GetCollisions()
Definition: Terrain.h:83
RoR::CacheEntry::actor_def
RigDef::DocumentPtr actor_def
Cached actor definition (aka truckfile) after first spawn.
Definition: CacheSystem.h:91
RoR::Actor::getPosition
Ogre::Vector3 getPosition()
Definition: Actor.cpp:424
RoR::FreeForceRequest::ffr_target_coords
Ogre::Vector3 ffr_target_coords
Definition: SimData.h:816
GfxScene.h
RoR::node_t::nd_tyre_node
bool nd_tyre_node
Attr; This node is part of a tyre (note some wheel types don't use rim nodes at all)
Definition: SimData.h:311
RoR::Actor::NotifyActorCameraChanged
void NotifyActorCameraChanged()
Logic: sound, display; Notify this vehicle that camera changed;.
Definition: Actor.cpp:3844
RoR::Actor::ForceFeedbackStep
void ForceFeedbackStep(int steps)
Definition: Actor.cpp:1784
RoR::Actor::WriteDiagnosticDump
void WriteDiagnosticDump(std::string const &filename)
Definition: Actor.cpp:4629
RoR::EV_COMMON_REPLAY_FAST_FORWARD
@ EV_COMMON_REPLAY_FAST_FORWARD
Definition: InputEngine.h:254
RoR::ActorLinkingRequest::alr_rope_group
int alr_rope_group
Definition: SimData.h:927
RoR::Actor::ar_import_commands
bool ar_import_commands
Sim state.
Definition: Actor.h:481
FindPivotActorId
int FindPivotActorId(ActorPtr player, ActorPtr prev_player)
Definition: ActorManager.cpp:937
RoR::ActorManager::UpdateNetTimeOffset
void UpdateNetTimeOffset(int sourceid, int offset)
Definition: ActorManager.cpp:507
RoR::EngineSim::hasContact
bool hasContact() const
Definition: EngineSim.h:127
RoR::ActorManager::m_physics_steps
int m_physics_steps
Definition: ActorManager.h:147
Application.h
Central state/object manager and communications hub.
RoR::Actor::m_net_propanimkey_buf_size
size_t m_net_propanimkey_buf_size
For incoming/outgoing traffic; calculated on spawn.
Definition: Actor.h:604
RoR::App::GetConsole
Console * GetConsole()
Definition: Application.cpp:270
RoR::FreeForce::ffc_base_actor
ActorPtr ffc_base_actor
Definition: SimData.h:794
RoR::Actor::m_net_color_num
int m_net_color_num
Definition: Actor.h:610
RigDef::Parser::Prepare
void Prepare()
Definition: RigDef_Parser.cpp:2707
RoRnet::MSG2_STREAM_REGISTER_RESULT
@ MSG2_STREAM_REGISTER_RESULT
result of a stream creation
Definition: RoRnet.h:64
SoundScriptManager.h
RoR::Actor::ar_initial_beam_defaults
std::vector< std::pair< float, float > > ar_initial_beam_defaults
Definition: Actor.h:312
RoR::App::GetGameContext
GameContext * GetGameContext()
Definition: Application.cpp:280
RoR::Actor::UpdateCruiseControl
void UpdateCruiseControl(float dt)
Defined in 'gameplay/CruiseControl.cpp'.
Definition: CruiseControl.cpp:48
RoR::ActorManager::FetchRescueVehicle
const ActorPtr & FetchRescueVehicle()
Definition: ActorManager.cpp:1014
RoR::Actor::m_lightmask
BitMask_t m_lightmask
RoRnet::Lightmask.
Definition: Actor.h:616
RoR::Actor::m_dry_mass
float m_dry_mass
Physics attr;.
Definition: Actor.h:586
RoR::FreeForceRequest::ffr_force_magnitude
double ffr_force_magnitude
Definition: SimData.h:811
RigDef::Validator::SetCheckBeams
void SetCheckBeams(bool check_beams)
Definition: RigDef_Validator.h:77
RoR::FreeForce
Global force affecting particular (base) node of particular (base) actor; added ad-hoc by scripts.
Definition: SimData.h:788
RoR::ActorManager::m_total_sim_time
float m_total_sim_time
Definition: ActorManager.h:153
RoR::Actor::m_prop_anim_key_states
std::vector< PropAnimKeyState > m_prop_anim_key_states
Definition: Actor.h:598
RoR::Actor::ar_initial_total_mass
float ar_initial_total_mass
Definition: Actor.h:309
RoR::Actor::ar_sleep_counter
float ar_sleep_counter
Sim state; idle time counter.
Definition: Actor.h:412
RoR::Actor::m_spawn_rotation
float m_spawn_rotation
Definition: Actor.h:561
RoR::Actor::getDirection
Ogre::Vector3 getDirection()
average actor velocity, calculated using the actor positions of the last two frames
Definition: Actor.cpp:419
RoR::ActorSpawnRequest::net_stream_id
int net_stream_id
Definition: SimData.h:862
RoR::ActorSpawnRequest::Origin::TERRN_DEF
@ TERRN_DEF
Preloaded with terrain.
RoR::ActorSpawnRequest::asr_skin_entry
CacheEntryPtr asr_skin_entry
Definition: SimData.h:854
RoRnet::LIGHTMASK_BRAKES
@ LIGHTMASK_BRAKES
brake lights on
Definition: RoRnet.h:118
RoR::ActorManager::m_simulation_time
float m_simulation_time
Amount of time the physics simulation is going to be advanced.
Definition: ActorManager.h:151
RoR::Actor::ar_num_beams
int ar_num_beams
Definition: Actor.h:288
RoR::ActorManager::SetSimulationSpeed
void SetSimulationSpeed(float speed)
Definition: ActorManager.h:92
RoR::Actor::m_preloaded_with_terrain
bool m_preloaded_with_terrain
Spawn context (TODO: remove!)
Definition: Actor.h:629
RoR::Actor::m_replay_handler
Replay * m_replay_handler
Definition: Actor.h:556
RoR::Actor::getTotalMass
float getTotalMass(bool withLocked=true)
Definition: Actor.cpp:807
RoR::EngineSim::GetGear
int GetGear()
low level gear changing
Definition: EngineSim.cpp:1041
RoR::Actor::m_net_total_buffer_size
size_t m_net_total_buffer_size
For incoming/outgoing traffic; calculated on spawn.
Definition: Actor.h:605
RoR::ActorManager::m_last_simulation_speed
float m_last_simulation_speed
previously used time ratio between real time (evt.timeSinceLastFrame) and physics time ('dt' used in ...
Definition: ActorManager.h:150
RoR::Actor::RecalculateNodeMasses
void RecalculateNodeMasses(Ogre::Real total)
Previously 'calc_masses2()'.
Definition: Actor.cpp:715
RoR::Actor::ar_num_cinecams
int ar_num_cinecams
Sim attr;.
Definition: Actor.h:381
RoRnet::StreamRegister::status
int32_t status
initial stream status
Definition: RoRnet.h:143
PointColDetector.h
RoR::ActorManager::RecursiveActivation
void RecursiveActivation(int j, std::vector< bool > &visited)
Definition: ActorManager.cpp:624
RoR::SanitizeUtf8CString
std::string SanitizeUtf8CString(const char *start, const char *end=nullptr)
Definition: Utils.cpp:125
RoR::Actor::m_total_mass
float m_total_mass
Physics state; total mass in Kg.
Definition: Actor.h:557
RoRnet::StreamRegister::type
int32_t type
0 = Actor, 1 = Character, 3 = ChatSystem
Definition: RoRnet.h:142
RoR::ActorManager::DeleteActorInternal
void DeleteActorInternal(ActorPtr actor)
Do not call directly; use GameContext::DeleteActor()
Definition: ActorManager.cpp:881
RigDef::Script
Definition: RigDef_File.h:1170
RoR::Actor::m_net_node_buf_size
size_t m_net_node_buf_size
For incoming/outgoing traffic; calculated on spawn.
Definition: Actor.h:602
RoR::App::sim_realistic_commands
CVar * sim_realistic_commands
Definition: Application.cpp:104
RoR::Actor::ar_initial_node_positions
std::vector< Ogre::Vector3 > ar_initial_node_positions
Definition: Actor.h:311
RoR::App::GetCacheSystem
CacheSystem * GetCacheSystem()
Definition: Application.cpp:272
RoR::Sha1Hash
std::string Sha1Hash(std::string const &data)
Definition: Utils.cpp:138
RoR::CacheSystem::FetchSkinByName
CacheEntryPtr FetchSkinByName(std::string const &skin_name)
Definition: CacheSystem.cpp:1560
ProcessFreeForce
static bool ProcessFreeForce(FreeForceRequest *rq, FreeForce &freeforce)
Definition: ActorManager.cpp:1537
RoR::ActorManager::MuteAllActors
void MuteAllActors()
Definition: ActorManager.cpp:836
RoRnet::UserInfo::colournum
int32_t colournum
colour set by server
Definition: RoRnet.h:175
RigDef::Script::filename
std::string filename
Definition: RigDef_File.h:1172
RoRnet::StreamRegister::name
char name[128]
file name
Definition: RoRnet.h:146
RoR::Actor::ar_nodes
node_t * ar_nodes
Definition: Actor.h:279
RoR::FreeForceRequest
Common for ADD and MODIFY requests; tailored for use with AngelScript thru GameScript::pushMessage().
Definition: SimData.h:804
RoRnet::UserInfo::username
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
Definition: RoRnet.h:177
RoR::ActorLinkingRequest::alr_tie_group
int alr_tie_group
Definition: SimData.h:925
RoR::Actor::ar_toggle_ties
bool ar_toggle_ties
Sim state.
Definition: Actor.h:483
RoR::Actor::getRotation
float getRotation()
Definition: Actor.cpp:409
RoR::node_t::nd_rim_node
bool nd_rim_node
Attr; This node is part of a rim (only wheel types with separate rim nodes)
Definition: SimData.h:310
RoR::beam_t::k
float k
tensile spring
Definition: SimData.h:337
RoR::CacheSystem::LoadResource
void LoadResource(CacheEntryPtr &t)
Loads the associated resource bundle if not already done.
Definition: CacheSystem.cpp:1435
RoR::EngineSim::getAutoShift
int getAutoShift()
Definition: EngineSim.cpp:1184
RoR::MSG_SIM_ACTOR_LINKING_REQUESTED
@ MSG_SIM_ACTOR_LINKING_REQUESTED
Payload = RoR::ActorLinkingRequest* (owner)
Definition: Application.h:128
RoR::Message
Unified game event system - all requests and state changes are reported using a message.
Definition: GameContext.h:51
RoR::Actor::ar_initial_node_masses
std::vector< float > ar_initial_node_masses
Definition: Actor.h:310
RoR::ActorManager::m_net_timer
Ogre::Timer m_net_timer
Definition: ActorManager.h:142
_L
#define _L
Definition: ErrorUtils.cpp:34
PHYSICS_DT
#define PHYSICS_DT
Definition: SimConstants.h:20
RoR::Console::putNetMessage
void putNetMessage(int user_id, MessageType type, const char *text)
Definition: Console.cpp:102
RoR::ActorManager::~ActorManager
~ActorManager()
Definition: ActorManager.cpp:74
SOUND_PLAY_ONCE
#define SOUND_PLAY_ONCE(_ACTOR_, _TRIG_)
Definition: SoundScriptManager.h:34
RoR::Actor::dispose
void dispose()
Effectively destroys the object but keeps it in memory to satisfy shared pointers.
Definition: Actor.cpp:89
RoR::ActorSpawnRequest::asr_net_username
Ogre::UTFString asr_net_username
Definition: SimData.h:859
RoR::EngineSim::StartEngine
void StartEngine()
Quick engine start. Plays sounds.
Definition: EngineSim.cpp:998
RoR::ActorSpawnRequest::asr_debugview
int asr_debugview
Definition: SimData.h:858
RoR::Actor::m_net_username
Ogre::UTFString m_net_username
Definition: Actor.h:609
RoR::ActorManager::UpdateInputEvents
void UpdateInputEvents(float dt)
Definition: ActorManager.cpp:1343
RoR::Actor::m_working_tuneup_def
TuneupDefPtr m_working_tuneup_def
Each actor gets unique instance, even if loaded from .tuneup file in modcache.
Definition: Actor.h:590
RoR::GfxActor::UpdateWingMeshes
void UpdateWingMeshes()
Definition: GfxActor.cpp:3327
RoR::beam_t::minmaxposnegstress
float minmaxposnegstress
Definition: SimData.h:340
RoR::FreeForceType::TOWARDS_NODE
@ TOWARDS_NODE
Constant force directed towards ffc_target_node
RoR::MSG_SIM_SPAWN_ACTOR_REQUESTED
@ MSG_SIM_SPAWN_ACTOR_REQUESTED
Payload = RoR::ActorSpawnRequest* (owner)
Definition: Application.h:119
RoR::Actor::ar_num_wheels
int ar_num_wheels
Definition: Actor.h:324
RoRnet::StreamRegister::origin_streamid
int32_t origin_streamid
origin streamid
Definition: RoRnet.h:145
RoR::App::GetInputEngine
InputEngine * GetInputEngine()
Definition: Application.cpp:271
RoR::ActorManager::ModifyFreeForce
void ModifyFreeForce(FreeForceRequest *rq)
Definition: ActorManager.cpp:1621
RoR::EraseIf
void EraseIf(std::vector< T, A > &c, Predicate pred)
Definition: Utils.h:74
RoR::Actor::m_avg_node_position
Ogre::Vector3 m_avg_node_position
average node position
Definition: Actor.h:551
RoR::ActorPtr
RefCountingObjectPtr< Actor > ActorPtr
Definition: ForwardDeclarations.h:194
RoR::ActorLinkingRequest::alr_actor_instance_id
ActorInstanceID_t alr_actor_instance_id
Definition: SimData.h:919
RoR::MSG_SIM_DELETE_ACTOR_REQUESTED
@ MSG_SIM_DELETE_ACTOR_REQUESTED
Payload = RoR::ActorPtr* (owner)
Definition: Application.h:121
RoR::LT_AllBeam
@ LT_AllBeam
Definition: Application.h:303
ShouldIncludeActorInList
bool ShouldIncludeActorInList(const ActorPtr &actor)
Definition: ActorManager.cpp:946
RoR::ScriptCategory::ACTOR
@ ACTOR
Defined in truck file under 'scripts', contains global variable BeamClass@ thisActor.
RoR::EngineSim::GetAcceleration
float GetAcceleration()
Definition: EngineSim.cpp:880
RoR::ActorSpawnRequest::net_source_id
int net_source_id
Definition: SimData.h:861
RoR::ActorManager::UpdateTruckFeatures
void UpdateTruckFeatures(ActorPtr vehicle, float dt)
Definition: ActorManager.cpp:1433
RoR::ActorManager::ForwardCommands
void ForwardCommands(ActorPtr source_actor)
Fowards things to trailers.
Definition: ActorManager.cpp:649
Terrain.h
RoR::Actor::ar_net_stream_id
int ar_net_stream_id
Definition: Actor.h:429
RoR::Collisions::isInside
bool isInside(Ogre::Vector3 pos, const Ogre::String &inst, const Ogre::String &box, float border=0)
Definition: Collisions.cpp:1169
RoR::Actor::ar_submesh_ground_model
ground_model_t * ar_submesh_ground_model
Definition: Actor.h:413
RoR::EngineSim::OffStart
void OffStart()
Quick start of vehicle engine.
Definition: EngineSim.cpp:1016
RoR::ActorState::NETWORKED_HIDDEN
@ NETWORKED_HIDDEN
not simulated, not updated (remote)
RoR::ActorManager::FetchActorDef
RigDef::DocumentPtr FetchActorDef(RoR::ActorSpawnRequest &rq)
Definition: ActorManager.cpp:1253
InputEngine.h
Handles controller inputs from player. Defines input events and binding mechanism,...
Ogre
Definition: ExtinguishableFireAffector.cpp:35
RoR::Actor::m_wheel_node_count
int m_wheel_node_count
Static attr; filled at spawn.
Definition: Actor.h:574
RoR::ActorSpawner::SetupDefaultSoundSources
static void SetupDefaultSoundSources(ActorPtr const &actor)
Definition: ActorSpawner.cpp:6295
RoR::ActorManager::RepairActor
void RepairActor(Collisions *collisions, const Ogre::String &inst, const Ogre::String &box, bool keepPosition=false)
Definition: ActorManager.cpp:822
RigDef::DocumentPtr
std::shared_ptr< Document > DocumentPtr
Definition: RigDef_Prerequisites.h:38
RoR::Console::CONSOLE_SYSTEM_WARNING
@ CONSOLE_SYSTEM_WARNING
Definition: Console.h:53
RigDef::Validator::Validate
bool Validate()
Definition: RigDef_Validator.cpp:56
RoR::App::app_async_physics
CVar * app_async_physics
Definition: Application.cpp:83
RoR::CVar::getInt
int getInt() const
Definition: CVar.h:97
RoR::Console::CONSOLE_MSGTYPE_INFO
@ CONSOLE_MSGTYPE_INFO
Generic message.
Definition: Console.h:60
RoR::Actor::calculateAveragePosition
void calculateAveragePosition()
Definition: Actor.cpp:1130
RoR::ActorManager::m_forced_awake
bool m_forced_awake
disables sleep counters
Definition: ActorManager.h:146
RoR::FreeForceRequest::ffr_id
int64_t ffr_id
Definition: SimData.h:809
RoR::SS_TRIG_REPAIR
@ SS_TRIG_REPAIR
Definition: SoundScriptManager.h:67
RoR::ActorSpawnRequest::asr_position
Ogre::Vector3 asr_position
Definition: SimData.h:851
RoR::ActorSpawner::GetSubmeshGroundmodelName
std::string GetSubmeshGroundmodelName()
Definition: ActorSpawner.cpp:1320
RoR::ActorManager::WakeUpAllActors
void WakeUpAllActors()
Definition: ActorManager.cpp:779
RoR::Actor::ar_net_source_id
int ar_net_source_id
Unique ID of remote player who spawned this actor.
Definition: Actor.h:428
Collisions.h
RoR::node_t::mass
Ogre::Real mass
Definition: SimData.h:298
RoR::EV_COMMON_RESET_SIMULATION_PACE
@ EV_COMMON_RESET_SIMULATION_PACE
reset the simulation speed
Definition: InputEngine.h:225
RoR::ActorState::NETWORKED_OK
@ NETWORKED_OK
not simulated (remote) actor
RoR::ThreadPool::Parallelize
void Parallelize(const std::vector< std::function< void()>> &task_funcs)
Run collection of tasks in parallel and wait until all have finished.
Definition: ThreadPool.h:193
RoR::App::GetThreadPool
ThreadPool * GetThreadPool()
Definition: Application.cpp:274
RoR::ActorManager::UpdateActors
void UpdateActors(ActorPtr player_actor)
Definition: ActorManager.cpp:1026
RoR::EV_COMMON_DECELERATE_SIMULATION
@ EV_COMMON_DECELERATE_SIMULATION
decelerate the simulation speed
Definition: InputEngine.h:224
RoR::tryConvertUTF
Ogre::UTFString tryConvertUTF(const char *buffer)
Definition: Utils.cpp:58
RoR::NetRecvPacket
Definition: Network.h:94
RoR::ActorLinkingRequestType::TIE_TOGGLE
@ TIE_TOGGLE
RoR::Actor::ar_state
ActorState ar_state
Definition: Actor.h:446
RoR::GfxActor::UpdateFlexbodies
void UpdateFlexbodies()
Definition: GfxActor.cpp:3115
RoR::ActorManager::FetchNextVehicleOnList
const ActorPtr & FetchNextVehicleOnList(ActorPtr player, ActorPtr prev_player)
Definition: ActorManager.cpp:962
RoR::Actor::getLightStateMask
BitMask_t getLightStateMask() const
Definition: Actor.h:183
RoR::GfxActor::UpdateWheelVisuals
void UpdateWheelVisuals()
Definition: GfxActor.cpp:1909
RoR::EngineSim::NEUTRAL
@ NEUTRAL
Definition: EngineSim.h:132
RoR::AI
@ AI
machine controlled by an Artificial Intelligence
Definition: SimData.h:97
RoR::ActorSpawner::GetMemoryRequirements
ActorMemoryRequirements const & GetMemoryRequirements()
Definition: ActorSpawner.h:107
RoR::FreeForce::ffc_target_coords
Ogre::Vector3 ffc_target_coords
Definition: SimData.h:798
RoR::TyrePressure::IsEnabled
bool IsEnabled() const
Definition: TyrePressure.h:47
RoR::Network::AddPacket
void AddPacket(int streamid, int type, int len, const char *content)
Definition: Network.cpp:606
RoR::ActorModifyRequest::amr_type
Type amr_type
Definition: SimData.h:887
RoR::ActorSpawnRequest::asr_spawnbox
collision_box_t * asr_spawnbox
Definition: SimData.h:853
RoR::ActorSpawnRequest::asr_rotation
Ogre::Quaternion asr_rotation
Definition: SimData.h:852
RoR::FreeForceRequest::ffr_type
int64_t ffr_type
Definition: SimData.h:810
RoR::Actor::UpdateBoundingBoxes
void UpdateBoundingBoxes()
Definition: Actor.cpp:1165
RoR
Definition: AppContext.h:36
Network.h
RoR::ActorManager::GetActorById
const ActorPtr & GetActorById(ActorInstanceID_t actor_id)
Definition: ActorManager.cpp:1142
RoR::App::sim_spawn_running
CVar * sim_spawn_running
Definition: Application.cpp:100
RoR::ActorManager::m_free_forces
FreeForceVec_t m_free_forces
Global forces added ad-hoc by scripts.
Definition: ActorManager.h:154
RoR::beam_t::default_beam_deform
float default_beam_deform
for reset
Definition: SimData.h:361
RoR::ActorManager::CleanUpSimulation
void CleanUpSimulation()
Call this after simulation loop finishes.
Definition: ActorManager.cpp:868
RoR::App::GetGfxScene
GfxScene * GetGfxScene()
Definition: Application.cpp:276
RoR::GameContext::GetActorManager
ActorManager * GetActorManager()
Definition: GameContext.h:127
RoRnet::MSG2_USER_LEAVE
@ MSG2_USER_LEAVE
user leaves
Definition: RoRnet.h:58
RoR::ActorManager::CreateNewActor
ActorPtr CreateNewActor(ActorSpawnRequest rq, RigDef::DocumentPtr def)
Definition: ActorManager.cpp:79
RoR::FreeForceRequest::ffr_target_actor
int64_t ffr_target_actor
Definition: SimData.h:817
RoR::ActorManager::UpdatePhysicsSimulation
void UpdatePhysicsSimulation()
Definition: ActorManager.cpp:1154
RoR::App::sim_replay_enabled
CVar * sim_replay_enabled
Definition: Application.cpp:101
RoR::ActorManager::CheckNetRemoteStreamsOk
int CheckNetRemoteStreamsOk(int sourceid)
Definition: ActorManager.cpp:534
RoR::ActorModifyRequest::Type::RESET_ON_SPOT
@ RESET_ON_SPOT
RoR::App::mp_pseudo_collisions
CVar * mp_pseudo_collisions
Definition: Application.cpp:120
RoR::Actor::isBeingReset
bool isBeingReset() const
Definition: Actor.h:273
RoR::GameContext::GetTerrain
const TerrainPtr & GetTerrain()
Definition: GameContext.h:117
RoR::CacheEntry::fname
Ogre::String fname
filename
Definition: CacheSystem.h:67
RoR::Actor::calcNodeConnectivityGraph
void calcNodeConnectivityGraph()
Definition: Actor.cpp:871
RoRnet::StreamRegister
< Sent from the client to server and vice versa, to broadcast a new stream
Definition: RoRnet.h:140