add twist option to bridge tool (for circular loops)
This commit is contained in:
@@ -518,6 +518,7 @@ static BMOpDefine bmo_bridge_loops_def = {
|
||||
{"use_cyclic", BMO_OP_SLOT_BOOL},
|
||||
{"use_merge", BMO_OP_SLOT_BOOL},
|
||||
{"merge_factor", BMO_OP_SLOT_FLT},
|
||||
{"twist_offset", BMO_OP_SLOT_INT},
|
||||
{{'\0'}},
|
||||
},
|
||||
/* slots_out */
|
||||
|
||||
@@ -142,7 +142,7 @@ static bool bm_edge_test_cb(BMEdge *e, void *bm_v)
|
||||
static void bridge_loop_pair(BMesh *bm,
|
||||
struct BMEdgeLoopStore *el_store_a,
|
||||
struct BMEdgeLoopStore *el_store_b,
|
||||
const bool use_merge, const float merge_factor)
|
||||
const bool use_merge, const float merge_factor, const int twist_offset)
|
||||
{
|
||||
const float eps = 0.00001f;
|
||||
LinkData *el_a_first, *el_b_first;
|
||||
@@ -268,6 +268,15 @@ static void bridge_loop_pair(BMesh *bm,
|
||||
|
||||
if (is_closed) {
|
||||
bm_bridge_best_rotation(el_store_a, el_store_b);
|
||||
|
||||
/* add twist */
|
||||
if (twist_offset != 0) {
|
||||
const int len_b = BM_edgeloop_length_get(el_store_b);
|
||||
ListBase *lb_b = BM_edgeloop_verts_get(el_store_b);
|
||||
const int offset = twist_offset % len_b;
|
||||
LinkData *el_b = BLI_rfindlink(lb_b, (offset < 0) ? (offset + len_b) : offset);
|
||||
BLI_rotatelist(lb_b, el_b);
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign after flipping is finalized */
|
||||
@@ -476,6 +485,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
|
||||
const bool use_merge = BMO_slot_bool_get(op->slots_in, "use_merge");
|
||||
const float merge_factor = BMO_slot_float_get(op->slots_in, "merge_factor");
|
||||
const bool use_cyclic = BMO_slot_bool_get(op->slots_in, "use_cyclic") && (use_merge == false);
|
||||
const int twist_offset = BMO_slot_int_get(op->slots_in, "twist_offset");
|
||||
int count;
|
||||
bool change = false;
|
||||
|
||||
@@ -535,7 +545,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
|
||||
bridge_loop_pair(bm,
|
||||
(struct BMEdgeLoopStore *)el_store,
|
||||
(struct BMEdgeLoopStore *)el_store_next,
|
||||
use_merge, merge_factor);
|
||||
use_merge, merge_factor, twist_offset);
|
||||
if (use_pairs) {
|
||||
el_store = el_store->next;
|
||||
}
|
||||
|
||||
@@ -3978,6 +3978,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
|
||||
const bool use_cyclic = (type == 1);
|
||||
const bool use_merge = RNA_boolean_get(op->ptr, "use_merge");
|
||||
const float merge_factor = RNA_float_get(op->ptr, "merge_factor");
|
||||
const int twist_offset = RNA_int_get(op->ptr, "twist_offset");
|
||||
const bool use_faces = (em->bm->totfacesel != 0);
|
||||
char edge_hflag;
|
||||
|
||||
@@ -4005,8 +4006,8 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
EDBM_op_init(em, &bmop, op,
|
||||
"bridge_loops edges=%he use_pairs=%b use_cyclic=%b use_merge=%b merge_factor=%f",
|
||||
edge_hflag, use_pairs, use_cyclic, use_merge, merge_factor);
|
||||
"bridge_loops edges=%he use_pairs=%b use_cyclic=%b use_merge=%b merge_factor=%f twist_offset=%i",
|
||||
edge_hflag, use_pairs, use_cyclic, use_merge, merge_factor, twist_offset);
|
||||
|
||||
BMO_op_exec(em->bm, &bmop);
|
||||
|
||||
@@ -4086,6 +4087,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
|
||||
|
||||
RNA_def_boolean(ot->srna, "use_merge", false, "Merge", "Merge rather than creating faces");
|
||||
RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f);
|
||||
RNA_def_int(ot->srna, "twist_offset", 0, -1000, 1000, "Twist", "Twist offset for closed loops", -1000, 1000);
|
||||
|
||||
mesh_operator_edgering_props(ot, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user