Materials: Assigning material without appearance

Assigning a material without an appearance reset the appearance to the
default appearance.

There were two main problems. One was the comparison function for
App::Material objects. It would return false when the UUID or MatType
values were different although there are many circumstances where this
could be true and the appearance be the same. It also incorrectly
compared the imagePath.

The second problem was the logic for detecting if an object has already
been assigned an appearance by assigning a material or manually setting
the appearance. If assigned a material, the appearance should update but
not if it has been set manually. This logic has been corrected.
This commit is contained in:
David Carter
2025-10-29 17:46:23 -04:00
committed by Max Wilfinger
parent de8d02e0bb
commit 31929cb4e5
2 changed files with 9 additions and 6 deletions

View File

@@ -195,8 +195,10 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop)
*/
App::Material defaultMaterial;
auto material = geometry->getMaterialAppearance();
if ((materialAppearance == defaultMaterial)
|| (ShapeAppearance.getSize() == 1 && ShapeAppearance[0] == materialAppearance)) {
if ((ShapeAppearance.getSize() == 1)
&& (ShapeAppearance[0] == defaultMaterial
|| ShapeAppearance[0] == materialAppearance)
&& (material != defaultMaterial)) {
ShapeAppearance.setValue(material);
}
materialAppearance = material;