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.
This commit is contained in:
Hans Goudey 2022-12-01 16:30:46 -06:00
parent 3059f1743e
commit 97df619be7
2 changed files with 9 additions and 14 deletions

View File

@ -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());

View File

@ -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);