diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index d7c1754c15..d4d4cba0e3 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -188,8 +188,19 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop) // Set the appearance from the material auto geometry = dynamic_cast(getObject()); if (geometry) { + /* + * Change the appearance only if the appearance hasn't been set explicitly. A cached + * material appearance is used to see if the current appearance matches the last + * material. It is also compared against an empty material to see if the saved + * material value has been initialized. + */ + App::Material defaultMaterial; auto material = geometry->getMaterialAppearance(); - ShapeAppearance.setValue(material); + if ((materialAppearance == defaultMaterial) + || (ShapeAppearance.getSize() == 1 && ShapeAppearance[0] == materialAppearance)) { + ShapeAppearance.setValue(material); + } + materialAppearance = material; } } diff --git a/src/Gui/ViewProviderGeometryObject.h b/src/Gui/ViewProviderGeometryObject.h index 607cd42d2f..3561b1178a 100644 --- a/src/Gui/ViewProviderGeometryObject.h +++ b/src/Gui/ViewProviderGeometryObject.h @@ -116,6 +116,8 @@ protected: SoFCBoundingBox* pcBoundingBox {nullptr}; SoSwitch* pcBoundSwitch {nullptr}; SoBaseColor* pcBoundColor {nullptr}; + + App::Material materialAppearance; }; } // namespace Gui