Skip to content

Commit

Permalink
🐛 Fixed #3148 Texture conflicts between mods
Browse files Browse the repository at this point in the history
Problem: when assigning `Ogre::Material` to a managedmat, the lookup was done across all resoruce groups instead of only the appropriate ZIP's (bundle) resource goroup. See `InstantiateManagedMaterial()`, `getByName()`.
Fix: use the correct resource group which is already detected in `ProcessManagedMaterial()`
  • Loading branch information
ohlidalp committed Apr 7, 2024
1 parent ddd2025 commit 04fb5da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


/// @file
/// @brief Vehicle spawning logic.
/// @brief Setup instance of `Actor` from a `RigDef` document.
/// @author Petr Ohlidal
/// @date 12/2013

Expand Down Expand Up @@ -2309,9 +2309,9 @@ void ActorSpawner::ProcessFlare2(RigDef::Flare2 & def)
m_actor->ar_flares.push_back(flare);
}

Ogre::MaterialPtr ActorSpawner::InstantiateManagedMaterial(Ogre::String const & source_name, Ogre::String const & clone_name)
Ogre::MaterialPtr ActorSpawner::InstantiateManagedMaterial(const Ogre::String& rg_name, Ogre::String const & source_name, Ogre::String const & clone_name)
{
Ogre::MaterialPtr src_mat = Ogre::MaterialManager::getSingleton().getByName(source_name);
Ogre::MaterialPtr src_mat = Ogre::MaterialManager::getSingleton().getByName(source_name, rg_name);
if (src_mat.isNull())
{
std::stringstream msg;
Expand Down Expand Up @@ -2382,11 +2382,11 @@ void ActorSpawner::ProcessManagedMaterial(RigDef::ManagedMaterial & def)
/* FLEXMESH, damage, specular */
if (App::gfx_alt_actor_materials->getBool())
{
material = this->InstantiateManagedMaterial(mat_name_base + "/speculardamage", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/speculardamage", custom_name);
}
else
{
material = this->InstantiateManagedMaterial(mat_name_base + "/speculardamage_nicemetal", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/speculardamage_nicemetal", custom_name);
}

if (material.isNull())
Expand All @@ -2411,7 +2411,7 @@ void ActorSpawner::ProcessManagedMaterial(RigDef::ManagedMaterial & def)
else
{
/* FLEXMESH, damage, no_specular */
material = this->InstantiateManagedMaterial(mat_name_base + "/damageonly", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/damageonly", custom_name);
if (material.isNull())
{
return;
Expand All @@ -2427,11 +2427,11 @@ void ActorSpawner::ProcessManagedMaterial(RigDef::ManagedMaterial & def)
/* FLEXMESH, no_damage, specular */
if (App::gfx_alt_actor_materials->getBool())
{
material = this->InstantiateManagedMaterial(mat_name_base + "/specularonly", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/specularonly", custom_name);
}
else
{
material = this->InstantiateManagedMaterial(mat_name_base + "/specularonly_nicemetal", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/specularonly_nicemetal", custom_name);
}

if (material.isNull())
Expand All @@ -2454,7 +2454,7 @@ void ActorSpawner::ProcessManagedMaterial(RigDef::ManagedMaterial & def)
else
{
/* FLEXMESH, no_damage, no_specular */
material = this->InstantiateManagedMaterial(mat_name_base + "/simple", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/simple", custom_name);
if (material.isNull())
{
return;
Expand All @@ -2475,11 +2475,11 @@ void ActorSpawner::ProcessManagedMaterial(RigDef::ManagedMaterial & def)
/* MESH, specular */
if (App::gfx_alt_actor_materials->getBool())
{
material = this->InstantiateManagedMaterial(mat_name_base + "/specular", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/specular", custom_name);
}
else
{
material = this->InstantiateManagedMaterial(mat_name_base + "/specular_nicemetal", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/specular_nicemetal", custom_name);
}

if (material.isNull())
Expand All @@ -2502,7 +2502,7 @@ void ActorSpawner::ProcessManagedMaterial(RigDef::ManagedMaterial & def)
else
{
/* MESH, no_specular */
material = this->InstantiateManagedMaterial(mat_name_base + "/simple", custom_name);
material = this->InstantiateManagedMaterial(resource_group, mat_name_base + "/simple", custom_name);
if (material.isNull())
{
return;
Expand Down
2 changes: 1 addition & 1 deletion source/main/physics/ActorSpawner.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class ActorSpawner
void CreateVideoCamera(RigDef::VideoCamera* def);
void CreateMirrorPropVideoCam(Ogre::MaterialPtr custom_mat, CustomMaterial::MirrorPropType type, Ogre::SceneNode* prop_scenenode);
void SetupNewEntity(Ogre::Entity* e, Ogre::ColourValue simple_color); //!< Full texture and material setup
Ogre::MaterialPtr InstantiateManagedMaterial(Ogre::String const & source_name, Ogre::String const & clone_name);
Ogre::MaterialPtr InstantiateManagedMaterial(Ogre::String const & rg_name, Ogre::String const & source_name, Ogre::String const & clone_name);
void CreateCabVisual();
void CreateMaterialFlare(int flare_index, Ogre::MaterialPtr mat);

Expand Down

0 comments on commit 04fb5da

Please sign in to comment.