From 970598ea318aa4b2a0b7cf2da34d0b59894e2b60 Mon Sep 17 00:00:00 2001 From: ExPikaPaka Date: Wed, 23 Sep 2026 18:01:46 +0200 Subject: [PATCH] Give an empty patch an upright frame texture_displacement_patch_frame picks the world axis least aligned with the patch's average normal. With no patch there is no normal either, and the axis came out of the +Z fallback for it - so it was +X, while its test asked for the upright frame the fallback is meant to give. An empty patch now answers +Z outright. --- src/libslic3r/TextureDisplacement.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libslic3r/TextureDisplacement.cpp b/src/libslic3r/TextureDisplacement.cpp index 00a66271cd..f3f902e821 100644 --- a/src/libslic3r/TextureDisplacement.cpp +++ b/src/libslic3r/TextureDisplacement.cpp @@ -2890,6 +2890,12 @@ void texture_displacement_patch_frame(const indexed_triangle_set &patch, const s } average_normal = (normal_sum.norm() > 1e-8f) ? Vec3f(normal_sum.normalized()) : Vec3f::UnitZ(); center = (count > 0) ? Vec3f(centroid_sum / float(count)) : Vec3f::Zero(); + if (count == 0) { + // Nothing to measure: an upright cylinder about the origin, rather than the axis least aligned + // with a normal that is itself only a fallback. + axis = Vec3f::UnitZ(); + return; + } // The world axis least aligned with the average normal - perpendicular to the outward radial // normal, as a cylinder's own axis would be.