[Bf-blender-cvs] [71db02ed887] blender-v2.93-release: Fix: geometry nodes logs incorrect preview data

Jacques Lucke noreply at git.blender.org
Thu Apr 22 12:49:09 CEST 2021


Commit: 71db02ed887d8b9db958b482aa42cc27f0e57ed2
Author: Jacques Lucke
Date:   Thu Apr 22 12:48:59 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB71db02ed887d8b9db958b482aa42cc27f0e57ed2

Fix: geometry nodes logs incorrect preview data

Under some circumstances, modifiers are evaluated more than once.
One time to compute the actual output geometry and another time
with `MOD_APPLY_ORCO`. This design probably has to be revisited
at some point in the context of geometry nodes. However, that would
be much more involved than a bug fix.

The issue was that during the second evaluation, the node tree is
evaluated based on a slightly different input geometry. The data
generated during the second evaluation overwrote the cached
data from the first evaluation, resulting in incorrect data that is
shown in the spreadsheet.

The fix for now is to simply not log any data in the second evaluation.

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

M	source/blender/modifiers/intern/MOD_nodes.cc

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

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 53b79d0b2a5..57de629fc18 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -271,6 +271,17 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
   return false;
 }
 
+static bool logging_enabled(const ModifierEvalContext *ctx)
+{
+  if (!DEG_is_active(ctx->depsgraph)) {
+    return false;
+  }
+  if ((ctx->flag & MOD_APPLY_ORCO) != 0) {
+    return false;
+  }
+  return true;
+}
+
 class GeometryNodesEvaluator {
  public:
   using LogSocketValueFn = std::function<void(DSocket, Span<GPointer>)>;
@@ -1290,7 +1301,7 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree,
   find_sockets_to_preview(nmd, ctx, tree, preview_sockets);
 
   auto log_socket_value = [&](const DSocket socket, const Span<GPointer> values) {
-    if (!DEG_is_active(ctx->depsgraph)) {
+    if (!logging_enabled(ctx)) {
       return;
     }
     Span<uint64_t> keys = preview_sockets.lookup(socket);
@@ -1401,7 +1412,7 @@ static void modifyGeometry(ModifierData *md,
     return;
   }
 
-  if (DEG_is_active(ctx->depsgraph)) {
+  if (logging_enabled(ctx)) {
     reset_tree_ui_storage(tree.used_node_tree_refs(), *ctx->object, *md);
   }



More information about the Bf-blender-cvs mailing list