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:
authorJacques Lucke <jacques@blender.org>2021-11-26 20:00:52 +0300
committerJacques Lucke <jacques@blender.org>2021-11-26 20:01:59 +0300
commit97465046c6bb43647a34d9fbbf33b784c0c2604d (patch)
treed1c597d5d63f86e1b0c030c04cc7b9057112a6d4 /source/blender/modifiers
parent92daff6ac2adb5bb8c42933063e42fa77823c61f (diff)
Geometry Nodes: add utility to set remaining outputs
Differential Revision: https://developer.blender.org/D13384
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_nodes_evaluator.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
index 33a5da7ccb7..5a8575424c8 100644
--- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
+++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
@@ -416,6 +416,8 @@ class NodeParamsProvider : public nodes::GeoNodeExecParamsProvider {
bool lazy_require_input(StringRef identifier) override;
bool lazy_output_is_required(StringRef identifier) const override;
+
+ void set_default_remaining_outputs();
};
class GeometryNodesEvaluator {
@@ -1371,6 +1373,7 @@ class GeometryNodesEvaluator {
/**
* Moves a newly computed value from an output socket to all the inputs that might need it.
+ * Takes ownership of the value and destructs if it is unused.
*/
void forward_output(const DOutputSocket from_socket,
GMutablePointer value_to_forward,
@@ -1891,6 +1894,29 @@ bool NodeParamsProvider::lazy_output_is_required(StringRef identifier) const
return output_state.output_usage_for_execution == ValueUsage::Required;
}
+void NodeParamsProvider::set_default_remaining_outputs()
+{
+ LinearAllocator<> &allocator = evaluator_.local_allocators_.local();
+
+ for (const int i : this->dnode->outputs().index_range()) {
+ OutputState &output_state = node_state_.outputs[i];
+ if (output_state.has_been_computed) {
+ continue;
+ }
+ if (output_state.output_usage_for_execution == ValueUsage::Unused) {
+ continue;
+ }
+
+ const DOutputSocket socket = this->dnode.output(i);
+ const CPPType *type = get_socket_cpp_type(socket);
+ BLI_assert(type != nullptr);
+ void *buffer = allocator.allocate(type->size(), type->alignment());
+ type->copy_construct(type->default_value(), buffer);
+ evaluator_.forward_output(socket, {type, buffer}, run_state_);
+ output_state.has_been_computed = true;
+ }
+}
+
void evaluate_geometry_nodes(GeometryNodesEvaluationParams &params)
{
GeometryNodesEvaluator evaluator{params};