From 7fff27f036a5a808b9015ff448fb7f1468f4caa7 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sun, 10 Oct 2021 22:01:25 +0800 Subject: [PATCH] Part: sync ViewProviderExt::DiffuseColor on Transparency change --- src/Mod/Part/Gui/ViewProviderExt.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index c43bb64fad..47257f6958 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -452,17 +452,10 @@ void ViewProviderPartExt::onChanged(const App::Property* prop) long value = (long)(100*Mat.transparency); if (value != Transparency.getValue()) { float trans = Transparency.getValue()/100.0f; - if (pcFaceBind->value.getValue() == SoMaterialBinding::PER_PART) { - int cnt = pcShapeMaterial->diffuseColor.getNum(); - pcShapeMaterial->transparency.setNum(cnt); - float *t = pcShapeMaterial->transparency.startEditing(); - for (int i=0; itransparency.finishEditing(); - } - else { - pcShapeMaterial->transparency = trans; - } + auto colors = DiffuseColor.getValues(); + for (auto &c : colors) + c.a = Transparency.getValue()/100.0f; + DiffuseColor.setValues(colors); App::PropertyContainer* parent = ShapeMaterial.getContainer(); ShapeMaterial.setContainer(0); @@ -731,7 +724,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& col else if (colors.size() == 1) { pcFaceBind->value = SoMaterialBinding::OVERALL; pcShapeMaterial->diffuseColor.setValue(colors[0].r, colors[0].g, colors[0].b); - //pcShapeMaterial->transparency = colors[0].a; do not get transparency from DiffuseColor in this case + pcShapeMaterial->transparency = Transparency.getValue()/100.f; } }