Skip to content

Commit 597d889

Browse files
authored
Remove ClearMaterialsCache call when a material is destroyed in ogre2 (#1110)
Signed-off-by: Ian Chen <ichen@openrobotics.org>
1 parent a48f757 commit 597d889

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

ogre2/include/gz/rendering/ogre2/Ogre2MeshFactory.hh

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ namespace gz
9595
protected: Ogre2ScenePtr scene;
9696

9797
/// \brief Remove internal material cache for a specific material
98+
/// \todo(iche033) Deprecate this function in gz-rendering10
9899
public: void ClearMaterialsCache(const std::string &_name);
99100

100101
/// \brief Pointer to private data class

ogre2/include/gz/rendering/ogre2/Ogre2Scene.hh

+1
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ namespace gz
457457

458458
/// \brief Remove internal material cache for a specific material
459459
/// \param[in] _name Name of the template material to remove.
460+
/// \todo(iche033) Deprecate this function in gz-rendering10
460461
public: void ClearMaterialsCache(const std::string &_name);
461462

462463
/// \brief Create a shared pointer to self

ogre2/src/Ogre2Material.cc

-2
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ void Ogre2Material::Destroy()
277277

278278
if (textureToRemove && !textureIsUse)
279279
{
280-
Ogre2ScenePtr s = std::dynamic_pointer_cast<Ogre2Scene>(this->Scene());
281-
s->ClearMaterialsCache(this->textureName);
282280
this->Scene()->UnregisterMaterial(this->name);
283281
textureManager->destroyTexture(textureToRemove);
284282
}

ogre2/src/Ogre2MeshFactory.cc

+2-19
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
/// \brief Private data for the Ogre2MeshFactory class
5858
class gz::rendering::Ogre2MeshFactoryPrivate
5959
{
60-
/// \brief Vector with the template materials, we keep the pointer to be
61-
/// able to remove it when nobody is using it.
62-
public: std::vector<MaterialPtr> materialCache;
6360
};
6461

6562
/// \brief Private data for the Ogre2SubMeshStoreFactory class
@@ -91,22 +88,9 @@ void Ogre2MeshFactory::Clear()
9188
}
9289

9390
//////////////////////////////////////////////////
94-
void Ogre2MeshFactory::ClearMaterialsCache(const std::string &_name)
91+
void Ogre2MeshFactory::ClearMaterialsCache(const std::string &)
9592
{
96-
auto it = this->dataPtr->materialCache.begin();
97-
for (auto &mat : this->dataPtr->materialCache)
98-
{
99-
std::string matName = mat->Name();
100-
std::string textureName = mat->Texture();
101-
if (textureName == _name)
102-
{
103-
this->scene->UnregisterMaterial(matName);
104-
break;
105-
}
106-
++it;
107-
}
108-
if (it != this->dataPtr->materialCache.end())
109-
this->dataPtr->materialCache.erase(it);
93+
// no-op
11094
}
11195

11296
//////////////////////////////////////////////////
@@ -501,7 +485,6 @@ bool Ogre2MeshFactory::LoadImpl(const MeshDescriptor &_desc)
501485
if (material)
502486
{
503487
mat->CopyFrom(*material);
504-
this->dataPtr->materialCache.push_back(mat);
505488
}
506489
else
507490
{

0 commit comments

Comments
 (0)