[Bf-blender-cvs] [c50478674cd] temp-geometry-nodes-expandable-geometry-socket-prototype: add initial Extrude node by Fabian

Jacques Lucke noreply at git.blender.org
Fri Aug 6 13:29:06 CEST 2021


Commit: c50478674cdd3680fd24ad999bd8736b45aefdd7
Author: Jacques Lucke
Date:   Fri Aug 6 12:56:13 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rBc50478674cdd3680fd24ad999bd8736b45aefdd7

add initial Extrude node by Fabian

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

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/bmesh/intern/bmesh_mesh.h
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/operators/bmo_inset.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_geometry.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/geometry/nodes/node_geo_extrude.cc

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

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 4126c0335ef..acb50b460e4 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -554,6 +554,7 @@ geometry_node_categories = [
         NodeItem("GeometryNodeEdgeSplit"),
         NodeItem("GeometryNodeSubdivisionSurface"),
         NodeItem("GeometryNodeMeshSubdivide"),
+        NodeItem("GeometryNodeExtrude"),
     ]),
     GeometryNodeCategory("GEO_PRIMITIVES_MESH", "Mesh Primitives", items=[
         NodeItem("GeometryNodeMeshCircle"),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index ec438b0c9c0..d80feec94ef 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1490,6 +1490,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define GEO_NODE_CURVE_SPLINE_TYPE 1073
 #define GEO_NODE_CURVE_SELECT_HANDLES 1074
 #define GEO_NODE_GEOMETRY_EXPANDER 1075
+#define GEO_NODE_EXTRUDE 1076
 
 /** \} */
 
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index b2958a9e744..81791e2170f 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -1446,4 +1446,121 @@ void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm,
   }
 }
 
+/**
+ * Use to select  bmesh vertex data based on an array of bool.
+ */
+void BM_select_vertices(BMesh *bm, const bool *mask)
+{
+  BMIter iter;
+  BMVert *v;
+  int i = 0;
+  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+    BM_elem_flag_set(v, BM_ELEM_SELECT, mask[i]);
+    i++;
+  }
+}
+
+/**
+ * Use to select bmesh edge data based on an array of bool.
+ */
+void BM_select_edges(BMesh *bm, const bool *mask)
+{
+  BMIter iter;
+  BMEdge *e;
+  int i = 0;
+  BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+    BM_elem_flag_set(e, BM_ELEM_SELECT, mask[i]);
+    i++;
+  }
+}
+
+/**
+ * Use to select bmesh face data based on an array of bool.
+ */
+void BM_select_faces(BMesh *bm, const bool *mask)
+{
+  BMIter iter;
+  BMFace *f;
+  int i = 0;
+  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+    BM_elem_flag_set(f, BM_ELEM_SELECT, mask[i]);
+    i++;
+  }
+}
+
+void BM_get_selected_faces(BMesh *bm, bool **selection)
+{
+  BMIter iter;
+  BMFace *f;
+  int i = 0;
+  *selection = MEM_malloc_arrayN((size_t)bm->totface, sizeof(bool), "bm faces");
+  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+    (*selection)[i] = BM_elem_flag_test(f, BM_ELEM_SELECT);
+    i++;
+  }
+  // BMO_slot_map_elem_get()
+}
+
+void BM_get_tagged_faces(BMesh *bm, bool **selection)
+{
+  BMIter iter;
+  BMFace *f;
+  int i = 0;
+  *selection = MEM_malloc_arrayN((size_t)bm->totface, sizeof(bool), "bm faces");
+  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+    (*selection)[i] = BM_elem_flag_test(f, BM_ELEM_TAG);
+    i++;
+  }
+}
+
+void BM_tag_new_faces(BMesh *bm, BMOperator *b_mesh_operator)
+{
+  BMOIter iter;
+  BMFace *f;
+  //*selection = MEM_malloc_arrayN((size_t)bm->totface, sizeof(bool), "bm faces");
+  BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false);
+  BMO_ITER (f, &iter, b_mesh_operator->slots_out, "faces.out", BM_FACE) {
+    BM_elem_flag_enable(f, BM_ELEM_TAG);
+  }
+  // BMO_slot_map_elem_get()
+}
+
+void BM_tag_vertices(BMesh *bm, const bool *mask)
+{
+  BMIter iter;
+  BMVert *v;
+  int i = 0;
+  BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
+    BM_elem_flag_set(v, BM_ELEM_TAG, mask[i]);
+    i++;
+  }
+}
+
+/**
+ * Use to temporary tag bmesh edge data based on an array of bool.
+ */
+void BM_tag_edges(BMesh *bm, const bool *mask)
+{
+  BMIter iter;
+  BMEdge *e;
+  int i = 0;
+  BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+    BM_elem_flag_set(e, BM_ELEM_TAG, mask[i]);
+    i++;
+  }
+}
+
+/**
+ * Use to temporary tag bmesh face data based on an array of bool.
+ */
+void BM_tag_faces(BMesh *bm, const bool *mask)
+{
+  BMIter iter;
+  BMFace *f;
+  int i = 0;
+  BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+    BM_elem_flag_set(f, BM_ELEM_TAG, mask[i]);
+    i++;
+  }
+}
 /** \} */
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index bd0504b038a..99baaa1421f 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -134,3 +134,13 @@ void BM_mesh_vert_coords_apply(BMesh *bm, const float (*vert_coords)[3]);
 void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm,
                                          const float (*vert_coords)[3],
                                          const float mat[4][4]);
