Blender  V2.93
node_geometry_tree.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #include <cstring>
18 
19 #include "MEM_guardedalloc.h"
20 
21 #include "NOD_geometry.h"
22 
23 #include "BKE_context.h"
24 #include "BKE_node.h"
25 #include "BKE_object.h"
26 
27 #include "BLT_translation.h"
28 
29 #include "DNA_modifier_types.h"
30 #include "DNA_node_types.h"
31 #include "DNA_space_types.h"
32 
33 #include "RNA_access.h"
34 
35 #include "node_common.h"
36 
38 
40  bNodeTreeType *UNUSED(treetype),
41  bNodeTree **r_ntree,
42  ID **r_id,
43  ID **r_from)
44 {
45  ViewLayer *view_layer = CTX_data_view_layer(C);
46  Object *ob = OBACT(view_layer);
47 
48  if (ob == nullptr) {
49  return;
50  }
51 
53 
54  if (md == nullptr) {
55  return;
56  }
57 
58  if (md->type == eModifierType_Nodes) {
60  if (nmd->node_group != nullptr) {
61  *r_from = &ob->id;
62  *r_id = &ob->id;
63  *r_ntree = nmd->node_group;
64  }
65  }
66 }
67 
69 {
71 
72  /* Needed to give correct types to reroutes. */
74 }
75 
76 static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
77 {
78  func(calldata, NODE_CLASS_INPUT, N_("Input"));
79  func(calldata, NODE_CLASS_GEOMETRY, N_("Geometry"));
80  func(calldata, NODE_CLASS_ATTRIBUTE, N_("Attribute"));
81  func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
82  func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
83  func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
84  func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
85 }
86 
88 {
89  bNodeTreeType *tt = ntreeType_Geometry = static_cast<bNodeTreeType *>(
90  MEM_callocN(sizeof(bNodeTreeType), "geometry node tree type"));
91  tt->type = NTREE_GEOMETRY;
92  strcpy(tt->idname, "GeometryNodeTree");
93  strcpy(tt->ui_name, N_("Geometry Node Editor"));
94  tt->ui_icon = 0; /* defined in drawnode.c */
95  strcpy(tt->ui_description, N_("Geometry nodes"));
100 
101  ntreeTypeAdd(tt);
102 }
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
void ntreeTypeAdd(struct bNodeTreeType *nt)
Definition: node.cc:1219
void(* bNodeClassCallback)(void *calldata, int nclass, const char *name)
Definition: BKE_node.h:378
#define NODE_CLASS_CONVERTOR
Definition: BKE_node.h:341
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
void ntreeSetOutput(struct bNodeTree *ntree)
Definition: node.cc:3050
#define NODE_CLASS_OP_VECTOR
Definition: BKE_node.h:337
#define NODE_CLASS_LAYOUT
Definition: BKE_node.h:361
#define NODE_CLASS_OP_COLOR
Definition: BKE_node.h:336
#define NODE_CLASS_INPUT
Definition: BKE_node.h:334
#define NODE_CLASS_ATTRIBUTE
Definition: BKE_node.h:360
General operations, lookup, etc. for blender objects.
struct ModifierData * BKE_object_active_modifier(const struct Object *ob)
#define UNUSED(x)
#define N_(msgid)
@ eModifierType_Nodes
#define NTREE_GEOMETRY
#define OBACT(_view_layer)
Read Guarded memory(de)allocation.
StructRNA RNA_GeometryNodeTree
#define C
Definition: RandGen.cpp:39
Scene scene
bNodeTree * ntree
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void ntree_update_reroute_nodes(bNodeTree *ntree)
Definition: node_common.c:357
static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
void register_node_tree_type_geo(void)
bNodeTreeType * ntreeType_Geometry
static void geometry_node_tree_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
static void geometry_node_tree_update(bNodeTree *ntree)
StructRNA * srna
Definition: RNA_types.h:681
Definition: DNA_ID.h:273
struct bNodeTree * node_group
char idname[64]
Definition: BKE_node.h:381
void(* update)(struct bNodeTree *ntree)
Definition: BKE_node.h:407
void(* get_from_context)(const struct bContext *C, struct bNodeTreeType *ntreetype, struct bNodeTree **r_ntree, struct ID **r_id, struct ID **r_from)
Definition: BKE_node.h:395
char ui_name[64]
Definition: BKE_node.h:383
char ui_description[256]
Definition: BKE_node.h:384
void(* foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func)
Definition: BKE_node.h:391
ExtensionRNA rna_ext
Definition: BKE_node.h:414