diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-11 14:05:20 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-11 14:05:20 +0300 |
commit | 4e78b89e487e9b9707d583c6b2578ad122c59d5e (patch) | |
tree | 620c9d0e0114488328cc55187dadfdb4f8a05754 /source/blender/modifiers | |
parent | 166c8be7ac018c461514453b9947a23b7ac2ef26 (diff) |
Geometry Nodes: add field support for socket inspection
Since fields were committed to master, socket inspection did
not work correctly for all socket types anymore. Now the same
functionality as before is back. Furthermore, fields that depend
on some input will now show the inputs in the socket inspection.
I added support for evaluating constant fields more immediately.
This has the benefit that the same constant field is not evaluated
more than once. It also helps with making the field independent
of the multi-functions that it uses. We might still want to change
the ownership handling for the multi-functions of nodes a bit,
but that can be done separately.
Differential Revision: https://developer.blender.org/D12444
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes_evaluator.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index 4f21924619b..f67f7f967c9 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -892,8 +892,10 @@ class GeometryNodesEvaluator { OutputState &output_state = node_state.outputs[i]; const DOutputSocket socket{node.context(), &socket_ref}; const CPPType *cpp_type = get_socket_cpp_type(socket_ref); - GField &field = *allocator.construct<GField>(operation, output_index).release(); - this->forward_output(socket, {cpp_type, &field}); + GField new_field{operation, output_index}; + new_field = fn::make_field_constant_if_possible(std::move(new_field)); + GField &field_to_forward = *allocator.construct<GField>(std::move(new_field)).release(); + this->forward_output(socket, {cpp_type, &field_to_forward}); output_state.has_been_computed = true; output_index++; } @@ -1411,8 +1413,8 @@ class GeometryNodesEvaluator { { if (const FieldCPPType *field_cpp_type = dynamic_cast<const FieldCPPType *>(&type)) { const CPPType &base_type = field_cpp_type->field_type(); - auto constant_fn = std::make_unique<fn::CustomMF_GenericConstant>(base_type, - base_type.default_value()); + auto constant_fn = std::make_unique<fn::CustomMF_GenericConstant>( + base_type, base_type.default_value(), false); auto operation = std::make_shared<fn::FieldOperation>(std::move(constant_fn)); new (r_value) GField(std::move(operation), 0); return; |