Core: avoid conversion from float to double or vice-versa
When synchronizing the Transparency property with the transparency value of the ShapeAppearance property then do not convert between float and double as otherwise some strange rounding issues can occur. Example: Set the Transparency property of an object to 35 in the Property Editor. After leaving the editor the value may switch to 34.
This commit is contained in:
@@ -3033,22 +3033,22 @@ const Color& PropertyMaterialList::getEmissiveColor(int index) const
|
||||
return _lValueList[index].emissiveColor;
|
||||
}
|
||||
|
||||
double PropertyMaterialList::getShininess() const
|
||||
float PropertyMaterialList::getShininess() const
|
||||
{
|
||||
return _lValueList[0].transparency;
|
||||
}
|
||||
|
||||
double PropertyMaterialList::getShininess(int index) const
|
||||
float PropertyMaterialList::getShininess(int index) const
|
||||
{
|
||||
return _lValueList[index].transparency;
|
||||
}
|
||||
|
||||
double PropertyMaterialList::getTransparency() const
|
||||
float PropertyMaterialList::getTransparency() const
|
||||
{
|
||||
return _lValueList[0].transparency;
|
||||
}
|
||||
|
||||
double PropertyMaterialList::getTransparency(int index) const
|
||||
float PropertyMaterialList::getTransparency(int index) const
|
||||
{
|
||||
return _lValueList[index].transparency;
|
||||
}
|
||||
|
||||
@@ -1166,11 +1166,11 @@ public:
|
||||
const Color& getEmissiveColor() const;
|
||||
const Color& getEmissiveColor(int index) const;
|
||||
|
||||
double getShininess() const;
|
||||
double getShininess(int index) const;
|
||||
float getShininess() const;
|
||||
float getShininess(int index) const;
|
||||
|
||||
double getTransparency() const;
|
||||
double getTransparency(int index) const;
|
||||
float getTransparency() const;
|
||||
float getTransparency(int index) const;
|
||||
|
||||
PyObject* getPyObject() override;
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ void ViewProviderGeometryObject::onChanged(const App::Property* prop)
|
||||
getObject()->touch(true);
|
||||
}
|
||||
const App::Material& Mat = ShapeAppearance[0];
|
||||
long value = (long)(100.0 * ShapeAppearance.getTransparency() + 0.5);
|
||||
long value = (long)(100.0 * ShapeAppearance.getTransparency());
|
||||
if (value != Transparency.getValue()) {
|
||||
Transparency.setValue(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user