From 9711efece75aebf64cfda248b744357b946fe89c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 28 Jun 2025 00:03:45 +0200 Subject: [PATCH] Fix #141085: Cycles adaptive subdivision crash with zero length edges As produced by booleans in the reported blend file. Pull Request: https://projects.blender.org/blender/blender/pulls/141105 --- intern/cycles/subd/split.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/intern/cycles/subd/split.cpp b/intern/cycles/subd/split.cpp index 8e94d910fa9..7b9776f6858 100644 --- a/intern/cycles/subd/split.cpp +++ b/intern/cycles/subd/split.cpp @@ -593,11 +593,14 @@ void DiagSplit::split_triangle(SubPatch &&sub) * platforms rather than choice being decided by precision. */ const float bias = 1.00012345f; - /* Pick longest edge that must be split. */ - float max_length = 0; - int split_index_0 = 0; + /* Pick longest edge that must be split. Note that in degenerate cases edges may have + * zero length but still requires splitting at depth 0. */ + float max_length = 0.0f; + int split_index_0 = -1; for (int i = 0; i < 3; i++) { - if (sub.edges[i].edge->must_split() && sub.edges[i].edge->length > max_length) { + if (sub.edges[i].edge->must_split() && + (split_index_0 == -1 || sub.edges[i].edge->length > max_length)) + { split_index_0 = i; max_length = sub.edges[i].edge->length * bias; }