Gui: Do not round color values set in property editor
Do not use the number of decimals from the user settings to pass the material to the property as this will cause some unexpected rounding effects. This fixes issue 19048
This commit is contained in:
@@ -3752,37 +3752,33 @@ void PropertyMaterialItem::setValue(const QVariant& value)
|
||||
auto mat = value.value<Material>();
|
||||
Base::Color dc;
|
||||
dc.setValue<QColor>(mat.diffuseColor);
|
||||
uint32_t dcp = dc.getPackedValue();
|
||||
Base::Color ac;
|
||||
ac.setValue<QColor>(mat.ambientColor);
|
||||
uint32_t acp = ac.getPackedValue();
|
||||
Base::Color sc;
|
||||
sc.setValue<QColor>(mat.specularColor);
|
||||
uint32_t scp = sc.getPackedValue();
|
||||
Base::Color ec;
|
||||
ec.setValue<QColor>(mat.emissiveColor);
|
||||
uint32_t ecp = ec.getPackedValue();
|
||||
float s = mat.shininess;
|
||||
float t = mat.transparency;
|
||||
|
||||
QString data = QStringLiteral("App.Material("
|
||||
"DiffuseColor=(%1,%2,%3),"
|
||||
"AmbientColor=(%4,%5,%6),"
|
||||
"SpecularColor=(%7,%8,%9),"
|
||||
"EmissiveColor=(%10,%11,%12),"
|
||||
"Shininess=(%13),"
|
||||
"Transparency=(%14),"
|
||||
")")
|
||||
.arg(dc.r, 0, 'f', decimals())
|
||||
.arg(dc.g, 0, 'f', decimals())
|
||||
.arg(dc.b, 0, 'f', decimals())
|
||||
.arg(ac.r, 0, 'f', decimals())
|
||||
.arg(ac.g, 0, 'f', decimals())
|
||||
.arg(ac.b, 0, 'f', decimals())
|
||||
.arg(sc.r, 0, 'f', decimals())
|
||||
.arg(sc.g, 0, 'f', decimals())
|
||||
.arg(sc.b, 0, 'f', decimals())
|
||||
.arg(ec.r, 0, 'f', decimals())
|
||||
.arg(ec.g, 0, 'f', decimals())
|
||||
.arg(ec.b, 0, 'f', decimals())
|
||||
.arg(s, 0, 'f', decimals())
|
||||
.arg(t, 0, 'f', decimals());
|
||||
"DiffuseColor = %1,"
|
||||
"AmbientColor = %2,"
|
||||
"SpecularColor = %3,"
|
||||
"EmissiveColor = %4,"
|
||||
"Shininess = %5,"
|
||||
"Transparency = %6,"
|
||||
")")
|
||||
.arg(dcp)
|
||||
.arg(acp)
|
||||
.arg(scp)
|
||||
.arg(ecp)
|
||||
.arg(s, 0, 'f', 10)
|
||||
.arg(t, 0, 'f', 10);
|
||||
|
||||
setPropertyValue(data);
|
||||
}
|
||||
@@ -4258,37 +4254,33 @@ void PropertyMaterialListItem::setValue(const QVariant& value)
|
||||
auto mat = list[0].value<Material>();
|
||||
Base::Color dc;
|
||||
dc.setValue<QColor>(mat.diffuseColor);
|
||||
uint32_t dcp = dc.getPackedValue();
|
||||
Base::Color ac;
|
||||
ac.setValue<QColor>(mat.ambientColor);
|
||||
uint32_t acp = ac.getPackedValue();
|
||||
Base::Color sc;
|
||||
sc.setValue<QColor>(mat.specularColor);
|
||||
uint32_t scp = sc.getPackedValue();
|
||||
Base::Color ec;
|
||||
ec.setValue<QColor>(mat.emissiveColor);
|
||||
uint32_t ecp = ec.getPackedValue();
|
||||
float s = mat.shininess;
|
||||
float t = mat.transparency;
|
||||
|
||||
QString item = QStringLiteral("App.Material("
|
||||
"DiffuseColor=(%1,%2,%3),"
|
||||
"AmbientColor=(%4,%5,%6),"
|
||||
"SpecularColor=(%7,%8,%9),"
|
||||
"EmissiveColor=(%10,%11,%12),"
|
||||
"Shininess=(%13),"
|
||||
"Transparency=(%14),"
|
||||
")")
|
||||
.arg(dc.r, 0, 'f', decimals())
|
||||
.arg(dc.g, 0, 'f', decimals())
|
||||
.arg(dc.b, 0, 'f', decimals())
|
||||
.arg(ac.r, 0, 'f', decimals())
|
||||
.arg(ac.g, 0, 'f', decimals())
|
||||
.arg(ac.b, 0, 'f', decimals())
|
||||
.arg(sc.r, 0, 'f', decimals())
|
||||
.arg(sc.g, 0, 'f', decimals())
|
||||
.arg(sc.b, 0, 'f', decimals())
|
||||
.arg(ec.r, 0, 'f', decimals())
|
||||
.arg(ec.g, 0, 'f', decimals())
|
||||
.arg(ec.b, 0, 'f', decimals())
|
||||
.arg(s, 0, 'f', decimals())
|
||||
.arg(t, 0, 'f', decimals());
|
||||
"DiffuseColor = %1,"
|
||||
"AmbientColor = %2,"
|
||||
"SpecularColor = %3,"
|
||||
"EmissiveColor = %4,"
|
||||
"Shininess = %5,"
|
||||
"Transparency = %6,"
|
||||
")")
|
||||
.arg(dcp)
|
||||
.arg(acp)
|
||||
.arg(scp)
|
||||
.arg(ecp)
|
||||
.arg(s, 0, 'f', 10)
|
||||
.arg(t, 0, 'f', 10);
|
||||
str << item << ")";
|
||||
|
||||
setPropertyValue(data);
|
||||
|
||||
Reference in New Issue
Block a user