Part: Fix alpha <> transparency conversion

This commit is contained in:
wmayer
2024-11-16 12:37:32 +01:00
committed by Chris Hennes
parent e3f6fc5708
commit c32628ec0d
4 changed files with 45 additions and 47 deletions

View File

@@ -52,11 +52,10 @@ PyObject* ViewProviderPartExtPy::getCustomAttributes(const char* attr) const
// Get the color properties
App::PropertyColorList prop;
// v0.21 used the alpha channel to store transparency values
std::vector<App::Color> colors = vp->ShapeAppearance.getDiffuseColors();
std::vector<float> transparencies = vp->ShapeAppearance.getTransparencies();
for (int i = 0; i < static_cast<int>(colors.size()); i++) {
colors[i].a = transparencies[i];
colors[i].setTransparency(transparencies[i]);
}
prop.setValues(colors);
@@ -73,13 +72,12 @@ int ViewProviderPartExtPy::setCustomAttributes(const char* attr, PyObject* obj)
App::PropertyColorList prop;
prop.setPyObject(obj);
// v0.21 used the alpha channel to store transparency values
std::vector<App::Color> colors = prop.getValues();
std::vector<float> transparencies;
transparencies.resize(static_cast<int>(colors.size()));
for (int i = 0; i < static_cast<int>(colors.size()); i++) {
transparencies[i] = colors[i].a;
colors[i].a = 1.0;
transparencies[i] = colors[i].transparency();
colors[i].a = 1.0F;
}
vp->ShapeAppearance.setDiffuseColors(colors);
vp->ShapeAppearance.setTransparencies(transparencies);