[Bf-blender-cvs] [4f8edc8e7fc] master: Nodes: move some files to C++

Jacques Lucke noreply at git.blender.org
Wed Jun 2 17:26:12 CEST 2021


Commit: 4f8edc8e7fc9389b03543bc9a20f6c936e32b531
Author: Jacques Lucke
Date:   Wed Jun 2 17:19:36 2021 +0200
Branches: master
https://developer.blender.org/rB4f8edc8e7fc9389b03543bc9a20f6c936e32b531

Nodes: move some files to C++

This just moves a couple of files in `space_node` to C++ and fixes
related errors.

The goal is to be able to use C++ data structures to simplify the code.

Differential Revision: https://developer.blender.org/D11451

===================================================================

M	source/blender/editors/space_node/CMakeLists.txt
R082	source/blender/editors/space_node/drawnode.c	source/blender/editors/space_node/drawnode.cc
R093	source/blender/editors/space_node/node_add.c	source/blender/editors/space_node/node_add.cc
R092	source/blender/editors/space_node/node_edit.c	source/blender/editors/space_node/node_edit.cc
R094	source/blender/editors/space_node/node_group.c	source/blender/editors/space_node/node_group.cc
R091	source/blender/editors/space_node/node_relationships.c	source/blender/editors/space_node/node_relationships.cc
R087	source/blender/editors/space_node/node_select.c	source/blender/editors/space_node/node_select.cc
R088	source/blender/editors/space_node/node_templates.c	source/blender/editors/space_node/node_templates.cc
R100	source/blender/editors/space_node/node_toolbar.c	source/blender/editors/space_node/node_toolbar.cc
R090	source/blender/editors/space_node/node_view.c	source/blender/editors/space_node/node_view.cc

===================================================================

diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index bc043a4e665..6e234c5b2ce 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -37,20 +37,20 @@ set(INC
 
 
 set(SRC
-  drawnode.c
-  node_add.c
+  drawnode.cc
+  node_add.cc
   node_buttons.c
   node_draw.cc
-  node_edit.c
+  node_edit.cc
   node_geometry_attribute_search.cc
   node_gizmo.c
-  node_group.c
+  node_group.cc
   node_ops.c
-  node_relationships.c
-  node_select.c
-  node_templates.c
-  node_toolbar.c
-  node_view.c
+  node_relationships.cc
+  node_select.cc
+  node_templates.cc
+  node_toolbar.cc
+  node_view.cc
   space_node.c
 
   node_intern.h
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.cc
similarity index 82%
rename from source/blender/editors/space_node/drawnode.c
rename to source/blender/editors/space_node/drawnode.cc
index f11f1c01019..982af78dfde 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -95,9 +95,9 @@ static void node_socket_button_label(bContext *UNUSED(C),
 
 static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-  bNode *node = ptr->data;
+  bNode *node = (bNode *)ptr->data;
   /* first output stores value */
-  bNodeSocket *output = node->outputs.first;
+  bNodeSocket *output = (bNodeSocket *)node->outputs.first;
   PointerRNA sockptr;
   RNA_pointer_create(ptr->owner_id, &RNA_NodeSocket, output, &sockptr);
 
@@ -106,15 +106,15 @@ static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *p
 
 static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-  bNode *node = ptr->data;
+  bNode *node = (bNode *)ptr->data;
   /* first output stores value */
-  bNodeSocket *output = node->outputs.first;
+  bNodeSocket *output = (bNodeSocket *)node->outputs.first;
   PointerRNA sockptr;
   uiLayout *col;
   RNA_pointer_create(ptr->owner_id, &RNA_NodeSocket, output, &sockptr);
 
   col = uiLayoutColumn(layout, false);
-  uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
+  uiTemplateColorPicker(col, &sockptr, "default_value", true, false, false, false);
   uiItemR(col, &sockptr, "default_value", DEFAULT_FLAGS | UI_ITEM_R_SLIDER, "", ICON_NONE);
 }
 
@@ -129,14 +129,14 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA
     uiItemR(row, ptr, "use_alpha", DEFAULT_FLAGS, "", ICON_IMAGE_RGB_ALPHA);
   }
 
-  uiItemR(col, ptr, "use_clamp", DEFAULT_FLAGS, NULL, ICON_NONE);
+  uiItemR(col, ptr, "use_clamp", DEFAULT_FLAGS, nullptr, ICON_NONE);
 }
 
 static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 #if 0
   /* XXX no context access here .. */
