Part: sync ViewProviderExt::DiffuseColor on Transparency change

This commit is contained in:
Zheng, Lei
2021-10-10 22:01:25 +08:00
parent 3335da00ae
commit 7fff27f036

View File

@@ -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; i<cnt; i++)
t[i] = trans;
pcShapeMaterial->transparency.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<App::Color>& 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;
}
}