+
+void BM_select_vertices(BMesh *bm, const bool *mask);
+void BM_select_edges(BMesh *bm, const bool *mask);
+void BM_select_faces(BMesh *bm, const bool *mask);
+void BM_get_selected_faces(BMesh *bm, bool **selection);
+void BM_tag_vertices(BMesh *bm, const bool *mask);
+void BM_tag_edges(BMesh *bm, const bool *mask);
+void BM_tag_faces(BMesh *bm, const bool *mask);
+void BM_get_tagged_faces(BMesh *bm, bool **selection);
+void BM_tag_new_faces(BMesh *bm, BMOperator *b_mesh_operator);
\ No newline at end of file
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index b63a09a97a6..651f9184e19 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1898,6 +1898,9 @@ static BMOpDefine bmo_inset_individual_def = {
   {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},    /* input faces */
    {"thickness", BMO_OP_SLOT_FLT}, /* thickness */
    {"depth", BMO_OP_SLOT_FLT}, /* depth */
+   {"thickness_array", BMO_OP_SLOT_PTR}, /* thickness */
+   {"depth_array", BMO_OP_SLOT_PTR}, /* depth */
+   {"use_attributes", BMO_OP_SLOT_BOOL}, /* Use spans for thickness and depth */
    {"use_even_offset", BMO_OP_SLOT_BOOL}, /* scale the offset to give more even thickness */
    {"use_interpolate", BMO_OP_SLOT_BOOL}, /* blend face data across the inset */
    {"use_relative_offset", BMO_OP_SLOT_BOOL}, /* scale the offset by surrounding geometry */
@@ -1929,6 +1932,9 @@ static BMOpDefine bmo_inset_region_def = {
    {"use_edge_rail", BMO_OP_SLOT_BOOL}, /* inset the region along existing edges */
    {"thickness", BMO_OP_SLOT_FLT}, /* thickness */
    {"depth", BMO_OP_SLOT_FLT}, /* depth */
+   {"thickness_array", BMO_OP_SLOT_PTR}, /* thickness */
+   {"depth_array", BMO_OP_SLOT_PTR}, /* depth */
+   {"use_attributes", BMO_OP_SLOT_BOOL}, /* Use spans for thickness and depth */
    {"use_outset", BMO_OP_SLOT_BOOL}, /* outset rather than inset */
    {{'\0'}},
   },
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index 4833290aa0b..a623fe171c8 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -419,6 +419,9 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
   BMOIter oiter;
   MemArena *interp_arena = NULL;
 
+  const bool use_attributes = BMO_slot_bool_get(op->slots_in, "use_attributes");
+  const float *thickness_array = BMO_slot_ptr_get(op->slots_in, "thickness_array");
+  const float *depth_array = BMO_slot_ptr_get(op->slots_in, "depth_array");
   const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
   const float depth = BMO_slot_float_get(op->slots_in, "depth");
   const bool use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
@@ -433,19 +436,37 @@ void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
   if (use_interpolate) {
     interp_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
   }
+  int i = 0;
+  if (use_attributes) {
+    BMO_ITER_INDEX (f, &oiter, op->slots_in, "faces", BM_FACE, i) {
+      bmo_face_inset_individual(bm,
+                                f,
+                                interp_arena,
+                                thickness_array[i],
+                                depth_array[i],
+                                use_even_offset,
+                                use_relative_offset,
+                                use_interpolate);
 
-  BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
-    bmo_face_inset_individual(bm,
-                              f,
-                              interp_arena,
-                              thickness,
-                              depth,
-                              use_even_offset,
-                              use_relative_offset,
-                              use_interpolate);
+      if (use_interpolate) {
+        BLI_memarena_clear(interp_arena);
+      }
+    }
+  }
+  else {
+    BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
+      bmo_face_inset_individual(bm,
+                                f,
+                                interp_arena,
+                                thickness,
+                                depth,
+                                use_even_offset,
+                                use_relative_offset,
+                                use_interpolate);
 
-    if (use_interpolate) {
-      BLI_memarena_clear(interp_arena);
+      if (use_interpolate) {
+        BLI_memarena_clear(interp_arena);
+      }
     }
   }
 
@@ -677,12 +698,15 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
   const bool use_outset = BMO_slot_bool_get(op->slots_in, "use_outset");
   const bool use_boundary = BMO_slot_bool_get(op->slots_in, "use_boundary") &&
                             (use_outset == false);
+
   const bool use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
   const bool use_even_boundary = use_even_offset; /* could make own option */
   const bool use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset");
   const bool use_edge_rail = BMO_slot_bool_get(op->slots_in, "use_edge_rail");
   const bool use_interpolate = BMO_slot_bool_get(op->slots_in, "use_interpolate");
   const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
+  const bool use_attributes = BMO_slot_bool_get(op->slots_in, "use_attributes");
+  const float *thickness_array = BMO_slot_ptr_get(op->slots_in, "thickness_array");
   const float depth = BMO_slot_float_get(op->slots_i

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list