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
This commit is contained in:
parent
dc06bf2cb6
commit
dd5131bd70
Notes:
blender-bot
2023-02-13 11:50:45 +01:00
Referenced by commit 837144b457
, Nodes: Use plain menus for geometry nodes add menu
|
@ -1527,6 +1527,7 @@ struct TexResult;
|
|||
#define GEO_NODE_EDGE_PATHS_TO_SELECTION 1170
|
||||
#define GEO_NODE_MESH_FACE_SET_BOUNDARIES 1171
|
||||
#define GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME 1172
|
||||
#define GEO_NODE_SELF_OBJECT 1173
|
||||
|
||||
/** \} */
|
||||
|
||||
|
|
|
@ -2178,7 +2178,7 @@ bNode *nodeAddNode(const struct bContext *C, bNodeTree *ntree, const char *idnam
|
|||
|
||||
BKE_ntree_update_tag_node_new(ntree, node);
|
||||
|
||||
if (node->type == GEO_NODE_INPUT_SCENE_TIME) {
|
||||
if (ELEM(node->type, GEO_NODE_INPUT_SCENE_TIME, GEO_NODE_SELF_OBJECT)) {
|
||||
DEG_relations_tag_update(CTX_data_main(C));
|
||||
}
|
||||
|
||||
|
@ -3021,7 +3021,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
|
|||
|
||||
/* Also update relations for the scene time node, which causes a dependency
|
||||
* on time that users expect to be removed when the node is removed. */
|
||||
if (node_has_id || node->type == GEO_NODE_INPUT_SCENE_TIME) {
|
||||
if (node_has_id || ELEM(node->type, GEO_NODE_INPUT_SCENE_TIME, GEO_NODE_SELF_OBJECT)) {
|
||||
if (bmain != nullptr) {
|
||||
DEG_relations_tag_update(bmain);
|
||||
}
|
||||
|
@ -4804,6 +4804,7 @@ static void registerGeometryNodes()
|
|||
register_node_type_geo_scale_instances();
|
||||
register_node_type_geo_separate_components();
|
||||
register_node_type_geo_separate_geometry();
|
||||
register_node_type_geo_self_object();
|
||||
register_node_type_geo_set_curve_handles();
|
||||
register_node_type_geo_set_curve_radius();
|
||||
register_node_type_geo_set_curve_tilt();
|
||||
|
|
|
@ -203,6 +203,9 @@ static bool node_needs_own_transform_relation(const bNode &node)
|
|||
return storage.transform_space == GEO_NODE_TRANSFORM_SPACE_RELATIVE;
|
||||
}
|
||||
|
||||
if (node.type == GEO_NODE_SELF_OBJECT) {
|
||||
return true;
|
||||
}
|
||||
if (node.type == GEO_NODE_DEFORM_CURVES_ON_SURFACE) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ void register_node_type_geo_scale_instances(void);
|
|||
void register_node_type_geo_select_by_handle_type(void);
|
||||
void register_node_type_geo_separate_components(void);
|
||||
void register_node_type_geo_separate_geometry(void);
|
||||
void register_node_type_geo_self_object(void);
|
||||
void register_node_type_geo_set_curve_handles(void);
|
||||
void register_node_type_geo_set_curve_radius(void);
|
||||
void register_node_type_geo_set_curve_tilt(void);
|
||||
|
|
|
@ -382,6 +382,7 @@ DefNode(GeometryNode, GEO_NODE_SCALE_ELEMENTS, def_geo_scale_elements, "SCALE_EL
|
|||
DefNode(GeometryNode, GEO_NODE_SCALE_INSTANCES, 0, "SCALE_INSTANCES", ScaleInstances, "Scale Instances", "Scale geometry instances in local or global space")
|
||||
DefNode(GeometryNode, GEO_NODE_SEPARATE_COMPONENTS, 0, "SEPARATE_COMPONENTS",SeparateComponents, "Separate Components","Split a geometry into a separate output for each type of data in the geometry")
|
||||
DefNode(GeometryNode, GEO_NODE_SEPARATE_GEOMETRY, def_geo_separate_geometry,"SEPARATE_GEOMETRY", SeparateGeometry, "Separate Geometry", "Split a geometry into two geometry outputs based on a selection")
|
||||
DefNode(GeometryNode, GEO_NODE_SELF_OBJECT, 0, "SELF_OBJECT", SelfObject, "Self Object", "Retrieve the object that contains the geometry nodes modifier currently being executed")
|
||||
DefNode(GeometryNode, GEO_NODE_SET_CURVE_HANDLES, def_geo_curve_set_handle_positions, "SET_CURVE_HANDLES", SetCurveHandlePositions, "Set Handle Positions", "Set the positions for the handles of Bézier curves")
|
||||
DefNode(GeometryNode, GEO_NODE_SET_CURVE_RADIUS, 0, "SET_CURVE_RADIUS", SetCurveRadius, "Set Curve Radius", "Set the radius of the curve at each control point")
|
||||
DefNode(GeometryNode, GEO_NODE_SET_CURVE_TILT, 0, "SET_CURVE_TILT", SetCurveTilt, "Set Curve Tilt", "Set the tilt angle at each curve control point")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue