@@ -650,14 +650,30 @@ std::string editor::Properties::replaceNumberedBrackets(const std::string& input
650650 return result;
651651}
652652
653- Vector3 editor::Properties::roundZero (const Vector3& val, const float threshold){
653+ Vector3 editor::Properties::roundZero (const Vector3& val, const float threshold) const {
654654 return Vector3 (
655655 (fabs (val.x ) < threshold) ? 0 .0f : val.x ,
656656 (fabs (val.y ) < threshold) ? 0 .0f : val.y ,
657657 (fabs (val.z ) < threshold) ? 0 .0f : val.z
658658 );
659659}
660660
661+ float editor::Properties::snapDisplayedAngle (float angle, float threshold) const {
662+ float rounded = std::round (angle);
663+ return (std::fabs (angle - rounded) <= threshold) ? rounded : angle;
664+ }
665+
666+ Vector3 editor::Properties::getDisplayedEulerAngles (const Quaternion& value, const RotationOrder& order, float zeroThreshold) const {
667+ constexpr float displaySnapThreshold = 0 .05f ;
668+
669+ Vector3 euler = roundZero (Quaternion (value).normalize ().getEulerAngles (order), zeroThreshold);
670+ euler.x = snapDisplayedAngle (euler.x , displaySnapThreshold);
671+ euler.y = snapDisplayedAngle (euler.y , displaySnapThreshold);
672+ euler.z = snapDisplayedAngle (euler.z , displaySnapThreshold);
673+
674+ return euler;
675+ }
676+
661677bool editor::Properties::compareVectorFloat (const float * a, const float * b, size_t elements, const float threshold){
662678 for (size_t i = 0 ; i < elements; ++i) {
663679 if (fabs (a[i] - b[i]) > threshold) {
@@ -2053,7 +2069,7 @@ bool editor::Properties::propertyRow(RowPropertyType type, ComponentType cpType,
20532069 PropertyData prop = Catalog::getProperty (sceneProject->scene , entity, cpType, id);
20542070 defArr = static_cast <float *>(prop.def );
20552071 qValue = *static_cast <Quaternion*>(prop.ref );
2056- eValue[entity] = roundZero ( Quaternion ( qValue). normalize (). getEulerAngles ( order) , zeroThreshold);
2072+ eValue[entity] = getDisplayedEulerAngles ( qValue, order, zeroThreshold);
20572073 if (value){
20582074 if (std::fabs (value->x - eValue[entity].x ) > compThreshold)
20592075 difX = true ;
0 commit comments