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:
wmayer
2024-04-08 18:04:53 +02:00
parent 8cba167241
commit af317be718
3 changed files with 9 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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);
}