Materials: Set transparency from DiffuseColor
Migrate the transparency from the DiffuseColor alpha channel to the transparency color attribute. This allows the alpha channel to be used as designed fixes #14938
This commit is contained in:
committed by
Chris Hennes
parent
4e45d3b408
commit
5bc0684ecd
@@ -3018,6 +3018,17 @@ void PropertyMaterialList::setTransparency(int index, float val)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setTransparencies(const std::vector<float>& transparencies)
|
||||
{
|
||||
aboutToSetValue();
|
||||
setSize(transparencies.size(), _lValueList[0]);
|
||||
|
||||
for (std::size_t i = 0; i < transparencies.size(); i++) {
|
||||
_lValueList[i].transparency = transparencies[i];
|
||||
}
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getAmbientColor() const
|
||||
{
|
||||
return _lValueList[0].ambientColor;
|
||||
|
||||
@@ -1156,6 +1156,7 @@ public:
|
||||
|
||||
void setTransparency(float);
|
||||
void setTransparency(int index, float);
|
||||
void setTransparencies(const std::vector<float>& transparencies);
|
||||
|
||||
const Color& getAmbientColor() const;
|
||||
const Color& getAmbientColor(int index) const;
|
||||
|
||||
@@ -341,8 +341,17 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
}
|
||||
else if (prop == &_diffuseColor) {
|
||||
// Used to load the old DiffuseColor values asynchronously
|
||||
ShapeAppearance.setDiffuseColors(_diffuseColor.getValues());
|
||||
ShapeAppearance.setTransparency(Transparency.getValue() / 100.0F);
|
||||
// v0.21 used the alpha channel to store transparency values
|
||||
std::vector<App::Color> colors = _diffuseColor.getValues();
|
||||
std::vector<float> transparencies;
|
||||
transparencies.resize(static_cast<int>(colors.size()));
|
||||
for (int i = 0; i < static_cast<int>(colors.size()); i++) {
|
||||
Base::Console().Log("%d: %f\n", i, colors[i].a);
|
||||
transparencies[i] = colors[i].a;
|
||||
colors[i].a = 1.0;
|
||||
}
|
||||
ShapeAppearance.setDiffuseColors(colors);
|
||||
ShapeAppearance.setTransparencies(transparencies);
|
||||
}
|
||||
else if (prop == &ShapeAppearance) {
|
||||
setHighlightedFaces(ShapeAppearance);
|
||||
|
||||
Reference in New Issue
Block a user