[Bf-blender-cvs] [504e3c563f8] soc-2021-porting-modifiers-to-nodes-extrude: added side selection.
Fabian Schempp
noreply at git.blender.org
Thu Aug 5 23:50:35 CEST 2021
Commit: 504e3c563f851fc0296fb2d6b96704233c477814
Author: Fabian Schempp
Date: Thu Aug 5 23:47:44 2021 +0200
Branches: soc-2021-porting-modifiers-to-nodes-extrude
https://developer.blender.org/rB504e3c563f851fc0296fb2d6b96704233c477814
added side selection.
===================================================================
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/NOD_static_types.h
M source/blender/nodes/geometry/nodes/node_geo_extrude.cc
===================================================================
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index ad8158e2e6f..217c3502b40 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -1455,12 +1455,7 @@ void BM_select_vertices(BMesh *bm, const bool *mask)
BMVert *v;
int i = 0;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (mask[i]) {
- BM_elem_flag_set(v, BM_ELEM_SELECT, true);
- }
- else {
- BM_elem_flag_set(v, BM_ELEM_SELECT, false);
- }
+ BM_elem_flag_set(v, BM_ELEM_SELECT, mask[i]);
i++;
}
}
@@ -1474,12 +1469,7 @@ void BM_select_edges(BMesh *bm, const bool *mask)
BMEdge *e;
int i = 0;
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (mask[i]) {
- BM_elem_flag_set(e, BM_ELEM_SELECT, true);
- }
- else {
- BM_elem_flag_set(e, BM_ELEM_SELECT, false);
- }
+ BM_elem_flag_set(e, BM_ELEM_SELECT, mask[i]);
i++;
}
}
@@ -1493,14 +1483,47 @@ void BM_select_faces(BMesh *bm, const bool *mask)
BMFace *f;
int i = 0;
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (mask[i]) {
- BM_elem_flag_set(f, BM_ELEM_SELECT, true);
- }
- else {
- BM_elem_flag_set(f, BM_ELEM_SELECT, false);
- }
+ 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)
+{
+ BMIter iter;
+ BMFace *f;
+ int i = 0;
+ //*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)
@@ -1509,12 +1532,7 @@ void BM_tag_vertices(BMesh *bm, const bool *mask)
BMVert *v;
int i = 0;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (mask[i]) {
- BM_elem_flag_set(v, BM_ELEM_TAG, true);
- }
- else {
- BM_elem_flag_set(v, BM_ELEM_TAG, false);
- }
+ BM_elem_flag_set(v, BM_ELEM_TAG, mask[i]);
i++;
}
}
@@ -1528,12 +1546,7 @@ void BM_tag_edges(BMesh *bm, const bool *mask)
BMEdge *e;
int i = 0;
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (mask[i]) {
- BM_elem_flag_set(e, BM_ELEM_TAG, true);
- }
- else {
- BM_elem_flag_set(e, BM_ELEM_TAG, false);
- }
+ BM_elem_flag_set(e, BM_ELEM_TAG, mask[i]);
i++;
}
}
@@ -1547,12 +1560,7 @@ void BM_tag_faces(BMesh *bm, const bool *mask)
BMFace *f;
int i = 0;
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (mask[i]) {
- BM_elem_flag_set(f, BM_ELEM_TAG, true);
- }
- else {
- BM_elem_flag_set(f, BM_ELEM_TAG, false);
- }
+ 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 eb7dcaac046..99baaa1421f 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -138,6 +138,9 @@ void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm,
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);
\ No newline at end of file
+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..b02a3e8652f 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,16 @@ 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_array = BMO_slot_ptr_get(op->slots_in, "depth_array");
const float depth = BMO_slot_float_get(op->slots_in, "depth");
#ifdef USE_LOOP_CUSTOMDATA_MERGE
const bool has_math_ldata = (use_interpolate && CustomData_has_math(&bm->ldata));
@@ -1096,7 +1121,13 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
}
/* apply the offset */
- madd_v3_v3fl(v_split->co, tvec, thickness);
+ if (use_attributes) {
+ printf("index: %i\n", v_split->head.index);
+ madd_v3_v3fl(v_split->co, tvec, thickness_array[v_split->head.index]);
+ }
+ else {
+ madd_v3_v3fl(v_split->co, tvec, thickness);
+ }
}
/* this saves expensive/slo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list