[Bf-blender-cvs] [97df619be73] geometry-nodes-simulation: Move "Run" input to simulation output node

Hans Goudey noreply at git.blender.org
Thu Dec 1 23:35:00 CET 2022


Commit: 97df619be73478a356ebecf91bb0b391f9cd5064
Author: Hans Goudey
Date:   Thu Dec 1 16:30:46 2022 -0600
Branches: geometry-nodes-simulation
https://developer.blender.org/rB97df619be73478a356ebecf91bb0b391f9cd5064

Move "Run" input to simulation output node

It's the output node that decides whether to requiest the values
from the nodes inside the simulation, so it makes more sense
for it to be there. This is part of a general effort to have less
redundancy in the options.

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

M	source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
M	source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
index 2cd240570a7..3e1330b44b0 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc
@@ -13,7 +13,6 @@ NODE_STORAGE_FUNCS(NodeGeometrySimulationInput);
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
-  b.add_input<decl::Bool>(N_("Run"));
   b.add_input<decl::Geometry>(N_("Geometry"));
 
   b.add_output<decl::Float>(N_("Delta Time"));
@@ -35,9 +34,6 @@ static void node_geo_exec(GeoNodeExecParams params)
   const float scene_ctime = BKE_scene_ctime_get(scene);
   const int scene_frame = int(scene_ctime);
 
-  /* TODO: Somehow use "Run" input. We also need to pass through the simulation state directly to
-   * the output node on the first frame the "Run" input is true. */
-
   const GeoNodesLFUserData &lf_data = *params.user_data();
   bke::ComputeCaches &all_caches = *lf_data.modifier_data->cache_per_frame;
   const bke::SimulationCache *cache = all_caches.lookup_context(lf_data.compute_context->hash());
diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc
index a72d1f31983..f11100f0eac 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc
@@ -16,7 +16,7 @@ NODE_STORAGE_FUNCS(NodeGeometrySimulationOutput);
 
 static void node_declare(NodeDeclarationBuilder &b)
 {
-  b.add_input<decl::Bool>(N_("Stop"));
+  b.add_input<decl::Bool>(N_("Run"));
   b.add_input<decl::Geometry>(N_("Geometry"));
   b.add_output<decl::Bool>(N_("Started"));
   b.add_output<decl::Bool>(N_("Ended"));
@@ -38,7 +38,7 @@ static void node_init(bNodeTree * /*tree*/, bNode *node)
 
 static void node_geo_exec(GeoNodeExecParams params)
 {
-  if (params.lazy_require_input("Stop")) {
+  if (params.lazy_require_input("Run")) {
     return;
   }
 
@@ -51,7 +51,6 @@ static void node_geo_exec(GeoNodeExecParams params)
   bke::ComputeCaches &all_caches = *lf_data.modifier_data->cache_per_frame;
   bke::SimulationCache &cache = all_caches.ensure_for_context(lf_data.compute_context->hash());
 
-  /* TODO: Retrieve "started" from "run" socket on simulation input node? */
   if (cache.geometry_per_frame.is_empty()) {
     if (params.lazy_output_is_required("Started")) {
       params.set_output("Started", false);
@@ -66,8 +65,13 @@ static void node_geo_exec(GeoNodeExecParams params)
     }
   }
 
-  const bool stop = params.get_input<bool>("Stop");
-  if (stop) {
+  const bool run = params.get_input<bool>("Run");
+  if (run) {
+    if (params.lazy_output_is_required("Ended")) {
+      params.set_output("Ended", false);
+    }
+  }
+  else {
     if (params.lazy_output_is_required("Ended")) {
       params.set_output("Ended", true);
     }
@@ -77,11 +81,6 @@ static void node_geo_exec(GeoNodeExecParams params)
       return;
     }
   }
-  else {
-    if (params.lazy_output_is_required("Ended")) {
-      params.set_output("Ended", false);
-    }
-  }
 
   if (const bke::GeometryCacheValue *data = cache.value_at_time(scene_frame)) {
     params.set_output("Geometry", data->geometry_set);



More information about the Bf-blender-cvs mailing list