diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-22 16:15:03 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-22 16:15:03 +0300 |
commit | dd5131bd700c7eae9772b54de1640ef15edff28f (patch) | |
tree | dd99c58c66ff30392ae75890e17e8ef469c12ab3 /source/blender/nodes/geometry | |
parent | dc06bf2cb6b1289cdb90b960b8f125f99e57946b (diff) |
Geometry Nodes: Add Self Object Node
From the nodes' description: "Retrieve the object that contains
the geometry nodes modifier currently being executed". This was
discussed in the most recent geometry nodes module meeting.
Because the node allows you to retrieve the position of the modifier
object, it has to add a depsgraph relation to object transform.
Expect that modifiers will be reevaluated when moving the object.
In the future, better static analysis of node trees could make this
check smarter.
Differential Revision: https://developer.blender.org/D16037
Diffstat (limited to 'source/blender/nodes/geometry')
-rw-r--r-- | source/blender/nodes/geometry/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_self_object.cc | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/nodes/geometry/CMakeLists.txt b/source/blender/nodes/geometry/CMakeLists.txt index ce285488109..f15152fe1c4 100644 --- a/source/blender/nodes/geometry/CMakeLists.txt +++ b/source/blender/nodes/geometry/CMakeLists.txt @@ -132,6 +132,7 @@ set(SRC nodes/node_geo_scale_instances.cc nodes/node_geo_separate_components.cc nodes/node_geo_separate_geometry.cc + nodes/node_geo_self_object.cc nodes/node_geo_set_curve_handles.cc nodes/node_geo_set_curve_radius.cc nodes/node_geo_set_curve_tilt.cc diff --git a/source/blender/nodes/geometry/nodes/node_geo_self_object.cc b/source/blender/nodes/geometry/nodes/node_geo_self_object.cc new file mode 100644 index 00000000000..7b33afdb4a0 --- /dev/null +++ b/source/blender/nodes/geometry/nodes/node_geo_self_object.cc @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "node_geometry_util.hh" + +namespace blender::nodes::node_geo_self_object_cc { + +static void node_declare(NodeDeclarationBuilder &b) +{ + b.add_output<decl::Object>(N_("Self Object")); +} + +static void node_geo_exec(GeoNodeExecParams params) +{ + params.set_output("Self Object", const_cast<Object *>(params.self_object())); +} + +} // namespace blender::nodes::node_geo_self_object_cc + +void register_node_type_geo_self_object() +{ + namespace file_ns = blender::nodes::node_geo_self_object_cc; + + static bNodeType ntype; + + geo_node_type_base(&ntype, GEO_NODE_SELF_OBJECT, "Self Object", NODE_CLASS_INPUT); + ntype.geometry_node_execute = file_ns::node_geo_exec; + ntype.declare = file_ns::node_declare; + nodeRegisterType(&ntype); +} |