Skip to content

Commit

Permalink
NBUtil/Export: fixes for wheels (still buggy)
Browse files Browse the repository at this point in the history
It doesn't crash anymore but the wheel spring/damp still isn't saved.
  • Loading branch information
ohlidalp committed Oct 14, 2024
1 parent 21a1d7e commit 0a31404
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
15 changes: 15 additions & 0 deletions source/main/physics/ActorExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 << ", "
Expand Down

0 comments on commit 0a31404

Please sign in to comment.