From 7ac9f9a97f305f05fa4faffebf92ea7bd315745c Mon Sep 17 00:00:00 2001 From: Fabian Schempp Date: Fri, 20 Aug 2021 00:05:24 +0200 Subject: Fix: Inset socket nameing was wrong --- source/blender/bmesh/intern/bmesh_opdefines.c | 6 +++ source/blender/bmesh/operators/bmo_inset.c | 53 +++++++++++++++++----- .../nodes/geometry/nodes/node_geo_mesh_inset.cc | 8 ++-- 3 files changed, 51 insertions(+), 16 deletions(-) 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..1e30f1b72b3 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); + } } } @@ -683,6 +704,9 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) 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 +1120,12 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) } /* apply the offset */ - madd_v3_v3fl(v_split->co, tvec, thickness); + if (use_attributes) { + 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/slow glue check for common cases */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_inset.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_inset.cc index 342897a695c..4bfda0376e0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_inset.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_inset.cc @@ -32,8 +32,8 @@ static bNodeSocketTemplate geo_node_mesh_inset_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Distance")}, {SOCK_FLOAT, N_("Distance"), 0.0f, 0, 0, 0, FLT_MIN, FLT_MAX, PROP_DISTANCE}, - {SOCK_STRING, N_("mesh_inset")}, - {SOCK_FLOAT, N_("mesh_inset"), 0.0f, 0, 0, 0, FLT_MIN, FLT_MAX, PROP_DISTANCE}, + {SOCK_STRING, N_("Inset")}, + {SOCK_FLOAT, N_("Inset"), 0.0f, 0, 0, 0, FLT_MIN, FLT_MAX, PROP_DISTANCE}, {SOCK_BOOLEAN, N_("Individual")}, {SOCK_STRING, N_("Selection")}, {SOCK_STRING, N_("Top Face")}, @@ -65,7 +65,7 @@ static void geo_node_mesh_inset_update(bNodeTree *UNUSED(ntree), bNode *node) blender::nodes::update_attribute_input_socket_availabilities( *node, "Distance", (GeometryNodeAttributeInputMode)node->custom1, true); blender::nodes::update_attribute_input_socket_availabilities( - *node, "mesh_inset", (GeometryNodeAttributeInputMode)node->custom2, true); + *node, "Inset", (GeometryNodeAttributeInputMode)node->custom2, true); } using blender::Span; @@ -179,7 +179,7 @@ static void geo_node_mesh_inset_exec(GeoNodeExecParams params) const float default_mesh_inset = 0; GVArray_Typed mesh_inset_attribute = params.get_input_attribute( - "mesh_inset", mesh_component, attribute_domain, default_mesh_inset); + "Inset", mesh_component, attribute_domain, default_mesh_inset); VArray_Span mesh_inset{mesh_inset_attribute}; std::string selection_top_faces_out_attribute_name = params.get_input("Top Face"); -- cgit v1.2.3