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  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
110  {
111  // Calculate optimal node position compression (for network transfer)
112  Vector3 aabb_size = actor->ar_bounding_box.getSize();
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);
116  actor->m_net_node_compression = std::numeric_limits<short int>::max() / std::ceil(max_dimension * 1.5f);
117  }
118  // Apply spawn position & spawn rotation
119  for (int i = 0; i < actor->ar_num_nodes; i++)
120  {
121  actor->ar_nodes[i].AbsPosition = rq.asr_position + rq.asr_rotation * (actor->ar_nodes[i].AbsPosition - rq.asr_position);
122  actor->ar_nodes[i].RelPosition = actor->ar_nodes[i].AbsPosition - actor->ar_origin;
123  };
124 
125  /* Place correctly */
126  if (spawner.GetMemoryRequirements().num_fixes == 0)
127  {
128  Ogre::Vector3 vehicle_position = rq.asr_position;
129 
130  // check if over-sized
131  actor->UpdateBoundingBoxes();
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;
134 
135  float miny = 0.0f;
136 
137  if (!actor->m_preloaded_with_terrain)
138  {
139  miny = vehicle_position.y;
140  }
141 
142  if (rq.asr_spawnbox != nullptr)
143  {
144  miny = rq.asr_spawnbox->relo.y + rq.asr_spawnbox->center.y;
145  }
146 
147  if (rq.asr_free_position)
148  actor->resetPosition(vehicle_position, true);
149  else
150  actor->resetPosition(vehicle_position.x, vehicle_position.z, true, miny);
151 
152  if (rq.asr_spawnbox != nullptr)
153  {
154  bool inside = true;
155 
156  for (int i = 0; i < actor->ar_num_nodes; i++)
157  inside = (inside && App::GetGameContext()->GetTerrain()->GetCollisions()->isInside(actor->ar_nodes[i].AbsPosition, rq.asr_spawnbox, 0.2f));
158 
159  if (!inside)
160  {
161  Vector3 gpos = Vector3(vehicle_position.x, 0.0f, vehicle_position.z);
162 
163  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);
164 
165  actor->resetPosition(gpos.x, gpos.z, true, miny);
166  }
167  }
168  }
169  else
170  {
171  actor->resetPosition(rq.asr_position, true);
172  }
173  actor->UpdateBoundingBoxes();
174 
175  //compute final mass
176  actor->RecalculateNodeMasses(actor->m_dry_mass);
177  actor->ar_initial_total_mass = actor->m_total_mass;
178  for (int i = 0; i < actor->ar_num_nodes; i++)
179  {
180  actor->ar_initial_node_masses[i] = actor->ar_nodes[i].mass;
181  }
182 
183  //setup default sounds
184  if (!actor->m_disable_default_sounds)
185  {
187  }
188 
189  //compute node connectivity graph
190  actor->calcNodeConnectivityGraph();
191 
192  actor->UpdateBoundingBoxes();
193  actor->calculateAveragePosition();
194 
195  // calculate minimum camera radius
196  actor->calculateAveragePosition();
197  for (int i = 0; i < actor->ar_num_nodes; i++)
198  {
199  Real dist = actor->ar_nodes[i].AbsPosition.squaredDistance(actor->m_avg_node_position);
200  if (dist > actor->m_min_camera_radius)
201  {
202  actor->m_min_camera_radius = dist;
203  }
204  }
205  actor->m_min_camera_radius = std::sqrt(actor->m_min_camera_radius) * 1.2f; // twenty percent buffer
206 
207  // fix up submesh collision model
208  std::string subMeshGroundModelName = spawner.GetSubmeshGroundmodelName();
209  if (!subMeshGroundModelName.empty())
210  {
212  if (!actor->ar_submesh_ground_model)
213  {
215  }
216  }
217 
218  // Set beam defaults
219  for (int i = 0; i < actor->ar_num_beams; i++)
220  {
221  actor->ar_beams[i].initial_beam_strength = actor->ar_beams[i].strength;
223  actor->ar_initial_beam_defaults[i] = std::make_pair(actor->ar_beams[i].k, actor->ar_beams[i].d);
224  }
225 
226  actor->m_spawn_rotation = actor->getRotation();
227 
229 
230  actor->NotifyActorCameraChanged(); // setup sounds properly
231 
232  // calculate the number of wheel nodes
233  actor->m_wheel_node_count = 0;
234  for (int i = 0; i < actor->ar_num_nodes; i++)
235  {
236  if (actor->ar_nodes[i].nd_tyre_node)
237  actor->m_wheel_node_count++;
238  }
239 
240  // search m_net_first_wheel_node
241  actor->m_net_first_wheel_node = actor->ar_num_nodes;
242  for (int i = 0; i < actor->ar_num_nodes; i++)
243  {
244  if (actor->ar_nodes[i].nd_tyre_node || actor->ar_nodes[i].nd_rim_node)
245  {
246  actor->m_net_first_wheel_node = i;
247  break;
248  }
249  }
250 
251  // Initialize visuals
252  actor->updateVisual();
254 
255  // perform full visual update only if the vehicle won't be immediately driven by player.
256  if (actor->isPreloadedWithTerrain() || // .tobj file - Spawned sleeping somewhere on terrain
257  rq.asr_origin == ActorSpawnRequest::Origin::CONFIG_FILE || // RoR.cfg or commandline - not entered by default
258  actor->ar_num_cinecams == 0) // Not intended for player-controlling
259  {
260  actor->GetGfxActor()->UpdateSimDataBuffer(); // Initial fill of sim data buffers
261 
262  actor->GetGfxActor()->UpdateFlexbodies(); // Push tasks to threadpool
263  actor->GetGfxActor()->UpdateWheelVisuals(); // Push tasks to threadpool
264  actor->GetGfxActor()->UpdateCabMesh();
265  actor->GetGfxActor()->UpdateWingMeshes();
266  actor->GetGfxActor()->UpdateProps(0.f, false);
267  actor->GetGfxActor()->UpdateRods(); // beam visuals
268  actor->GetGfxActor()->FinishWheelUpdates(); // Sync tasks from threadpool
269  actor->GetGfxActor()->FinishFlexbodyTasks(); // Sync tasks from threadpool
270  }
271 
273 
274  if (actor->ar_engine)
275  {
277  actor->ar_engine->StartEngine();
278  else
279  actor->ar_engine->OffStart();
280  }
281  // pressurize tires
282  if (actor->getTyrePressure().IsEnabled())
283  {
284  actor->getTyrePressure().ModifyTyrePressure(0.f); // Initialize springiness of pressure-beams.
285  }
286 
288 
289  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
290  {
291  // network buffer layout (without RoRnet::VehicleState):
292  // -----------------------------------------------------
293 
294  // - 3 floats (x,y,z) for the reference node 0
295  // - ar_num_nodes - 1 times 3 short ints (compressed position info)
296  actor->m_net_node_buf_size = sizeof(float) * 3 + (actor->m_net_first_wheel_node - 1) * sizeof(short int) * 3;
298  // - ar_num_wheels times a float for the wheel rotation
299  actor->m_net_wheel_buf_size = actor->ar_num_wheels * sizeof(float);
301  // - bit array (made of ints) for the prop animation key states
303  (actor->m_prop_anim_key_states.size() / 8) + // whole chars
304  (size_t)(actor->m_prop_anim_key_states.size() % 8 != 0); // remainder: 0 or 1 chars
306 
308  {
310  if (actor->ar_engine)
311  {
312  actor->ar_engine->StartEngine();
313  }
314  }
315 
316  actor->m_net_username = rq.asr_net_username;
317  actor->m_net_color_num = rq.asr_net_color;
318  }
319  else if (App::sim_replay_enabled->getBool())
320  {
321  actor->m_replay_handler = new Replay(actor, App::sim_replay_length->getInt());
322  }
323 
324  // Launch scripts (FIXME: ignores sectionconfig)
325  for (RigDef::Script const& script_def : def->root_module->scripts)
326  {
328  }
329 
330  LOG(" ===== DONE LOADING VEHICLE");
331 
332  if (App::diag_actor_dump->getBool())
333  {
334  actor->WriteDiagnosticDump(actor->ar_filename + "_dump_recalc.txt"); // Saves file to 'logs'
335  }
336 
337  m_actors.push_back(ActorPtr(actor));
338 
339  return actor;
340 }
341 
343 {
344  m_stream_mismatches.erase(sourceid);
345 
346  for (ActorPtr& actor : m_actors)
347  {
348  if (actor->ar_state != ActorState::NETWORKED_OK)
349  continue;
350 
351  if (actor->ar_net_source_id == sourceid)
352  {
354  }
355  }
356 }
357 
358 #ifdef USE_SOCKETW
359 void ActorManager::HandleActorStreamData(std::vector<RoR::NetRecvPacket> packet_buffer)
360 {
361  // Sort by stream source
362  std::stable_sort(packet_buffer.begin(), packet_buffer.end(),
363  [](const RoR::NetRecvPacket& a, const RoR::NetRecvPacket& b)
364  { return a.header.source > b.header.source; });
365  // Compress data stream by eliminating all but the last update from every consecutive group of stream data updates
366  auto it = std::unique(packet_buffer.rbegin(), packet_buffer.rend(),
367  [](const RoR::NetRecvPacket& a, const RoR::NetRecvPacket& b)
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)
372  {
373  if (packet.header.command == RoRnet::MSG2_STREAM_REGISTER)
374  {
375  RoRnet::StreamRegister* reg = (RoRnet::StreamRegister *)packet.buffer;
376  if (reg->type == 0)
377  {
378  reg->name[127] = 0;
379  std::string filename = SanitizeUtf8CString(reg->name);
380 
381  RoRnet::UserInfo info;
382  if (!App::GetNetwork()->GetUserInfo(reg->origin_sourceid, info))
383  {
384  RoR::LogFormat("[RoR] Invalid STREAM_REGISTER, user id %d does not exist", reg->origin_sourceid);
385  reg->status = -1;
386  }
387  else if (filename.empty())
388  {
389  RoR::LogFormat("[RoR] Invalid STREAM_REGISTER (user '%s', ID %d), filename is empty string", info.username, reg->origin_sourceid);
390  reg->status = -1;
391  }
392  else
393  {
394  Str<200> text;
395  text << _L("spawned a new vehicle: ") << filename;
398 
399  LOG("[RoR] Creating remote actor for " + TOSTRING(reg->origin_sourceid) + ":" + TOSTRING(reg->origin_streamid));
400 
401  if (!App::GetCacheSystem()->CheckResourceLoaded(filename))
402  {
405  _L("Mod not installed: ") + filename);
406  RoR::LogFormat("[RoR] Cannot create remote actor (not installed), filename: '%s'", filename.c_str());
408  reg->status = -1;
409  }
410  else
411  {
412  auto actor_reg = reinterpret_cast<RoRnet::ActorStreamRegister*>(reg);
414  {
415  int offset = actor_reg->time - m_net_timer.getMilliseconds();
416  m_stream_time_offsets[reg->origin_sourceid] = offset - 100;
417  }
420  // TODO: Look up cache entry early (eliminate asr_filename) and fetch skin by name+guid! ~ 03/2019
421  rq->asr_filename = filename;
422  if (strnlen(actor_reg->skin, 60) < 60 && actor_reg->skin[0] != '\0')
423  {
424  rq->asr_skin_entry = App::GetCacheSystem()->FetchSkinByName(actor_reg->skin);
425  }
426  if (strnlen(actor_reg->sectionconfig, 60) < 60)
427  {
428  rq->asr_config = actor_reg->sectionconfig;
429  }
431  rq->asr_net_color = info.colournum;
432  rq->net_source_id = reg->origin_sourceid;
433  rq->net_stream_id = reg->origin_streamid;
434 
436  MSG_SIM_SPAWN_ACTOR_REQUESTED, (void*)rq));
437 
438  reg->status = 1;
439  }
440  }
441 
443  }
444  }
445  else if (packet.header.command == RoRnet::MSG2_STREAM_REGISTER_RESULT)
446  {
447  RoRnet::StreamRegister* reg = (RoRnet::StreamRegister *)packet.buffer;
448  for (ActorPtr& actor: m_actors)
449  {
450  if (actor->ar_net_source_id == reg->origin_sourceid && actor->ar_net_stream_id == reg->origin_streamid)
451  {
452  int sourceid = packet.header.source;
453  actor->ar_net_stream_results[sourceid] = reg->status;
454 
455  String message = "";
456  switch (reg->status)
457  {
458  case 1: message = "successfully loaded stream"; break;
459  case -2: message = "detected mismatch stream"; break;
460  default: message = "could not load stream"; break;
461  }
462  LOG("Client " + TOSTRING(sourceid) + " " + message + " " + TOSTRING(reg->origin_streamid) +
463  " with name '" + reg->name + "', result code: " + TOSTRING(reg->status));
464  break;
465  }
466  }
467  }
468  else if (packet.header.command == RoRnet::MSG2_STREAM_UNREGISTER)
469  {
470  ActorPtr b = this->GetActorByNetworkLinks(packet.header.source, packet.header.streamid);
471  if (b)
472  {
474  {
476  }
477  }
478  m_stream_mismatches[packet.header.source].erase(packet.header.streamid);
479  }
480  else if (packet.header.command == RoRnet::MSG2_USER_LEAVE)
481  {
482  this->RemoveStreamSource(packet.header.source);
483  }
484  else if (packet.header.command == RoRnet::MSG2_STREAM_DATA)
485  {
486  for (ActorPtr& actor: m_actors)
487  {
488  if (actor->ar_state != ActorState::NETWORKED_OK)
489  continue;
490  if (packet.header.source == actor->ar_net_source_id && packet.header.streamid == actor->ar_net_stream_id)
491  {
492  actor->pushNetwork(packet.buffer, packet.header.size);
493  break;
494  }
495  }
496  }
497  }
498 }
499 #endif // USE_SOCKETW
500 
502 {
503  auto search = m_stream_time_offsets.find(sourceid);
504  if (search != m_stream_time_offsets.end())
505  {
506  return search->second;
507  }
508  return 0;
509 }
510 
511 void ActorManager::UpdateNetTimeOffset(int sourceid, int offset)
512 {
513  if (m_stream_time_offsets.find(sourceid) != m_stream_time_offsets.end())
514  {
515  m_stream_time_offsets[sourceid] += offset;
516  }
517 }
518 
520 {
521  if (!m_stream_mismatches[sourceid].empty())
522  return 0;
523 
524  for (ActorPtr& actor: m_actors)
525  {
526  if (actor->ar_state != ActorState::NETWORKED_OK)
527  continue;
528 
529  if (actor->ar_net_source_id == sourceid)
530  {
531  return 1;
532  }
533  }
534 
535  return 2;
536 }
537 
539 {
540  int result = 2;
541 
542  for (ActorPtr& actor: m_actors)
543  {
544  if (actor->ar_state == ActorState::NETWORKED_OK)
545  continue;
546 
547  int stream_result = actor->ar_net_stream_results[sourceid];
548  if (stream_result == -1 || stream_result == -2)
549  return 0;
550  if (stream_result == 1)
551  result = 1;
552  }
553 
554  return result;
555 }
556 
557 const ActorPtr& ActorManager::GetActorByNetworkLinks(int source_id, int stream_id)
558 {
559  for (ActorPtr& actor: m_actors)
560  {
561  if (actor->ar_net_source_id == source_id && actor->ar_net_stream_id == stream_id)
562  {
563  return actor;
564  }
565  }
566 
567  return ACTORPTR_NULL;
568 }
569 
571 {
572  if (m_actors[a]->ar_collision_bounding_boxes.empty() && m_actors[b]->ar_collision_bounding_boxes.empty())
573  {
574  return m_actors[a]->ar_bounding_box.intersects(m_actors[b]->ar_bounding_box);
575  }
576  else if (m_actors[a]->ar_collision_bounding_boxes.empty())
577  {
578  for (const auto& bbox_b : m_actors[b]->ar_collision_bounding_boxes)
579  if (bbox_b.intersects(m_actors[a]->ar_bounding_box))
580  return true;
581  }
582  else if (m_actors[b]->ar_collision_bounding_boxes.empty())
583  {
584  for (const auto& bbox_a : m_actors[a]->ar_collision_bounding_boxes)
585  if (bbox_a.intersects(m_actors[b]->ar_bounding_box))
586  return true;
587  }
588  else
589  {
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))
593  return true;
594  }
595 
596  return false;
597 }
598 
600 {
601  if (m_actors[a]->ar_predicted_coll_bounding_boxes.empty() && m_actors[b]->ar_predicted_coll_bounding_boxes.empty())
602  {
603  return m_actors[a]->ar_predicted_bounding_box.intersects(m_actors[b]->ar_predicted_bounding_box);
604  }
605  else if (m_actors[a]->ar_predicted_coll_bounding_boxes.empty())
606  {
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))
609  return true;
610  }
611  else if (m_actors[b]->ar_predicted_coll_bounding_boxes.empty())
612  {
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))
615  return true;
616  }
617  else
618  {
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))
622  return true;
623  }
624 
625  return false;
626 }
627 
628 void ActorManager::RecursiveActivation(int j, std::vector<bool>& visited)
629 {
630  if (visited[j] || m_actors[j]->ar_state != ActorState::LOCAL_SIMULATED)
631  return;
632 
633  visited[j] = true;
634 
635  for (unsigned int t = 0; t < m_actors.size(); t++)
636  {
637  if (t == j || visited[t])
638  continue;
640  {
641  m_actors[t]->ar_sleep_counter = 0.0f;
642  this->RecursiveActivation(t, visited);
643  }
645  {
646  m_actors[t]->ar_sleep_counter = 0.0f;
647  m_actors[t]->ar_state = ActorState::LOCAL_SIMULATED;
648  this->RecursiveActivation(t, visited);
649  }
650  }
651 }
652 
654 {
655  if (source_actor->ar_forward_commands)
656  {
657  auto linked_actors = source_actor->ar_linked_actors;
658 
659  for (ActorPtr& actor : this->GetActors())
660  {
661  if (actor != source_actor && actor->ar_import_commands &&
662  (actor->getPosition().distance(source_actor->getPosition()) <
663  actor->m_min_camera_radius + source_actor->m_min_camera_radius))
664  {
665  // activate the truck
666  if (actor->ar_state == ActorState::LOCAL_SLEEPING)
667  {
668  actor->ar_sleep_counter = 0.0f;
669  actor->ar_state = ActorState::LOCAL_SIMULATED;
670  }
671 
672  if (App::sim_realistic_commands->getBool())
673  {
674  if (std::find(linked_actors.begin(), linked_actors.end(), actor) == linked_actors.end())
675  continue;
676  }
677 
678  // forward commands
679  for (int j = 1; j <= MAX_COMMANDS; j++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
680  {
681  actor->ar_command_key[j].playerInputValue = std::max(source_actor->ar_command_key[j].playerInputValue,
682  source_actor->ar_command_key[j].commandValue);
683  }
684  if (source_actor->ar_toggle_ties)
685  {
686  //actor->tieToggle();
689  rq->alr_actor_instance_id = actor->ar_instance_id;
690  rq->alr_tie_group = -1;
692 
693  }
694  if (source_actor->ar_toggle_ropes)
695  {
696  //actor->ropeToggle(-1);
699  rq->alr_actor_instance_id = actor->ar_instance_id;
700  rq->alr_rope_group = -1;
702  }
703  }
704  }
705  // just send brake and lights to the connected trucks, and no one else :)
706  for (auto hook : source_actor->ar_hooks)
707  {
708  if (!hook.hk_locked_actor || hook.hk_locked_actor == source_actor)
709  continue;
710 
711  // forward brakes
712  hook.hk_locked_actor->ar_brake = source_actor->ar_brake;
713  if (hook.hk_locked_actor->ar_parking_brake != source_actor->ar_trailer_parking_brake)
714  {
715  hook.hk_locked_actor->parkingbrakeToggle();
716  }
717 
718  // forward lights
719  hook.hk_locked_actor->setLightStateMask(source_actor->getLightStateMask());
720  }
721  }
722 }
723 
725 {
726  for (auto& entry: inter_actor_links)
727  {
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))
731  {
732  return true;
733  }
734  }
735  return false;
736 }
737 
738 void ActorManager::UpdateSleepingState(ActorPtr player_actor, float dt)
739 {
740  if (!m_forced_awake)
741  {
742  for (ActorPtr& actor: m_actors)
743  {
744  if (actor->ar_state != ActorState::LOCAL_SIMULATED)
745  continue;
746  if (actor->ar_driveable == AI)
747  continue;
748  if (actor->getVelocity().squaredLength() > 0.01f)
749  {
750  actor->ar_sleep_counter = 0.0f;
751  continue;
752  }
753 
754  actor->ar_sleep_counter += dt;
755 
756  if (actor->ar_sleep_counter >= 10.0f)
757  {
758  actor->ar_state = ActorState::LOCAL_SLEEPING;
759  }
760  }
761  }
762 
763  if (player_actor && player_actor->ar_state == ActorState::LOCAL_SLEEPING)
764  {
765  player_actor->ar_state = ActorState::LOCAL_SIMULATED;
766  }
767 
768  std::vector<bool> visited(m_actors.size());
769  // Recursivly activate all actors which can be reached from current actor
770  if (player_actor && player_actor->ar_state == ActorState::LOCAL_SIMULATED)
771  {
772  player_actor->ar_sleep_counter = 0.0f;
773  this->RecursiveActivation(player_actor->ar_vector_index, visited);
774  }
775  // Snowball effect (activate all actors which might soon get hit by a moving actor)
776  for (unsigned int t = 0; t < m_actors.size(); t++)
777  {
778  if (m_actors[t]->ar_state == ActorState::LOCAL_SIMULATED && m_actors[t]->ar_sleep_counter == 0.0f)
779  this->RecursiveActivation(t, visited);
780  }
781 }
782 
784 {
785  for (ActorPtr& actor: m_actors)
786  {
787  if (actor->ar_state == ActorState::LOCAL_SLEEPING)
788  {
789  actor->ar_state = ActorState::LOCAL_SIMULATED;
790  actor->ar_sleep_counter = 0.0f;
791  }
792  }
793 }
794 
796 {
797  m_forced_awake = false;
798  for (ActorPtr& actor: m_actors)
799  {
800  if (actor->ar_state == ActorState::LOCAL_SIMULATED)
801  {
802  actor->ar_state = ActorState::LOCAL_SLEEPING;
803  }
804  }
805 }
806 
807 ActorPtr ActorManager::FindActorInsideBox(Collisions* collisions, const Ogre::String& inst, const Ogre::String& box)
808 {
809  // try to find the desired actor (the one in the box)
810  ActorPtr ret = nullptr;
811  for (ActorPtr& actor: m_actors)
812  {
813  if (collisions->isInside(actor->ar_nodes[0].AbsPosition, inst, box))
814  {
815  if (ret == nullptr)
816  // first actor found
817  ret = actor;
818  else
819  // second actor found -> unclear which one was meant
820  return nullptr;
821  }
822  }
823  return ret;
824 }
825 
826 void ActorManager::RepairActor(Collisions* collisions, const Ogre::String& inst, const Ogre::String& box, bool keepPosition)
827 {
828  ActorPtr actor = this->FindActorInsideBox(collisions, inst, box);
829  if (actor != nullptr)
830  {
832 
834  rq->amr_actor = actor->ar_instance_id;
837  }
838 }
839 
841 {
842  for (ActorPtr& actor: m_actors)
843  {
844  actor->muteAllSounds();
845  }
846 }
847 
849 {
850  for (ActorPtr& actor: m_actors)
851  {
852  actor->unmuteAllSounds();
853  }
854 }
855 
856 std::pair<ActorPtr, float> ActorManager::GetNearestActor(Vector3 position)
857 {
858  ActorPtr nearest_actor = nullptr;
859  float min_squared_distance = std::numeric_limits<float>::max();
860  for (ActorPtr& actor : m_actors)
861  {
862  float squared_distance = position.squaredDistance(actor->ar_nodes[0].AbsPosition);
863  if (squared_distance < min_squared_distance)
864  {
865  min_squared_distance = squared_distance;
866  nearest_actor = actor;
867  }
868  }
869  return std::make_pair(nearest_actor, std::sqrt(min_squared_distance));
870 }
871 
872 void ActorManager::CleanUpSimulation() // Called after simulation finishes
873 {
874  while (m_actors.size() > 0)
875  {
876  this->DeleteActorInternal(m_actors.back());
877  }
878 
879  m_total_sim_time = 0.f;
881  m_simulation_paused = false;
882  m_simulation_speed = 1.f;
883 }
884 
886 {
887  if (actor == nullptr || actor->ar_state == ActorState::DISPOSED)
888  return;
889 
890  this->SyncWithSimThread();
891 
892 #ifdef USE_SOCKETW
893  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
894  {
895  if (actor->ar_state != ActorState::NETWORKED_OK)
896  {
898  }
899  else if (std::count_if(m_actors.begin(), m_actors.end(), [actor](ActorPtr& b)
900  { return b->ar_net_source_id == actor->ar_net_source_id; }) == 1)
901  {
902  // We're deleting the last actor from this stream source, reset the stream time offset
904  }
905  }
906 #endif // USE_SOCKETW
907 
908  // Unload actor's scripts
909  std::vector<ScriptUnitId_t> unload_list;
910  for (auto& pair : App::GetScriptEngine()->getScriptUnits())
911  {
912  if (pair.second.associatedActor == actor)
913  unload_list.push_back(pair.first);
914  }
915  for (ScriptUnitId_t id : unload_list)
916  {
918  }
919 
920  // Remove FreeForces referencing this actor
921  m_free_forces.erase(
922  std::remove_if(
923  m_free_forces.begin(),
924  m_free_forces.end(),
925  [actor](FreeForce& item) { return item.ffc_base_actor == actor || item.ffc_target_actor == actor; }),
926  m_free_forces.end());
927 
928  // Only dispose(), do not `delete`; a script may still hold pointer to the object.
929  actor->dispose();
930 
931  EraseIf(m_actors, [actor](ActorPtr& curActor) { return actor == curActor; });
932 
933  // Upate actor indices
934  for (unsigned int i = 0; i < m_actors.size(); i++)
935  m_actors[i]->ar_vector_index = i;
936 }
937 
938 // ACTORLIST for cycling with hotkeys
939 // ----------------------------------
940 
941 int FindPivotActorId(ActorPtr player, ActorPtr prev_player)
942 {
943  if (player != nullptr)
944  return player->ar_vector_index;
945  else if (prev_player != nullptr)
946  return prev_player->ar_vector_index + 1;
947  return -1;
948 }
949 
951 {
952  bool retval = !actor->isPreloadedWithTerrain();
953 
954  // Exclude remote actors, if desired
955  if (!App::mp_cyclethru_net_actors->getBool())
956  {
958  {
959  retval = false;
960  }
961  }
962 
963  return retval;
964 }
965 
967 {
968  int pivot_index = FindPivotActorId(player, prev_player);
969 
970  for (int i = pivot_index + 1; i < m_actors.size(); i++)
971  {
973  return m_actors[i];
974  }
975 
976  for (int i = 0; i < pivot_index; i++)
977  {
979  return m_actors[i];
980  }
981 
982  if (pivot_index >= 0)
983  {
984  if (ShouldIncludeActorInList(m_actors[pivot_index]))
985  return m_actors[pivot_index];
986  }
987 
988  return ACTORPTR_NULL;
989 }
990 
992 {
993  int pivot_index = FindPivotActorId(player, prev_player);
994 
995  for (int i = pivot_index - 1; i >= 0; i--)
996  {
998  return m_actors[i];
999  }
1000 
1001  for (int i = static_cast<int>(m_actors.size()) - 1; i > pivot_index; i--)
1002  {
1004  return m_actors[i];
1005  }
1006 
1007  if (pivot_index >= 0)
1008  {
1009  if (ShouldIncludeActorInList(m_actors[pivot_index]))
1010  return m_actors[pivot_index];
1011  }
1012 
1013  return ACTORPTR_NULL;
1014 }
1015 
1016 // END actorlist
1017 
1019 {
1020  for (ActorPtr& actor: m_actors)
1021  {
1022  if (actor->ar_rescuer_flag)
1023  {
1024  return actor;
1025  }
1026  }
1027  return ACTORPTR_NULL;
1028 }
1029 
1031 {
1032  float dt = m_simulation_time;
1033 
1034  // do not allow dt > 1/20
1035  dt = std::min(dt, 1.0f / 20.0f);
1036 
1037  dt *= m_simulation_speed;
1038 
1039  dt += m_dt_remainder;
1040  m_physics_steps = dt / PHYSICS_DT;
1041  if (m_physics_steps == 0)
1042  {
1043  return;
1044  }
1045 
1047  dt = PHYSICS_DT * m_physics_steps;
1048 
1049  this->SyncWithSimThread();
1050 
1051  this->UpdateSleepingState(player_actor, dt);
1052 
1053  for (ActorPtr& actor: m_actors)
1054  {
1055  actor->HandleInputEvents(dt);
1056  actor->HandleAngelScriptEvents(dt);
1057 
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
1062 
1063  if (actor->ar_engine)
1064  {
1065  if (actor->ar_driveable == TRUCK)
1066  {
1067  this->UpdateTruckFeatures(actor, dt);
1068  }
1069  if (actor->ar_state == ActorState::LOCAL_SLEEPING)
1070  {
1071  actor->ar_engine->UpdateEngineSim(dt, 1);
1072  }
1073  actor->ar_engine->UpdateEngineAudio();
1074  }
1075 
1076  // Always update indicator states - used by 'u' type flares.
1077  actor->updateDashBoards(dt);
1078 
1079  // Blinkers (turn signals) must always be updated
1080  actor->updateFlareStates(dt);
1081 
1082  if (actor->ar_state != ActorState::LOCAL_SLEEPING)
1083  {
1084  actor->updateVisual(dt);
1085  if (actor->ar_update_physics && App::gfx_skidmarks_mode->getInt() > 0)
1086  {
1087  actor->updateSkidmarks();
1088  }
1089  }
1090  if (App::mp_state->getEnum<MpState>() == RoR::MpState::CONNECTED)
1091  {
1092  // FIXME: Hidden actors must also be updated to workaround a glitch, see https://github.com/RigsOfRods/rigs-of-rods/issues/2911
1093  if (actor->ar_state == ActorState::NETWORKED_OK || actor->ar_state == ActorState::NETWORKED_HIDDEN)
1094  actor->calcNetwork();
1095  else
1096  actor->sendStreamData();
1097  }
1098  }
1099 
1100  if (player_actor != nullptr)
1101  {
1102  this->ForwardCommands(player_actor);
1103  if (player_actor->ar_toggle_ties)
1104  {
1105  //player_actor->tieToggle();
1108  rq->alr_actor_instance_id = player_actor->ar_instance_id;
1109  rq->alr_tie_group = -1;
1111 
1112  player_actor->ar_toggle_ties = false;
1113  }
1114  if (player_actor->ar_toggle_ropes)
1115  {
1116  //player_actor->ropeToggle(-1);
1119  rq->alr_actor_instance_id = player_actor->ar_instance_id;
1120  rq->alr_rope_group = -1;
1122 
1123  player_actor->ar_toggle_ropes = false;
1124  }
1125 
1126  player_actor->ForceFeedbackStep(m_physics_steps);
1127 
1128  if (player_actor->ar_state == ActorState::LOCAL_REPLAY)
1129  {
1130  player_actor->getReplay()->replayStepActor();
1131  }
1132  }
1133 
1134  auto func = std::function<void()>([this]()
1135  {
1136  this->UpdatePhysicsSimulation();
1137  });
1138  m_sim_task = m_sim_thread_pool->RunTask(func);
1139 
1140  m_total_sim_time += dt;
1141 
1142  if (!App::app_async_physics->getBool())
1143  m_sim_task->join();
1144 }
1145 
1147 {
1148  for (ActorPtr& actor: m_actors)
1149  {
1150  if (actor->ar_instance_id == actor_id)
1151  {
1152  return actor;
1153  }
1154  }
1155  return ACTORPTR_NULL;
1156 }
1157 
1159 {
1160  for (ActorPtr& actor: m_actors)
1161  {
1162  actor->UpdatePhysicsOrigin();
1163  }
1164  for (int i = 0; i < m_physics_steps; i++)
1165  {
1166  {
1167  std::vector<std::function<void()>> tasks;
1168  for (ActorPtr& actor: m_actors)
1169  {
1170  if (actor->ar_update_physics = actor->CalcForcesEulerPrepare(i == 0))
1171  {
1172  auto func = std::function<void()>([this, i, &actor]()
1173  {
1174  actor->CalcForcesEulerCompute(i == 0, m_physics_steps);
1175  });
1176  tasks.push_back(func);
1177  }
1178  }
1179  App::GetThreadPool()->Parallelize(tasks);
1180  for (ActorPtr& actor: m_actors)
1181  {
1182  if (actor->ar_update_physics)
1183  {
1184  actor->CalcBeamsInterActor();
1185  }
1186  }
1187  }
1188  {
1189  std::vector<std::function<void()>> tasks;
1190  for (ActorPtr& actor: m_actors)
1191  {
1192  if (actor->m_inter_point_col_detector != nullptr && (actor->ar_update_physics ||
1193  (App::mp_pseudo_collisions->getBool() && actor->ar_state == ActorState::NETWORKED_OK)))
1194  {
1195  auto func = std::function<void()>([this, &actor]()
1196  {
1197  actor->m_inter_point_col_detector->UpdateInterPoint();
1198  if (actor->ar_collision_relevant)
1199  {
1200  ResolveInterActorCollisions(PHYSICS_DT,
1201  *actor->m_inter_point_col_detector,
1202  actor->ar_num_collcabs,
1203  actor->ar_collcabs,
1204  actor->ar_cabs,
1205  actor->ar_inter_collcabrate,
1206  actor->ar_nodes,
1207  actor->ar_collision_range,
1208  *actor->ar_submesh_ground_model);
1209  }
1210  });
1211  tasks.push_back(func);
1212  }
1213  }
1214  App::GetThreadPool()->Parallelize(tasks);
1215  }
1216 
1217  // Apply FreeForces - intentionally as a separate pass over all actors
1218  this->CalcFreeForces();
1219  }
1220  for (ActorPtr& actor: m_actors)
1221  {
1222  actor->m_ongoing_reset = false;
1223  if (actor->ar_update_physics && m_physics_steps > 0)
1224  {
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;
1231  actor->m_avg_node_velocity /= (m_physics_steps * PHYSICS_DT);
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());
1234  }
1235  }
1236 }
1237 
1239 {
1240  if (m_sim_task)
1241  m_sim_task->join();
1242 }
1243 
1244 void HandleErrorLoadingFile(std::string type, std::string filename, std::string exception_msg)
1245 {
1246  RoR::Str<200> msg;
1247  msg << "Failed to load '" << filename << "' (type: '" << type << "'), message: " << exception_msg;
1250 }
1251 
1252 void HandleErrorLoadingTruckfile(std::string filename, std::string exception_msg)
1253 {
1254  HandleErrorLoadingFile("actor", filename, exception_msg);
1255 }
1256 
1257 RigDef::DocumentPtr ActorManager::FetchActorDef(std::string filename, bool predefined_on_terrain)
1258 {
1259  // Find the user content
1260  CacheEntryPtr cache_entry = App::GetCacheSystem()->FindEntryByFilename(LT_AllBeam, /*partial=*/false, filename);
1261  if (cache_entry == nullptr)
1262  {
1263  HandleErrorLoadingTruckfile(filename, "Truckfile not found in ModCache (probably not installed)");
1264  return nullptr;
1265  }
1266 
1267  // If already parsed, re-use
1268  if (cache_entry->actor_def != nullptr)
1269  {
1270  return cache_entry->actor_def;
1271  }
1272 
1273  // Load the 'truckfile'
1274  try
1275  {
1276  Ogre::String resource_filename = filename;
1277  Ogre::String resource_groupname;
1278  if (!App::GetCacheSystem()->CheckResourceLoaded(resource_filename, resource_groupname)) // Validates the filename and finds resource group
1279  {
1280  HandleErrorLoadingTruckfile(filename, "Truckfile not found");
1281  return nullptr;
1282  }
1283  Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(resource_filename, resource_groupname);
1284 
1285  if (stream.isNull() || !stream->isReadable())
1286  {
1287  HandleErrorLoadingTruckfile(filename, "Unable to open/read truckfile");
1288  return nullptr;
1289  }
1290 
1291  RoR::LogFormat("[RoR] Parsing truckfile '%s'", resource_filename.c_str());
1292  RigDef::Parser parser;
1293  parser.Prepare();
1294  parser.ProcessOgreStream(stream.getPointer(), resource_groupname);
1295  parser.Finalize();
1296 
1297  auto def = parser.GetFile();
1298 
1299  // VALIDATING
1300  LOG(" == Validating vehicle: " + def->name);
1301 
1302  RigDef::Validator validator;
1303  validator.Setup(def);
1304 
1305  if (predefined_on_terrain)
1306  {
1307  // Workaround: Some terrains pre-load truckfiles with special purpose:
1308  // "soundloads" = play sound effect at certain spot
1309  // "fixes" = structures of N/B fixed to the ground
1310  // These files can have no beams. Possible extensions: .load or .fixed
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"))
1314  {
1315  validator.SetCheckBeams(false);
1316  }
1317  }
1318 
1319  validator.Validate(); // Sends messages to console
1320 
1321  def->hash = Sha1Hash(stream->getAsString());
1322 
1323  cache_entry->actor_def = def;
1324  return def;
1325  }
1326  catch (Ogre::Exception& oex)
1327  {
1328  HandleErrorLoadingTruckfile(filename, oex.getFullDescription().c_str());
1329  return nullptr;
1330  }
1331  catch (std::exception& stex)
1332  {
1333  HandleErrorLoadingTruckfile(filename, stex.what());
1334  return nullptr;
1335  }
1336  catch (...)
1337  {
1338  HandleErrorLoadingTruckfile(filename, "<Unknown exception occurred>");
1339  return nullptr;
1340  }
1341 }
1342 
1343 std::vector<ActorPtr> ActorManager::GetLocalActors()
1344 {
1345  std::vector<ActorPtr> actors;
1346  for (ActorPtr& actor: m_actors)
1347  {
1348  if (actor->ar_state != ActorState::NETWORKED_OK)
1349  actors.push_back(actor);
1350  }
1351  return actors;
1352 }
1353 
1355 {
1356  // Simulation pace adjustment (slowmotion)
1357  if (!App::GetGameContext()->GetRaceSystem().IsRaceInProgress())
1358  {
1359  // EV_COMMON_ACCELERATE_SIMULATION
1360  if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_ACCELERATE_SIMULATION))
1361  {
1362  float simulation_speed = this->GetSimulationSpeed() * pow(2.0f, dt / 2.0f);
1363  this->SetSimulationSpeed(simulation_speed);
1364  String ssmsg = _L("New simulation speed: ") + TOSTRING(Round(simulation_speed * 100.0f, 1)) + "%";
1366  }
1367 
1368  // EV_COMMON_DECELERATE_SIMULATION
1369  if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_DECELERATE_SIMULATION))
1370  {
1371  float simulation_speed = this->GetSimulationSpeed() * pow(0.5f, dt / 2.0f);
1372  this->SetSimulationSpeed(simulation_speed);
1373  String ssmsg = _L("New simulation speed: ") + TOSTRING(Round(simulation_speed * 100.0f, 1)) + "%";
1375  }
1376 
1377  // EV_COMMON_RESET_SIMULATION_PACE
1378  if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_RESET_SIMULATION_PACE))
1379  {
1380  float simulation_speed = this->GetSimulationSpeed();
1381  if (simulation_speed != 1.0f)
1382  {
1383  m_last_simulation_speed = simulation_speed;
1384  this->SetSimulationSpeed(1.0f);
1385  UTFString ssmsg = _L("Simulation speed reset.");
1387  }
1388  else if (m_last_simulation_speed != 1.0f)
1389  {
1391  String ssmsg = _L("New simulation speed: ") + TOSTRING(Round(m_last_simulation_speed * 100.0f, 1)) + "%";
1393  }
1394  }
1395 
1396  // Special adjustment while racing
1397  if (App::GetGameContext()->GetRaceSystem().IsRaceInProgress() && this->GetSimulationSpeed() != 1.0f)
1398  {
1400  this->SetSimulationSpeed(1.f);
1401  }
1402  }
1403 
1404  // EV_COMMON_TOGGLE_PHYSICS - Freeze/unfreeze physics
1405  if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_PHYSICS))
1406  {
1408 
1409  if (m_simulation_paused)
1410  {
1411  String ssmsg = _L("Physics paused");
1413  }
1414  else
1415  {
1416  String ssmsg = _L("Physics unpaused");
1418  }
1419  }
1420 
1421  // Calculate simulation time
1422  if (m_simulation_paused)
1423  {
1424  m_simulation_time = 0.f;
1425 
1426  // Frozen physics stepping
1427  if (this->GetSimulationSpeed() > 0.0f)
1428  {
1429  // EV_COMMON_REPLAY_FAST_FORWARD - Advance simulation while pressed
1430  // EV_COMMON_REPLAY_FORWARD - Advanced simulation one step
1431  if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_REPLAY_FAST_FORWARD) ||
1432  App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_REPLAY_FORWARD))
1433  {
1435  }
1436  }
1437  }
1438  else
1439  {
1440  m_simulation_time = dt;
1441  }
1442 }
1443 
1445 {
1446  if (vehicle->isBeingReset() || vehicle->ar_physics_paused)
1447  return;
1448 #ifdef USE_ANGELSCRIPT
1449  if (vehicle->ar_vehicle_ai && vehicle->ar_vehicle_ai->isActive())
1450  return;
1451 #endif // USE_ANGELSCRIPT
1452 
1453  EngineSim* engine = vehicle->ar_engine;
1454 
1455  if (engine && engine->hasContact() &&
1456  engine->GetAutoShiftMode() == SimGearboxMode::AUTO &&
1457  engine->getAutoShift() != EngineSim::NEUTRAL)
1458  {
1459  Ogre::Vector3 dirDiff = vehicle->getDirection();
1460  Ogre::Degree pitchAngle = Ogre::Radian(asin(dirDiff.dotProduct(Ogre::Vector3::UNIT_Y)));
1461 
1462  if (std::abs(pitchAngle.valueDegrees()) > 2.0f)
1463  {
1464  if (engine->getAutoShift() > EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed < +0.02f && pitchAngle.valueDegrees() > 0.0f ||
1465  engine->getAutoShift() < EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed > -0.02f && pitchAngle.valueDegrees() < 0.0f)
1466  {
1467  // anti roll back in SimGearboxMode::AUTO (DRIVE, TWO, ONE) mode
1468  // anti roll forth in SimGearboxMode::AUTO (REAR) mode
1469  float g = std::abs(App::GetGameContext()->GetTerrain()->getGravity());
1470  float downhill_force = std::abs(sin(pitchAngle.valueRadians()) * vehicle->getTotalMass()) * g;
1471  float engine_force = std::abs(engine->GetTorque()) / vehicle->getAvgPropedWheelRadius();
1472  float ratio = std::max(0.0f, 1.0f - (engine_force / downhill_force));
1473  if (vehicle->ar_avg_wheel_speed * pitchAngle.valueDegrees() > 0.0f)
1474  {
1475  ratio *= sqrt((0.02f - vehicle->ar_avg_wheel_speed) / 0.02f);
1476  }
1477  vehicle->ar_brake = sqrt(ratio);
1478  }
1479  }
1480  else if (vehicle->ar_brake == 0.0f && !vehicle->ar_parking_brake && engine->GetTorque() == 0.0f)
1481  {
1482  float ratio = std::max(0.0f, 0.2f - std::abs(vehicle->ar_avg_wheel_speed)) / 0.2f;
1483  vehicle->ar_brake = ratio;
1484  }
1485  }
1486 
1487  if (vehicle->cc_mode)
1488  {
1489  vehicle->UpdateCruiseControl(dt);
1490  }
1491  if (vehicle->sl_enabled)
1492  {
1493  // check speed limit
1494  if (engine && engine->GetGear() != 0)
1495  {
1496  float accl = (vehicle->sl_speed_limit - std::abs(vehicle->ar_wheel_speed / 1.02f)) * 2.0f;
1497  engine->SetAcceleration(Ogre::Math::Clamp(accl, 0.0f, engine->GetAcceleration()));
1498  }
1499  }
1500 
1501  BITMASK_SET(vehicle->m_lightmask, RoRnet::LIGHTMASK_BRAKES, (vehicle->ar_brake > 0.01f && !vehicle->ar_parking_brake));
1502  BITMASK_SET(vehicle->m_lightmask, RoRnet::LIGHTMASK_REVERSE, (vehicle->ar_engine && vehicle->ar_engine->GetGear() < 0));
1503 }
1504 
1506 {
1507  for (FreeForce& freeforce: m_free_forces)
1508  {
1509  // Sanity checks
1510  ROR_ASSERT(freeforce.ffc_base_actor != nullptr);
1511  ROR_ASSERT(freeforce.ffc_base_actor->ar_state != ActorState::DISPOSED);
1512  ROR_ASSERT(freeforce.ffc_base_node != NODENUM_INVALID);
1513  ROR_ASSERT(freeforce.ffc_base_node <= freeforce.ffc_base_actor->ar_num_nodes);
1514 
1515 
1516  switch (freeforce.ffc_type)
1517  {
1519  freeforce.ffc_base_actor->ar_nodes[freeforce.ffc_base_node].Forces += freeforce.ffc_force_magnitude * freeforce.ffc_force_const_direction;
1520  break;
1521 
1523  {
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;
1526  }
1527  break;
1528 
1530  {
1531  // Sanity checks
1532  ROR_ASSERT(freeforce.ffc_target_actor != nullptr);
1533  ROR_ASSERT(freeforce.ffc_target_actor->ar_state != ActorState::DISPOSED);
1534  ROR_ASSERT(freeforce.ffc_target_node != NODENUM_INVALID);
1535  ROR_ASSERT(freeforce.ffc_target_node <= freeforce.ffc_target_actor->ar_num_nodes);
1536 
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;
1539  }
1540  break;
1541 
1542  default:
1543  break;
1544  }
1545  }
1546 }
1547 
1548 static bool ProcessFreeForce(FreeForceRequest* rq, FreeForce& freeforce)
1549 {
1550  // internal helper for processing add/modify requests, with checks
1551  // ---------------------------------------------------------------
1552 
1553  // Unchecked stuff
1554  freeforce.ffc_id = (FreeForceID_t)rq->ffr_id;
1555  freeforce.ffc_type = (FreeForceType)rq->ffr_type;
1556  freeforce.ffc_force_magnitude = (float)rq->ffr_force_magnitude;
1558  freeforce.ffc_target_coords = rq->ffr_target_coords;
1559 
1560  // Base actor
1562  ROR_ASSERT(freeforce.ffc_base_actor != nullptr && freeforce.ffc_base_actor->ar_state != ActorState::DISPOSED);
1563  if (!freeforce.ffc_base_actor || freeforce.ffc_base_actor->ar_state == ActorState::DISPOSED)
1564  {
1566  fmt::format("Cannot add free force with ID {} to actor {}: Base actor not found or disposed", freeforce.ffc_id, rq->ffr_base_actor));
1567  return false;
1568  }
1569 
1570  // Base node
1571  ROR_ASSERT(rq->ffr_base_node >= 0);
1574  if (rq->ffr_base_node < 0 || rq->ffr_base_node >= NODENUM_MAX || rq->ffr_base_node >= freeforce.ffc_base_actor->ar_num_nodes)
1575  {
1577  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));
1578  return false;
1579  }
1580  freeforce.ffc_base_node = (NodeNum_t)rq->ffr_base_node;
1581 
1582  if (freeforce.ffc_type == FreeForceType::TOWARDS_NODE)
1583  {
1584  // Target actor
1586  ROR_ASSERT(freeforce.ffc_target_actor != nullptr && freeforce.ffc_target_actor->ar_state != ActorState::DISPOSED);
1587  if (!freeforce.ffc_target_actor || freeforce.ffc_target_actor->ar_state == ActorState::DISPOSED)
1588  {
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));
1591  return false;
1592  }
1593 
1594  // Target node
1595  ROR_ASSERT(rq->ffr_target_node >= 0);
1598  if (rq->ffr_target_node < 0 || rq->ffr_target_node >= NODENUM_MAX || rq->ffr_target_node >= freeforce.ffc_target_actor->ar_num_nodes)
1599  {
1601  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));
1602  return false;
1603  }
1604  freeforce.ffc_target_node = (NodeNum_t)rq->ffr_target_node;
1605  }
1606 
1607  return true;
1608 }
1609 
1610 ActorManager::FreeForceVec_t::iterator ActorManager::FindFreeForce(FreeForceID_t id)
1611 {
1612  return std::find_if(m_free_forces.begin(), m_free_forces.end(), [id](FreeForce& item) { return id == item.ffc_id; });
1613 }
1614 
1616 {
1617  // Make sure ID is unique
1618  if (this->FindFreeForce(rq->ffr_id) != m_free_forces.end())
1619  {
1621  fmt::format("Cannot add free force with ID {}: ID already in use", rq->ffr_id));
1622  return;
1623  }
1624 
1625  FreeForce freeforce;
1626  if (ProcessFreeForce(rq, freeforce))
1627  {
1628  m_free_forces.push_back(freeforce);
1629  }
1630 }
1631 
1633 {
1634  auto it = this->FindFreeForce(rq->ffr_id);
1635  if (it == m_free_forces.end())
1636  {
1638  fmt::format("Cannot modify free force with ID {}: ID not found", rq->ffr_id));
1639  return;
1640  }
1641 
1642  FreeForce& freeforce = *it;
1643  if (ProcessFreeForce(rq, freeforce))
1644  {
1645  *it = freeforce;
1646  }
1647 }
1648 
1650 {
1651  auto it = this->FindFreeForce(id);
1652  if (it == m_free_forces.end())
1653  {
1655  fmt::format("Cannot remove free force with ID {}: ID not found", id));
1656  return;
1657  }
1658 
1659  m_free_forces.erase(it);
1660 }
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:1318
RoR::Actor::cc_mode
bool cc_mode
Cruise Control.
Definition: Actor.h:364
RoR::App::GetNetwork
Network * GetNetwork()
Definition: Application.cpp:284
RoRnet::ActorStreamRegister
Definition: RoRnet.h:150
RoR::ActorManager::GetSimulationSpeed
float GetSimulationSpeed() const
Definition: ActorManager.h:93
RoR::ActorManager::CheckNetworkStreamsOk
int CheckNetworkStreamsOk(int sourceid)
Definition: ActorManager.cpp:519
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:158
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:501
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:168
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::CacheSystem::FindEntryByFilename
CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string &filename)
Returns NULL if none found.
Definition: CacheSystem.cpp:184
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:1252
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:1615
HandleErrorLoadingFile
void HandleErrorLoadingFile(std::string type, std::string filename, std::string exception_msg)
Definition: ActorManager.cpp:1244
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:1946
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:342
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:807
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:570
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
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::ActorManager::FetchActorDef
RigDef::DocumentPtr FetchActorDef(std::string filename, bool predefined_on_terrain=false)
Definition: ActorManager.cpp:1257
RoR::Actor::ar_hooks
std::vector< hook_t > ar_hooks
Definition: Actor.h:302
RoR::Actor::m_net_node_compression
float m_net_node_compression
For incoming/outgoing traffic; calculated on spawn.
Definition: Actor.h:606
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::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:557
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:991
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:856
RigDef::Validator::Setup
void Setup(RigDef::DocumentPtr file)
Prepares the validation.
Definition: RigDef_Validator.cpp:85
RoR::ActorManager::SyncWithSimThread
void SyncWithSimThread()
Definition: ActorManager.cpp:1238
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:724
RoR::ActorSpawnRequest::asr_filename
std::string asr_filename
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:795
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:4561
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:1505
RoR::ActorManager::UpdateSleepingState
void UpdateSleepingState(ActorPtr player_actor, float dt)
Definition: ActorManager.cpp:738
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:599
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::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:1649
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:1610
RigDef_Validator.h
.truck format validator
RoR::ActorManager::UnmuteAllActors
void UnmuteAllActors()
Definition: ActorManager.cpp:848
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:359
RoRnet::MSG2_STREAM_REGISTER
@ MSG2_STREAM_REGISTER
create new stream
Definition: RoRnet.h:63
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:1343
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:3210
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:423
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:3839
RoR::Actor::ForceFeedbackStep
void ForceFeedbackStep(int steps)
Definition: Actor.cpp:1787
RoR::Actor::WriteDiagnosticDump
void WriteDiagnosticDump(std::string const &filename)
Definition: Actor.cpp:4624
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:941
RoR::ActorManager::UpdateNetTimeOffset
void UpdateNetTimeOffset(int sourceid, int offset)
Definition: ActorManager.cpp:511
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:1018
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:418
RoR::ActorSpawnRequest::net_stream_id
int net_stream_id
Definition: SimData.h:862
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:810
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:718
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:628
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
stream type
Definition: RoRnet.h:142
RoR::ActorManager::DeleteActorInternal
void DeleteActorInternal(ActorPtr actor)
Do not call directly; use GameContext::DeleteActor()
Definition: ActorManager.cpp:885
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:1559
ProcessFreeForce
static bool ProcessFreeForce(FreeForceRequest *rq, FreeForce &freeforce)
Definition: ActorManager.cpp:1548
RoR::ActorManager::MuteAllActors
void MuteAllActors()
Definition: ActorManager.cpp:840
RoRnet::UserInfo::colournum
int32_t colournum
colour set by server
Definition: RoRnet.h:173
RigDef::Script::filename
std::string filename
Definition: RigDef_File.h:1172
RoRnet::StreamRegister::name
char name[128]
the actor filename
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:175
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:408
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::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:88
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:1354
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:1632
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:950
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:1444
RoR::ActorManager::ForwardCommands
void ForwardCommands(ActorPtr source_actor)
Fowards things to trailers.
Definition: ActorManager.cpp:653
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)
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:826
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:1133
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:783
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:1030
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:966
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:1168
RoR
Definition: AppContext.h:36
Network.h
RoR::ActorManager::GetActorById
const ActorPtr & GetActorById(ActorInstanceID_t actor_id)
Definition: ActorManager.cpp:1146
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:872
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:1158
RoR::App::sim_replay_enabled
CVar * sim_replay_enabled
Definition: Application.cpp:101
RoR::ActorManager::CheckNetRemoteStreamsOk
int CheckNetRemoteStreamsOk(int sourceid)
Definition: ActorManager.cpp:538
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::Actor::calcNodeConnectivityGraph
void calcNodeConnectivityGraph()
Definition: Actor.cpp:874
RoRnet::StreamRegister
< Sent from the client to server and vice versa, to broadcast a new stream
Definition: RoRnet.h:140