-  bNode *node = ptr->data;
+  bNode *node = (bNode*)ptr->data;
   CurveMapping *cumap = node->storage;
 
   if (cumap) {
@@ -156,7 +156,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
 
 static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-  uiTemplateColorRamp(layout, ptr, "color_ramp", 0);
+  uiTemplateColorRamp(layout, ptr, "color_ramp", false);
 }
 
 static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@ -179,8 +179,8 @@ void ED_node_sample_set(const float col[4])
 
 static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-  bNode *node = ptr->data;
-  CurveMapping *cumap = node->storage;
+  bNode *node = (bNode *)ptr->data;
+  CurveMapping *cumap = (CurveMapping *)node->storage;
 
   if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
     cumap->flag |= CUMA_DRAW_SAMPLE;
@@ -198,9 +198,9 @@ static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA
 
 static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-  bNode *node = ptr->data;
+  bNode *node = (bNode *)ptr->data;
   /* first output stores normal */
-  bNodeSocket *output = node->outputs.first;
+  bNodeSocket *output = (bNodeSocket *)node->outputs.first;
   PointerRNA sockptr;
   RNA_pointer_create(ptr->owner_id, &RNA_NodeSocket, output, &sockptr);
 
@@ -209,7 +209,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
 
 static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-  bNode *node = ptr->data;
+  bNode *node = (bNode *)ptr->data;
 
   short multi = (node->id && ((Tex *)node->id)->use_nodes && (node->type != CMP_NODE_TEXTURE) &&
                  (node->type != TEX_NODE_TEXTURE));
@@ -233,14 +233,14 @@ static void node_shader_buts_map_range(uiLayout *layout, bContext *UNUSED(C), Po
   if (!ELEM(RNA_enum_get(ptr, "interpolation_type"),
             NODE_MAP_RANGE_SMOOTHSTEP,
             NODE_MAP_RANGE_SMOOTHERSTEP)) {
-    uiItemR(layout, ptr, "clamp", DEFAULT_FLAGS, NULL, ICON_NONE);
+    uiItemR(layout, ptr, "clamp", DEFAULT_FLAGS, nullptr, ICON_NONE);
   }
 }
 
 static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
   uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
-  uiItemR(layout, ptr, "use_clamp", DEFAULT_FLAGS, NULL, ICON_NONE);
+  uiItemR(layout, ptr, "use_clamp", DEFAULT_FLAGS, nullptr, ICON_NONE);
 }
 
 static int node_resize_area_default(bNode *node, int x, int y)
@@ -274,7 +274,7 @@ static int node_resize_area_default(bNode *node, int x, int y)
 static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
   uiTemplateIDBrowse(
-      layout, C, ptr, "node_tree", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL, NULL);
+      layout, C, ptr, "node_tree", nullptr, nullptr, nullptr, UI_TEMPLATE_ID_FILTER_ALL, nullptr);
 }
 
 /* XXX Does a bounding box update by iterating over all children.
@@ -311,7 +311,7 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree,
 
     /* first child initializes frame */
     if (bbinit) {
-      bbinit = 0;
+      bbinit = false;
       rect = noderect;
       data->flag &= ~NODE_FRAME_RESIZEABLE;
     }
