Skip to content

Commit

Permalink
Tuning: fixed vehicle not restoring after removing addonpart.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Nov 13, 2023
1 parent c622acc commit ca84bed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ void ActorSpawner::ConfigureAddonParts(CacheEntryPtr& tuneup_entry)
ROR_ASSERT(tuneup_entry->resource_group != "");
ROR_ASSERT(tuneup_entry->tuneup_def != nullptr);

AddonPartUtility::ResetUnwantedAndTweakedElements(tuneup_entry->tuneup_def);

for (const std::string& addonpart: tuneup_entry->tuneup_def->use_addonparts)
{
CacheEntryPtr addonpart_entry = App::GetCacheSystem()->FindEntryByFilename(LT_AddonPart, /*partial:*/false, addonpart);
Expand Down
11 changes: 11 additions & 0 deletions source/main/resources/addonpart_fileformat/AddonPartFileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ void AddonPartUtility::ResolveUnwantedAndTweakedElements(TuneupDefPtr& tuneup, C
}
}

void AddonPartUtility::ResetUnwantedAndTweakedElements(TuneupDefPtr& tuneup)
{
ROR_ASSERT(tuneup);
// Unwanted
tuneup->remove_flexbodies.clear();
tuneup->remove_props.clear();
// Tweaked
tuneup->node_tweaks.clear();
tuneup->wheel_tweaks.clear();
}


// Helpers of `TransformToRigDefModule()`, they expect `m_context` to be in position:
// These expect `m_context` to be in position:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class AddonPartUtility
/// Also handles 'addonpart_tweak_*' elements, resolving possible conflicts among used parts.
void ResolveUnwantedAndTweakedElements(TuneupDefPtr& tuneup, CacheEntryPtr& addonpart_entry);

static void ResetUnwantedAndTweakedElements(TuneupDefPtr& tuneup);

private:
// Helpers of `TransformToRigDefModule()`, they expect `m_context` to be in position:
void ProcessManagedMaterial();
Expand Down

0 comments on commit ca84bed

Please sign in to comment.