Fix: Missing GeometryNodeCustomGroup

This is a minor change to add some plumbing code
to support custom geo nodes. This is working the
same way as the custom cycles and compositor nodes.

An example add-in is attached to D10784

Reviewed By: JacquesLucke

Differential Revision: http://developer.blender.org/D10784
This commit is contained in:
Ray molenkamp 2021-04-08 16:25:09 -06:00
parent 500045a0d3
commit 3d7e3d5ad0
Notes: blender-bot 2023-02-14 11:00:17 +01:00
Referenced by issue #87355, Crash using menu search from the top bar
6 changed files with 57 additions and 4 deletions

View File

@ -1314,8 +1314,8 @@ void nodeUnregisterType(bNodeType *nt)
bool nodeTypeUndefined(bNode *node)
{
return (node->typeinfo == &NodeTypeUndefined) ||
(node->type == NODE_GROUP && node->id && ID_IS_LINKED(node->id) &&
(node->id->tag & LIB_TAG_MISSING));
((node->type == NODE_GROUP || node->type == NODE_CUSTOM_GROUP) && node->id &&
ID_IS_LINKED(node->id) && (node->id->tag & LIB_TAG_MISSING));
}
GHashIterator *nodeTypeGetIterator(void)

View File

@ -497,6 +497,7 @@ static const EnumPropertyItem rna_node_geometry_attribute_input_type_items_no_bo
# include "NOD_common.h"
# include "NOD_composite.h"
# include "NOD_geometry.h"
# include "NOD_shader.h"
# include "NOD_socket.h"
@ -3290,6 +3291,35 @@ static StructRNA *rna_NodeCustomGroup_register(Main *bmain,
return nt->rna_ext.srna;
}
static StructRNA *rna_GeometryNodeCustomGroup_register(Main *bmain,
ReportList *reports,
void *data,
const char *identifier,
StructValidateFunc validate,
StructCallbackFunc call,
StructFreeFunc free)
{
bNodeType *nt = rna_Node_register_base(
bmain, reports, &RNA_GeometryNodeCustomGroup, data, identifier, validate, call, free);
if (!nt) {
return NULL;
}
nt->group_update_func = node_group_update;
nt->type = NODE_CUSTOM_GROUP;
register_node_type_geo_custom_group(nt);
nodeRegisterType(nt);
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return nt->rna_ext.srna;
}
void register_node_type_geo_custom_group(bNodeType *ntype);
static StructRNA *rna_ShaderNodeCustomGroup_register(Main *bmain,
ReportList *reports,
void *data,
@ -11501,6 +11531,12 @@ void RNA_def_nodetree(BlenderRNA *brna)
"Custom Group",
"Base node type for custom registered node group types",
"rna_NodeCustomGroup_register");
def_custom_group(brna,
"GeometryNodeCustomGroup",
"GeometryNode",
"Geometry Custom Group",
"Custom Geometry Group Node for Python nodes",
"rna_GeometryNodeCustomGroup_register");
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);

View File

@ -136,7 +136,7 @@ static void find_used_ids_from_nodes(const bNodeTree &tree, Set<ID *> &ids)
addIdsUsedBySocket(&node->inputs, ids);
addIdsUsedBySocket(&node->outputs, ids);
if (node->type == NODE_GROUP) {
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
const bNodeTree *group = (bNodeTree *)node->id;
if (group != nullptr && handled_groups.add(group)) {
find_used_ids_from_nodes(*group, ids);

View File

@ -20,11 +20,14 @@
extern "C" {
#endif
#include "BKE_node.h"
extern struct bNodeTreeType *ntreeType_Geometry;
void register_node_tree_type_geo(void);
void register_node_type_geo_group(void);
void register_node_type_geo_custom_group(bNodeType *ntype);
void register_node_type_geo_align_rotation_to_vector(void);
void register_node_type_geo_attribute_clamp(void);

View File

@ -528,7 +528,7 @@ inline bool NodeRef::is_reroute_node() const
inline bool NodeRef::is_group_node() const
{
return bnode_->type == NODE_GROUP;
return bnode_->type == NODE_GROUP || bnode_->type == NODE_CUSTOM_GROUP;
}
inline bool NodeRef::is_group_input_node() const

View File

@ -43,3 +43,17 @@ void register_node_type_geo_group(void)
nodeRegisterType(&ntype);
}
void register_node_type_geo_custom_group(bNodeType *ntype)
{
/* These methods can be overridden but need a default implementation otherwise. */
if (ntype->poll == nullptr) {
ntype->poll = geo_node_poll_default;
}
if (ntype->insert_link == nullptr) {
ntype->insert_link = node_insert_link_default;
}
if (ntype->update_internal_links == nullptr) {
ntype->update_internal_links = node_update_internal_links_default;
}
}