@@ -418,9 +418,9 @@ static void node_draw_frame(const bContext *C,
 {
 
   /* skip if out of view */
-  if (BLI_rctf_isect(&node->totr, &region->v2d.cur, NULL) == false) {
+  if (BLI_rctf_isect(&node->totr, &region->v2d.cur, nullptr) == false) {
     UI_block_end(C, node->block);
-    node->block = NULL;
+    node->block = nullptr;
     return;
   }
 
@@ -462,7 +462,7 @@ static void node_draw_frame(const bContext *C,
 
   UI_block_end(C, node->block);
   UI_block_draw(C, node->block);
-  node->block = NULL;
+  node->block = nullptr;
 }
 
 static int node_resize_area_frame(bNode *node, int x, int y)
@@ -497,7 +497,7 @@ static void node_buts_frame_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA
 {
   uiItemR(layout, ptr, "label_size", DEFAULT_FLAGS, IFACE_("Label Size"), ICON_NONE);
   uiItemR(layout, ptr, "shrink", DEFAULT_FLAGS, IFACE_("Shrink"), ICON_NONE);
-  uiItemR(layout, ptr, "text", DEFAULT_FLAGS, NULL, ICON_NONE);
+  uiItemR(layout, ptr, "text", DEFAULT_FLAGS, nullptr, ICON_NONE);
 }
 
 #define NODE_REROUTE_SIZE 8.0f
@@ -511,11 +511,11 @@ static void node_draw_reroute_prepare(const bContext *UNUSED(C),
   node_to_view(node, 0.0f, 0.0f, &locx, &locy);
 
   /* reroute node has exactly one input and one output, both in the same place */
-  bNodeSocket *nsock = node->outputs.first;
+  bNodeSocket *nsock = (bNodeSocket *)node->outputs.first;
   nsock->locx = locx;
   nsock->locy = locy;
 
-  nsock = node->inputs.first;
+  nsock = (bNodeSocket *)node->inputs.first;
   nsock->locx = locx;
   nsock->locy = locy;
 
@@ -541,7 +541,7 @@ static void node_draw_reroute(const bContext *C,
   if (node->totr.xmax < region->v2d.cur.xmin || node->totr.xmin > region->v2d.cur.xmax ||
       node->totr.ymax < region->v2d.cur.ymin || node->totr.ymin > region->v2d.cur.ymax) {
     UI_block_end(C, node->block);
-    node->block = NULL;
+    node->block = nullptr;
     return;
   }
 
@@ -586,12 +586,12 @@ static void node_draw_reroute(const bContext *C,
              (int)(rct->ymax),
              (short)512,
              (short)NODE_DY,
-             NULL,
+             nullptr,
              0,
              0,
              0,
              0,
-             NULL);
+             nullptr);
   }
 
   /* only draw input socket. as they all are placed on the same position.
@@ -601,7 +601,7 @@ static void node_draw_reroute(const bContext *C,
 
   UI_block_end(C, node->block);
   UI_block_draw(C, node->block);
-  node->block = NULL;
+  node->block = nullptr;
 }
 
 /* Special tweak area for reroute node.
@@ -612,7 +612,7 @@ static int node_tweak_area_reroute(bNode *node, int x, int y)
   /* square of tweak radius */
   const float tweak_radius_sq = square_f(24.0f);
 
-  bNodeSocket *sock = node->inputs.first;
+  bNodeSocket *sock = (bNodeSocket *)node->inputs.first;
   float dx = sock->locx - x;
   float dy = sock->locy - y;
   return (dx * dx + dy * dy <= tweak_radius_sq);
@@ -662,28 +662,28 @@ static void node_buts_image_user(uiLayout *layout,
     /* don't use iuser->framenr directly
      * because it may not be updated if auto-refresh is off */
     Scene *scene = CTX_data_scene(C);
-    ImageUser *iuser = iuserptr->data;
+    ImageUser *iuser = (ImageUser *)iuserptr->data;
     /* Image *ima = imaptr->data; */ /* UNUSED */
 
     char numstr[32];
-    const int framenr = BKE_image_user_frame_get(iuser, CFRA, NULL);
+    const int framenr = BKE_image_user_frame_get(iuser, CFRA, nullptr);
     BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
     uiItemL(layout, numstr, ICON_NONE);
   }
 
   if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
     col = uiLayoutColumn(layout, true);
-    uiItemR(col, ptr, "frame_duration", DEFAULT_FLAGS, NULL, ICON_NONE);
-    uiItemR(col, ptr, "frame_start", DEFAULT_FLAGS, NULL, ICON_NONE);
-    uiItemR(col, ptr, "frame_offset", DEFAULT_FLAGS, NULL, ICON_NONE);
-    uiItemR(col, ptr, "use_cyclic", DEFAULT_FLAGS, NULL, ICON_NONE);
-    uiItemR(col, ptr, "use_auto_refresh", DEFAULT_FLAGS, NULL, ICON_NONE);
+    uiItemR(col,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list