Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Hotfix: only load prop mesh from own resource group. #2784

Merged
merged 1 commit into from
Aug 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions source/main/utils/MeshObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ void MeshObject::createEntity(Ogre::String meshName, Ogre::String entityRG, Ogre

try
{
// Classic behavior: look in all resource groups.
// The mesh may live in terrain's resource bundle (aka ZIP) or ror's bundled resource ZIPs.
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(meshName, Ogre::RGN_AUTODETECT);
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(meshName, entityRG);

// important: you need to add the LODs before creating the entity
// now find possible LODs, needs to be done before calling createEntity()
String basename, ext;
StringUtil::splitBaseFilename(meshName, basename, ext);

// the classic LODs
FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo(Ogre::RGN_AUTODETECT, basename + "_lod*.mesh");
FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo(entityRG, basename + "_lod*.mesh");
for (FileInfoList::iterator iterFiles = files->begin(); iterFiles != files->end(); ++iterFiles)
{
String format = basename + "_lod%d.mesh";
Expand All @@ -89,11 +87,11 @@ void MeshObject::createEntity(Ogre::String meshName, Ogre::String entityRG, Ogre
if (r <= 0 || i < 0)
continue;

Ogre::MeshManager::getSingleton().load(iterFiles->filename, mesh->getGroup());
Ogre::MeshManager::getSingleton().load(iterFiles->filename, entityRG);
}

// the custom LODs
FileInfoListPtr files2 = ResourceGroupManager::getSingleton().findResourceFileInfo(Ogre::RGN_AUTODETECT, basename + "_clod_*.mesh");
FileInfoListPtr files2 = ResourceGroupManager::getSingleton().findResourceFileInfo(entityRG, basename + "_clod_*.mesh");
for (FileInfoList::iterator iterFiles = files2->begin(); iterFiles != files2->end(); ++iterFiles)
{
// and custom LODs
Expand All @@ -103,7 +101,7 @@ void MeshObject::createEntity(Ogre::String meshName, Ogre::String entityRG, Ogre
if (r <= 0 || i < 0)
continue;

Ogre::MeshManager::getSingleton().load(iterFiles->filename, mesh->getGroup());
Ogre::MeshManager::getSingleton().load(iterFiles->filename, entityRG);
}

// now create an entity around the mesh and attach it to the scene graph
Expand All @@ -116,7 +114,7 @@ void MeshObject::createEntity(Ogre::String meshName, Ogre::String entityRG, Ogre
}
catch (Ogre::Exception& e)
{
RoR::LogFormat("[RoR] Error creating entity of mesh '%s' (target group: '%s'), message: %s",
RoR::LogFormat("[RoR] Error creating entity of mesh '%s' (group: '%s'), message: %s",
meshName.c_str(), entityRG.c_str(), e.getFullDescription().c_str());
return;
}
Expand Down