[Bf-blender-cvs] [5e1229f2538] master: Fix overly noisy surface deform warning message

Sergey Sharybin noreply at git.blender.org
Fri Jul 15 16:29:31 CEST 2022


Commit: 5e1229f25387a90fe626b4b2ac34f2eb5c7dc23a
Author: Sergey Sharybin
Date:   Fri Jul 15 15:54:14 2022 +0200
Branches: master
https://developer.blender.org/rB5e1229f25387a90fe626b4b2ac34f2eb5c7dc23a

Fix overly noisy surface deform warning message

An increased number of vertices is not a stopper for the surface
deform modifier anymore. It might still be useful to expose the
message in the UI, but printing error message to the console on
every modifier evaluation makes real errors to become almost
invisible.

Differential Revision: https://developer.blender.org/D15468

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

M	source/blender/blenkernel/BKE_modifier.h
M	source/blender/blenkernel/intern/modifier.c
M	source/blender/modifiers/intern/MOD_surfacedeform.c

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

diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 866b0353d07..46d609f9aa3 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -446,10 +446,22 @@ bool BKE_modifier_is_enabled(const struct Scene *scene,
  */
 bool BKE_modifier_is_nonlocal_in_liboverride(const struct Object *ob,
                                              const struct ModifierData *md);
+
+/* Set modifier execution error.
+ * The message will be shown in the interface and will be logged as an error to the console. */
 void BKE_modifier_set_error(const struct Object *ob,
                             struct ModifierData *md,
                             const char *format,
                             ...) ATTR_PRINTF_FORMAT(3, 4);
+
+/* Set modifier execution warning, which does not prevent the modifier from being applied but which
+ * might need an attention. The message will only be shown in the interface, but will not appear in
+ * the logs. */
+void BKE_modifier_set_warning(const struct Object *ob,
+                              struct ModifierData *md,
+                              const char *format,
+                              ...) ATTR_PRINTF_FORMAT(3, 4);
+
 bool BKE_modifier_is_preview(struct ModifierData *md);
 
 void BKE_modifiers_foreach_ID_link(struct Object *ob, IDWalkFunc walk, void *userData);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 6348d83362e..831ea084961 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -456,6 +456,40 @@ void BKE_modifier_set_error(const Object *ob, ModifierData *md, const char *_for
   CLOG_ERROR(&LOG, "Object: \"%s\", Modifier: \"%s\", %s", ob->id.name + 2, md->name, md->error);
 }
 
+void BKE_modifier_set_warning(const struct Object *ob,
+                              struct ModifierData *md,
+                              const char *_format,
+                              ...)
+{
+  char buffer[512];
+  va_list ap;
+  const char *format = TIP_(_format);
+
+  va_start(ap, _format);
+  vsnprintf(buffer, sizeof(buffer), format, ap);
+  va_end(ap);
+  buffer[sizeof(buffer) - 1] = '\0';
+
+  /* Store the warning in the same field as the error.
+   * It is not expected to have both error and warning and having a single place to store the
+   * message simplifies interface code. */
+
+  if (md->error) {
+    MEM_freeN(md->error);
+  }
+
+  md->error = BLI_strdup(buffer);
+
+#ifndef NDEBUG
+  if ((md->mode & eModifierMode_Virtual) == 0) {
+    /* Ensure correct object is passed in. */
+    BLI_assert(BKE_modifier_get_original(ob, md) != NULL);
+  }
+#endif
+
+  UNUSED_VARS_NDEBUG(ob);
+}
+
 int BKE_modifiers_get_cage_index(const Scene *scene,
                                  Object *ob,
                                  int *r_lastPossibleCageIndex,
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index d63ef12285b..edc6819a26c 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1521,11 +1521,11 @@ static void surfacedeformModifier_do(ModifierData *md,
      * added after the original ones. This covers typical case when target was at the subdivision
      * level 0 and then subdivision was increased (i.e. for the render purposes). */
 
-    BKE_modifier_set_error(ob,
-                           md,
-                           "Target vertices changed from %u to %u, continuing anyway",
-                           smd->target_verts_num,
-                           target_verts_num);
+    BKE_modifier_set_warning(ob,
+                             md,
+                             "Target vertices changed from %u to %u, continuing anyway",
+                             smd->target_verts_num,
+                             target_verts_num);
 
     /* In theory we only need the `smd->verts_num` vertices in the `targetCos` for evaluation, but
      * it is not currently possible to request a subset of coordinates: the API expects that the



More information about the Bf-blender-cvs mailing list