gazebosim / gazebosim/gz-rendering

[Ogre2] Destroying material is expensive and does not remove all textures

Open
#1,167 0 comments 0 reactions 0 assignees View on GitHub
bug ogre2.x
Dominant language
C++
Stars
81
Forks
90
Avg merge
1d 13h
Merged PRs (30d)
10

Description

## Environment
* OS Version: 24.04
* Source or binary build?
source build, gz-rendering10

## Description
* Expected behavior: Destroying an Ogre2Material should be fast and it should clean up all unused textures created by the material, including diffuse, normal, roughness, metalness maps, lightmap, etc
* Actual behavior:
* The [Destroy()](https://github.com/gazebosim/gz-rendering/blob/fde53a65311c9eeeba73d68fbbe0689aa41332a5/ogre2/src/Ogre2Material.cc#L172) function can be quite expensive when there are many textures in the scene. The expensive part is that it [loops through all materials](https://github.com/gazebosim/gz-rendering/blob/fde53a65311c9eeeba73d68fbbe0689aa41332a5/ogre2/src/Ogre2Material.cc#L227) and checks to make sure they are not in use before removing them.
* In addition, it only [checks and cleans up the diffuse texture](https://github.com/gazebosim/gz-rendering/blob/fde53a65311c9eeeba73d68fbbe0689aa41332a5/ogre2/src/Ogre2Material.cc#L258) (`this->textureName`) and does not check for other texture maps like normal maps, etc. So other maps are not cleaned up properly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.