Skip to content

Commit

Permalink
N/B util: fixed export including generated N/B (wheels...)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Oct 3, 2024
1 parent 20b861a commit 5f44c89
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/main/physics/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4820,6 +4820,12 @@ void Actor::propagateNodeBeamChangesToDef()
pivot.y = App::GetGameContext()->GetTerrain()->GetHeightAt(pivot.x, pivot.z);
for (NodeNum_t i = 0; i < ar_num_nodes; i++)
{
if (ar_nodes[i].nd_rim_node || ar_nodes[i].nd_tyre_node || ar_nodes[i].nd_cinecam_node)
{
// Skip wheel nodes and cinecam nodes
continue;
}

// Check if 'set_node_defaults' must be updated.
float n_loadweight = ar_nodes_default_loadweights[i];
float n_friction = ar_nodes[i].friction_coef;
Expand Down Expand Up @@ -4871,6 +4877,12 @@ void Actor::propagateNodeBeamChangesToDef()

for (int i = 0; i < ar_num_beams; i++)
{
if (!ar_beams_user_defined[i])
{
// Skip everything not from 'beams' (wheels/cinecam/hooknode/wings/rotators etc...)
continue;
}

// Check if 'set_beam_defaults' must be updated.
float b_spring = ar_beams[i].k;
float b_damp = ar_beams[i].d;
Expand Down
1 change: 1 addition & 0 deletions source/main/physics/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class Actor : public RefCountingObject<Actor>
int ar_num_beams = 0;
std::vector<std::pair<float, float>> ar_initial_beam_defaults;
std::vector<bool> ar_beams_invisible;
std::vector<bool> ar_beams_user_defined; //!< True for 'beams', false for wheels/cinecam/hooknode/wings/rotators etc...

std::vector<beam_t*> ar_inter_beams; //!< Beams connecting 2 actors
shock_t* ar_shocks = nullptr; //!< Shock absorbers
Expand Down
3 changes: 3 additions & 0 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ void ActorSpawner::InitializeRig()
// Allocate memory as needed
m_actor->ar_beams = new beam_t[req.num_beams];
m_actor->ar_beams_invisible.resize(req.num_beams, false);
m_actor->ar_beams_user_defined.resize(req.num_beams, false);

m_actor->ar_nodes = new node_t[req.num_nodes];
m_actor->ar_nodes_id = new int[req.num_nodes];
Expand Down Expand Up @@ -5527,6 +5528,7 @@ void ActorSpawner::ProcessBeam(RigDef::Beam & def)

// Beam
int beam_index = m_actor->ar_num_beams;
m_actor->ar_beams_user_defined[beam_index] = true;
beam_t & beam = AddBeam(*ar_nodes[0], *ar_nodes[1], def.defaults, def.detacher_group);
beam.bm_type = BEAM_NORMAL;
beam.k = def.defaults->GetScaledSpringiness();
Expand Down Expand Up @@ -6065,6 +6067,7 @@ void ActorSpawner::ProcessCinecam(RigDef::Cinecam & def)
Ogre::Vector3 node_pos = m_spawn_position + def.position;
node_t & camera_node = GetAndInitFreeNode(node_pos);
camera_node.nd_no_ground_contact = true; // Orig: hardcoded in BTS_CINECAM
camera_node.nd_cinecam_node = true;
camera_node.friction_coef = NODE_FRICTION_COEF_DEFAULT; // Node defaults are ignored here.
AdjustNodeBuoyancy(camera_node, def.node_defaults);
camera_node.volume_coef = def.node_defaults->volume;
Expand Down
1 change: 1 addition & 0 deletions source/main/physics/SimData.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ struct node_t
bool nd_override_mass:1; //!< User defined attr; mass is user-specified rather than calculated (override the calculation)
bool nd_under_water:1; //!< State; GFX hint
bool nd_no_mouse_grab:1; //!< Attr; User-defined
bool nd_cinecam_node:1; //!< Attr; User-defined

Ogre::Real nd_avg_collision_slip; //!< Physics state; average slip velocity across the last few physics frames
Ogre::Vector3 nd_last_collision_slip; //!< Physics state; last collision slip vector
Expand Down
1 change: 1 addition & 0 deletions source/main/resources/CacheSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,7 @@ CacheEntryPtr CacheSystem::CreateProject(CreateProjectRequest* request)

if (request->cpr_type == CreateProjectRequestType::ACTOR_PROJECT)
{
// Load the project file to perform fixups (name & category)
GenericDocumentPtr doc = new GenericDocument();
int flags = GenericDocument::OPTION_ALLOW_NAKED_STRINGS
| GenericDocument::OPTION_ALLOW_SLASH_COMMENTS
Expand Down

0 comments on commit 5f44c89

Please sign in to comment.