71 for (
int i = 0; i < num_rays*2; ++i)
78 for (
int i = 0; i < num_rays*2; ++i)
89 auto end = def->user_modules.end();
90 auto itor = def->user_modules.begin();
91 for (;itor != end; ++itor)
120 cm_type = RoR::Console::MessageType::CONSOLE_SYSTEM_ERROR;
125 cm_type = RoR::Console::MessageType::CONSOLE_SYSTEM_WARNING;
129 cm_type = RoR::Console::MessageType::CONSOLE_SYSTEM_NOTICE;
140 unsigned out_offset = 0;
160 std::stringstream msg;
161 msg <<
"Cannot resolve node by index [" << index_in <<
"], node is not defined, highest available number is: " <<
m_all_nodes.size() - 1;
167 if (index_out != index_in)
169 std::stringstream msg;
170 msg <<
"Node resolved by index.\n\tSource: [" << index_in <<
"]\n\tResult: [" << index_out <<
"]";
182 return Node::Ref(
TOSTRING(index_out), index_out, Node::Ref::IMPORT_STATE_IS_VALID | Node::Ref::IMPORT_STATE_IS_RESOLVED_NUMBERED, def_line_number);
188 if (!noderef_in.GetImportState_IsValid())
197 if (noderef_in.GetImportState_MustCheckNamedFirst())
202 return Node::Ref(noderef_in.
Str(), 0, Node::Ref::IMPORT_STATE_IS_VALID | Node::Ref::IMPORT_STATE_IS_RESOLVED_NAMED, noderef_in.
GetLineNumber());
209 Node::Ref out_ref(
"0", 0, Node::Ref::IMPORT_STATE_IS_VALID | Node::Ref::IMPORT_STATE_IS_RESOLVED_NUMBERED, noderef_in.
GetLineNumber());
210 std::stringstream msg;
211 msg <<
"Cannot resolve " << noderef_in.
ToString() <<
" - not a named node, and index is not defined (highest is: "
212 <<
m_all_nodes.size() - 1 <<
"). For backwards compatibility, converting to: " << out_ref.
ToString();
217 if (entry.node_id.IsTypeNamed())
219 Node::Ref out_ref(entry.node_id.Str(), 0, Node::Ref::IMPORT_STATE_IS_VALID | Node::Ref::IMPORT_STATE_IS_RESOLVED_NAMED, noderef_in.
GetLineNumber());
227 else if (entry.node_id.IsTypeNumbered())
229 unsigned out_index = this->
GetNodeArrayOffset(entry.origin_keyword) + entry.node_sub_index;
230 Node::Ref out_ref(
TOSTRING(out_index), out_index, Node::Ref::IMPORT_STATE_IS_VALID | Node::Ref::IMPORT_STATE_IS_RESOLVED_NUMBERED, noderef_in.
GetLineNumber());
241 std::stringstream msg;
242 msg <<
"Cannot resolve " << noderef_in.
ToString() <<
" - found node is not valid";
250 auto range_itor = in_ranges.begin();
251 auto range_end = in_ranges.end();
252 for ( ; range_itor != range_end; ++range_itor)
257 if (!range.
start.GetImportState_IsValid())
259 std::stringstream msg;
260 msg <<
"ResolveFlexbodyForset(): Skipping node because it's marked INVALID:" << range.
start.
ToString();
270 out_nodes.push_back(node_ref);
274 std::stringstream msg;
275 msg <<
"ResolveFlexbodyForset(): Stand-alone node [" << range.
start.
ToString() <<
"] resolved invalid, removing from FORSET";
282 if (!range.
start.GetImportState_IsValid() || !range.
end.GetImportState_IsValid())
284 std::stringstream msg;
285 msg <<
"ResolveFlexbodyForset(): Skipping range because some nodes are marked INVALID, start: [" << range.
start.
ToString() <<
"], end: [" << range.
end.
ToString() <<
"]";
288 else if (range.
start.GetImportState_IsResolvedNamed() || range.
end.GetImportState_IsResolvedNamed())
290 std::stringstream msg;
291 msg <<
"ResolveFlexbodyForset(): Some nodes in range are already resolved as named, unable to process, start: [" << range.
start.
ToString() <<
"], end: [" << range.
end.
ToString() <<
"]";
296 unsigned int end_index = range.
end.
Num();
298 for (
unsigned int i = range.
start.
Num(); i <= end_index; ++i)
305 out_nodes.push_back(node_ref);
309 std::stringstream msg;
310 msg <<
"ResolveFlexbodyForset(): Node ["<<i<<
"] from range [" << range.
start.
ToString() <<
" - " << range.
end.
ToString() <<
"] resolved invalid, removing from FORSET";
321 auto in_ranges = ranges;
324 auto range_itor = in_ranges.begin();
325 auto range_end = in_ranges.end();
326 for ( ; range_itor != range_end; ++range_itor)
333 else if (!range.
start.GetImportState_IsValid() || !range.
end.GetImportState_IsValid())
335 std::stringstream msg;
336 msg <<
"Some nodes in range are invalid, start: [" << range.
start.
ToString() <<
"], end: [" << range.
end.
ToString() <<
"]";
339 else if (range.
start.GetImportState_IsResolvedNamed() || range.
end.GetImportState_IsResolvedNamed())
341 std::stringstream msg;
342 msg <<
"Some nodes in range are already resolved as named, unable to process, start: [" << range.
start.
ToString() <<
"], end: [" << range.
end.
ToString() <<
"]";
347 unsigned int end_index = range.
end.
Num();
348 for (
unsigned int i = range.
start.
Num(); i < end_index; ++i)
356 #define RESOLVE_OPTIONAL_SECTION(KEYWORD, PTRNAME, BLOCK) \
358 m_current_keyword = KEYWORD; \
363 m_current_keyword = Keyword::INVALID; \
366 #define FOR_EACH(KEYWORD, VECTOR, VARNAME, BLOCK) \
368 m_current_keyword = KEYWORD; \
369 auto itor_ = VECTOR.begin(); \
370 auto end_ = VECTOR.end(); \
371 for (; itor_ != end_; ++itor_) \
373 auto& VARNAME = *itor_; \
376 m_current_keyword = Keyword::INVALID; \
379 #define RESOLVE(VARNAME) VARNAME = this->ResolveNode(VARNAME);
381 #define RESOLVE_VECTOR(VECTORNAME) \
383 auto end = VECTORNAME.end(); \
384 for ( auto itor = VECTORNAME.begin(); itor != end; ++itor) \
400 RESOLVE(airbrake.reference_node);
401 RESOLVE(airbrake.x_axis_node );
402 RESOLVE(airbrake.y_axis_node );
403 RESOLVE(airbrake.aditional_node);
408 RESOLVE(axle.wheels[0][0]);
409 RESOLVE(axle.wheels[0][1]);
410 RESOLVE(axle.wheels[1][0]);
411 RESOLVE(axle.wheels[1][1]);
416 RESOLVE(beam.nodes[0]);
417 RESOLVE(beam.nodes[1]);
422 RESOLVE(camera.center_node);
423 RESOLVE(camera.back_node );
424 RESOLVE(camera.left_node );
429 RESOLVE_VECTOR(rail.nodes);
434 RESOLVE(cinecam.nodes[0]);
435 RESOLVE(cinecam.nodes[1]);
436 RESOLVE(cinecam.nodes[2]);
437 RESOLVE(cinecam.nodes[3]);
438 RESOLVE(cinecam.nodes[4]);
439 RESOLVE(cinecam.nodes[5]);
440 RESOLVE(cinecam.nodes[6]);
441 RESOLVE(cinecam.nodes[7]);
446 RESOLVE_VECTOR(box.nodes);
451 RESOLVE(command.nodes[0]);
452 RESOLVE(command.nodes[1]);
457 RESOLVE(contacter_node);
462 RESOLVE(exhaust.reference_node);
463 RESOLVE(exhaust.direction_node);
468 RESOLVE(extcamera.node);
478 RESOLVE(flare2.reference_node);
479 RESOLVE(flare2.node_axis_x );
480 RESOLVE(flare2.node_axis_y );
485 RESOLVE(flexbody.reference_node);
486 RESOLVE(flexbody.x_axis_node );
487 RESOLVE(flexbody.y_axis_node );
489 ResolveFlexbodyForset(flexbody.node_list_to_import, flexbody.node_list);
490 flexbody.node_list_to_import.clear();
495 RESOLVE(flexbodywheel.nodes[0] );
496 RESOLVE(flexbodywheel.nodes[1] );
497 RESOLVE(flexbodywheel.rigidity_node );
498 RESOLVE(flexbodywheel.reference_arm_node);
503 RESOLVE(fusedrag.front_node);
504 RESOLVE(fusedrag.rear_node);
514 RESOLVE(hydro.nodes[0]);
515 RESOLVE(hydro.nodes[1]);
520 RESOLVE(meshwheel.nodes[0] );
521 RESOLVE(meshwheel.nodes[1] );
522 RESOLVE(meshwheel.rigidity_node );
523 RESOLVE(meshwheel.reference_arm_node);
527 RESOLVE(meshwheel2.nodes[0] );
528 RESOLVE(meshwheel2.nodes[1] );
529 RESOLVE(meshwheel2.rigidity_node );
530 RESOLVE(meshwheel2.reference_arm_node);
535 RESOLVE(particle.emitter_node);
536 RESOLVE(particle.reference_node);
541 RESOLVE(prop.reference_node);
542 RESOLVE(prop.x_axis_node );
543 RESOLVE(prop.y_axis_node );
548 ResolveNodeRanges(railgroup.node_list);
553 RESOLVE(ropable.node);
558 RESOLVE(rope.root_node);
559 RESOLVE(rope.end_node );
564 RESOLVE(rotator.axis_nodes[0] );
565 RESOLVE(rotator.axis_nodes[1] );
566 RESOLVE(rotator.base_plate_nodes[0] );
567 RESOLVE(rotator.base_plate_nodes[1] );
568 RESOLVE(rotator.base_plate_nodes[2] );
569 RESOLVE(rotator.base_plate_nodes[3] );
570 RESOLVE(rotator.rotating_plate_nodes[0]);
571 RESOLVE(rotator.rotating_plate_nodes[1]);
572 RESOLVE(rotator.rotating_plate_nodes[2]);
573 RESOLVE(rotator.rotating_plate_nodes[3]);
578 RESOLVE(rotator2.axis_nodes[0] );
579 RESOLVE(rotator2.axis_nodes[1] );
580 RESOLVE(rotator2.base_plate_nodes[0] );
581 RESOLVE(rotator2.base_plate_nodes[1] );
582 RESOLVE(rotator2.base_plate_nodes[2] );
583 RESOLVE(rotator2.base_plate_nodes[3] );
584 RESOLVE(rotator2.rotating_plate_nodes[0]);
585 RESOLVE(rotator2.rotating_plate_nodes[1]);
586 RESOLVE(rotator2.rotating_plate_nodes[2]);
587 RESOLVE(rotator2.rotating_plate_nodes[3]);
592 RESOLVE(screwprop.prop_node);
593 RESOLVE(screwprop.back_node);
594 RESOLVE(screwprop.top_node );
599 RESOLVE(shock.nodes[0]);
600 RESOLVE(shock.nodes[1]);
605 RESOLVE(shock2.nodes[0]);
606 RESOLVE(shock2.nodes[1]);
611 RESOLVE(shock3.nodes[0]);
612 RESOLVE(shock3.nodes[1]);
617 RESOLVE(slidenode.slide_node);
619 ResolveNodeRanges(slidenode.rail_node_ranges);
624 RESOLVE(soundsource.node);
629 RESOLVE(soundsource2.node);
634 m_current_keyword = Keyword::TEXCOORDS;
635 auto texcoord_itor = submesh.texcoords.begin();
636 auto texcoord_end = submesh.texcoords.end();
637 for (; texcoord_itor != texcoord_end; ++texcoord_itor)
639 RESOLVE(texcoord_itor->node);
643 auto cab_itor = submesh.cab_triangles.begin();
644 auto cab_end = submesh.cab_triangles.end();
645 for (; cab_itor != cab_end; ++cab_itor)
655 RESOLVE(tie.root_node);
660 RESOLVE(trigger.nodes[0]);
661 RESOLVE(trigger.nodes[1]);
666 RESOLVE(turbojet.front_node);
667 RESOLVE(turbojet.back_node );
668 RESOLVE(turbojet.side_node );
673 RESOLVE(turboprop2.reference_node );
674 RESOLVE(turboprop2.axis_node );
675 RESOLVE(turboprop2.blade_tip_nodes[0]);
676 RESOLVE(turboprop2.blade_tip_nodes[1]);
677 RESOLVE(turboprop2.blade_tip_nodes[2]);
678 RESOLVE(turboprop2.blade_tip_nodes[3]);
683 RESOLVE(wheel.nodes[0] );
684 RESOLVE(wheel.nodes[1] );
685 RESOLVE(wheel.rigidity_node );
686 RESOLVE(wheel.reference_arm_node);
691 RESOLVE(wheel2.nodes[0] );
692 RESOLVE(wheel2.nodes[1] );
693 RESOLVE(wheel2.rigidity_node );
694 RESOLVE(wheel2.reference_arm_node);
699 RESOLVE(videocamera.reference_node );
700 RESOLVE(videocamera.left_node );
701 RESOLVE(videocamera.bottom_node );
702 RESOLVE(videocamera.alt_reference_node );
703 RESOLVE(videocamera.alt_orientation_node);
708 RESOLVE(wing.nodes[0]);
709 RESOLVE(wing.nodes[1]);
710 RESOLVE(wing.nodes[2]);
711 RESOLVE(wing.nodes[3]);
712 RESOLVE(wing.nodes[4]);
713 RESOLVE(wing.nodes[5]);
714 RESOLVE(wing.nodes[6]);
715 RESOLVE(wing.nodes[7]);
718 m_current_module.reset();
721 bool SequentialImporter::AddNumberedNode(
unsigned int number)
725 std::stringstream msg;
726 msg <<
"Lost sync in node numbers, got numbered node [" << number <<
"], expected [" <<
m_all_nodes.size() <<
"]. Ignoring node.";
738 auto result =
m_named_nodes.insert(std::make_pair(name, node_entry));
741 std::stringstream msg;
742 msg <<
"Duplicate node name [" << name <<
"]. Ignoring node.";
753 unsigned int new_number =
static_cast<int>(
m_all_nodes.size());
754 unsigned int node_sub_index = 0;
755 switch (generated_from)
768 #define STAT_LINE(STREAM, TITLE, COUNT_VAR, KEYWORD) \
770 unsigned offset = this->GetNodeArrayOffset(KEYWORD); \
771 STREAM << "\n\t" << TITLE << std::setw(4) << COUNT_VAR; \
772 if (COUNT_VAR != 0) { STREAM << " (after conversion: start index = " << std::setw(4) << offset << ", end index = " << (offset + COUNT_VAR) - 1 << ")"; } \
777 std::stringstream msg;
778 msg <<
"~~~ Node statistics: ~~~"
796 std::stringstream report;
797 report <<
"~~~ Iterating all nodes, in order as defined (total: " <<
m_all_nodes.size() <<
") ~~~\n";
801 for (; itor != end; ++itor)
805 bool is_wheel =
false;
819 report <<
"\n\t" << std::setw(3) << index <<
": " << entry.
node_id.
ToString()