Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2022-07-15 16:54:14 +0300
committerSergey Sharybin <sergey@blender.org>2022-07-15 17:30:11 +0300
commit5e1229f25387a90fe626b4b2ac34f2eb5c7dc23a (patch)
tree47ad2aacd0865a51b285e708394d3f7f32be6882
parent82f65d8971ea2def50ab6cd6031793207cc45168 (diff)
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
-rw-r--r--source/blender/blenkernel/BKE_modifier.h12
-rw-r--r--source/blender/blenkernel/intern/modifier.c34
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c10
3 files changed, 51 insertions, 5 deletions
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