Fix #104513: UV packing produces different results on x86 vs apple silicon
During uv unwrapping and uv packing, certain floating point algorithms
have extreme sensitivity to round-off errors. These can produce very
different layouts even when given inputs which are only slightly different.
The root cause is that the two main types of CPUs used to run Blender,
namely x86 and Apple Silicon, produce slightly different results on some
math functions, including `sinf()`, `cosf()` and `atan2f()`.
* sinf(0.8960554599761962890625) = 0.780868828296661376953125 (Intel i7)
* sinf(0.8960554599761962890625) = 0.78086888790130615234375 (Apple M1)
This fix, and others that came before it [0], improve accuracy by using
double-precision to hide the differences between the CPUs.
[0] e.g. 0eba9e41bf
[1] See also #107829
This commit is contained in:
@@ -251,7 +251,7 @@ static float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], int
|
||||
i_prev = i;
|
||||
}
|
||||
|
||||
return (area_best != FLT_MAX) ? atan2f(dvec_best[0], dvec_best[1]) : 0.0f;
|
||||
return (area_best != FLT_MAX) ? (float)atan2(dvec_best[0], dvec_best[1]) : 0.0f;
|
||||
}
|
||||
|
||||
float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int n)
|
||||
|
||||
Reference in New Issue
Block a user