From 0a31404401ad71153858d923ffba767076cdb445 Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Mon, 14 Oct 2024 23:22:12 +0200 Subject: [PATCH] NBUtil/Export: fixes for wheels (still buggy) It doesn't crash anymore but the wheel spring/damp still isn't saved. --- source/main/physics/ActorExport.cpp | 15 +++++++++++++++ source/main/physics/ActorSpawner.cpp | 6 ++++++ .../rig_def_fileformat/RigDef_Serializer.cpp | 8 ++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/source/main/physics/ActorExport.cpp b/source/main/physics/ActorExport.cpp index 5c06f41bd4..1dc52b58b6 100644 --- a/source/main/physics/ActorExport.cpp +++ b/source/main/physics/ActorExport.cpp @@ -295,6 +295,8 @@ void Actor::propagateNodeBeamChangesToDef() case Keyword::WHEELS: { RigDef::Wheel wheel; + wheel.beam_defaults = beam_defaults; + wheel.node_defaults = node_defaults; // radius wheel.radius = ar_wheels[i].wh_radius; // rays @@ -323,6 +325,8 @@ void Actor::propagateNodeBeamChangesToDef() case Keyword::WHEELS2: { RigDef::Wheel2 wheel; + wheel.beam_defaults = beam_defaults; + wheel.node_defaults = node_defaults; // radius wheel.rim_radius = ar_wheels[i].wh_rim_radius; wheel.tyre_radius = ar_wheels[i].wh_radius; @@ -354,6 +358,8 @@ void Actor::propagateNodeBeamChangesToDef() case Keyword::MESHWHEELS: { RigDef::MeshWheel wheel; + wheel.beam_defaults = beam_defaults; + wheel.node_defaults = node_defaults; // radius wheel.rim_radius = ar_wheels[i].wh_rim_radius; wheel.tyre_radius = ar_wheels[i].wh_radius; @@ -377,6 +383,8 @@ void Actor::propagateNodeBeamChangesToDef() wheel.side = ar_wheels[i].wh_arg_side; wheel.mesh_name = ar_wheels[i].wh_arg_media1; wheel.material_name = ar_wheels[i].wh_arg_media2; + + m_used_actor_entry->actor_def->root_module->meshwheels.push_back(wheel); break; } case Keyword::MESHWHEELS2: @@ -390,6 +398,7 @@ void Actor::propagateNodeBeamChangesToDef() RigDef::MeshWheel2 wheel; wheel.beam_defaults = beam_defaults; + wheel.node_defaults = node_defaults; // radius wheel.rim_radius = ar_wheels[i].wh_rim_radius; wheel.tyre_radius = ar_wheels[i].wh_radius; @@ -413,6 +422,8 @@ void Actor::propagateNodeBeamChangesToDef() wheel.side = ar_wheels[i].wh_arg_side; wheel.mesh_name = ar_wheels[i].wh_arg_media1; wheel.material_name = ar_wheels[i].wh_arg_media2; + + m_used_actor_entry->actor_def->root_module->meshwheels2.push_back(wheel); break; } case Keyword::FLEXBODYWHEELS: @@ -425,6 +436,8 @@ void Actor::propagateNodeBeamChangesToDef() beam_defaults->breaking_threshold = -1; RigDef::FlexBodyWheel wheel; + wheel.beam_defaults = beam_defaults; + wheel.node_defaults = node_defaults; // radius wheel.rim_radius = ar_wheels[i].wh_rim_radius; wheel.tyre_radius = ar_wheels[i].wh_radius; @@ -448,6 +461,8 @@ void Actor::propagateNodeBeamChangesToDef() wheel.side = ar_wheels[i].wh_arg_side; wheel.rim_mesh_name = ar_wheels[i].wh_arg_media1; wheel.tyre_mesh_name = ar_wheels[i].wh_arg_media2; + + m_used_actor_entry->actor_def->root_module->flexbodywheels.push_back(wheel); break; } default: diff --git a/source/main/physics/ActorSpawner.cpp b/source/main/physics/ActorSpawner.cpp index 65819fbddd..c9be69e728 100644 --- a/source/main/physics/ActorSpawner.cpp +++ b/source/main/physics/ActorSpawner.cpp @@ -4327,6 +4327,8 @@ void ActorSpawner::ProcessFlexBodyWheel(RigDef::FlexBodyWheel & def) m_actor->ar_wheels[wheel_id].wh_arg_keyword = RigDef::Keyword::FLEXBODYWHEELS; m_actor->ar_wheels[wheel_id].wh_arg_num_rays = def.num_rays; + m_actor->ar_wheels[wheel_id].wh_arg_media1 = def.rim_mesh_name; + m_actor->ar_wheels[wheel_id].wh_arg_media2 = def.tyre_mesh_name; // Beams float rim_spring = def.rim_springiness; @@ -4522,6 +4524,8 @@ void ActorSpawner::ProcessMeshWheel(RigDef::MeshWheel & meshwheel_def) m_actor->ar_wheels[wheel_id].wh_arg_simple_spring = meshwheel_def.spring; m_actor->ar_wheels[wheel_id].wh_arg_simple_damping = meshwheel_def.damping; m_actor->ar_wheels[wheel_id].wh_arg_side = meshwheel_def.side; + m_actor->ar_wheels[wheel_id].wh_arg_media1 = meshwheel_def.mesh_name; + m_actor->ar_wheels[wheel_id].wh_arg_media2 = meshwheel_def.material_name; this->BuildWheelBeams( meshwheel_def.num_rays, @@ -4590,6 +4594,8 @@ void ActorSpawner::ProcessMeshWheel2(RigDef::MeshWheel2 & def) m_actor->ar_wheels[wheel_id].wh_arg_side = def.side; m_actor->ar_wheels[wheel_id].wh_arg_rim_spring = def.beam_defaults->springiness; m_actor->ar_wheels[wheel_id].wh_arg_rim_damping = def.beam_defaults->damping_constant; + m_actor->ar_wheels[wheel_id].wh_arg_media1 = def.mesh_name; + m_actor->ar_wheels[wheel_id].wh_arg_media2 = def.material_name; /* --- Beams --- */ /* Use data from directive 'set_beam_defaults' for the tiretread beams */ diff --git a/source/main/resources/rig_def_fileformat/RigDef_Serializer.cpp b/source/main/resources/rig_def_fileformat/RigDef_Serializer.cpp index ffc9aee496..d5410fc083 100644 --- a/source/main/resources/rig_def_fileformat/RigDef_Serializer.cpp +++ b/source/main/resources/rig_def_fileformat/RigDef_Serializer.cpp @@ -1724,12 +1724,12 @@ void Serializer::ExportBaseMeshWheel(BaseMeshWheel& def) << setw(m_float_width) << def.rim_radius << ", " << setw(m_float_width) << def.width << ", " << setw(3) << def.num_rays << ", " - << setw(m_node_id_width) << def.nodes[0].ToString() << ", " - << setw(m_node_id_width) << def.nodes[1].ToString() << ", " - << setw(m_node_id_width) << def.rigidity_node.ToString() << ", " + << setw(m_node_id_width) << def.nodes[0].Str() << ", " + << setw(m_node_id_width) << def.nodes[1].Str() << ", " + << setw(m_node_id_width) << RigidityNodeToStr(def.rigidity_node) << ", " << setw(3) << (int)def.braking << ", " << setw(3) << (int)def.propulsion << ", " - << setw(m_node_id_width) << def.reference_arm_node.ToString() << ", " + << setw(m_node_id_width) << def.reference_arm_node.Str() << ", " << setw(m_float_width) << def.mass << ", " << setw(m_float_width) << def.spring << ", " << setw(m_float_width) << def.damping << ", "