[Bf-blender-cvs] [8c28a9906e1] sculpt-dev: Sculpt: try to fix NaN bug

Joseph Eagar noreply at git.blender.org
Fri Oct 15 00:20:28 CEST 2021


Commit: 8c28a9906e19a15d5dfb68403b84af034f5463d0
Author: Joseph Eagar
Date:   Wed Oct 13 22:05:11 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB8c28a9906e19a15d5dfb68403b84af034f5463d0

Sculpt: try to fix NaN bug

===================================================================

M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c

===================================================================

diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index ce668ba8a11..d5d356c29d4 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -1200,6 +1200,9 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
   if (setup_ui) {
     BKE_brush_channelset_ui_init(brush, tool);
   }
+
+  BKE_brush_channelset_check_radius(chset);
+
   namestack_pop();
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index 18070197d04..66835ae7124 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -74,6 +74,20 @@
 #include <math.h>
 #include <stdlib.h>
 
+#include "BLI_compiler_compat.h"
+#include "BLI_utildefines.h"
+
+MINLINE float safe_shell_angle_to_dist(const float angle)
+{
+  float th = cosf(angle);
+
+  if (th == 0.0f) {
+    return 10.0f;
+  }
+
+  return (UNLIKELY(angle < 1.e-8f)) ? 1.0f : fabsf(1.0f / th);
+}
+
 void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
                                              float result[3],
                                              SculptVertRef vertex,
@@ -317,7 +331,7 @@ void SCULPT_neighbor_coords_average_interior(SculptSession *ss,
       /*ok this bit smoothes the bevel edges.  why? hit on it
         by accident.*/
       float shellth = saacos(dot_v3v3(no, no2));
-      shellth = shell_angle_to_dist(shellth * 2.0);
+      shellth = safe_shell_angle_to_dist(shellth * 2.0);
       th /= 0.00001 + shellth;
 
       sub_v3_v3v3(tmp, co2, co);



More information about the Bf-blender-cvs mailing list