Set non-unique material to submesh when updating cast shadows property #3085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🦟 Bug fix
Related issue: gazebosim/jetty_demo#3
Requires gazebosim/gz-rendering#1168
Summary
When updating the cast shadows property of a visual, we set the material with the cast shadow value to all the submeshes in the visual. However, the
SetMaterial
call by default clones the input material before setting it to the submesh. The submesh's original material will also be destroyed during this process. The problem is that the material destruction process was found to be expensive and does not cleanup textures properly, see gazebosim/gz-rendering#1167. This PR updates theSetMaterial
call to passfalse
in the second arg so the material is not cloned when being set, which prevents the original material from being destroyed.When running the Jetty demo world, the load time reduced from 30s to 24s on my machine (tested with with #3070 and gazebosim/gz-common#706)
Checklist
codecheck
passed (See contributing)Generated-by: Remove this if GenAI was not used.
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
andGenerated-by
messages.