Fix [#21912] knife and subdivide tools do not split edges properly
Added back the 'corner cut pattern' as an operator property for subdivide operator. Not added for knife yet, since operator redo doesn't seem to be working at all - already logged in the tracker.
This commit is contained in:
@@ -1096,7 +1096,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
|
||||
}
|
||||
|
||||
dia*=200;
|
||||
for(a=1; a<subdiv; a++) esubdivideflag(obedit, em, 2, dia, 0, B_SPHERE,1,0);
|
||||
for(a=1; a<subdiv; a++) esubdivideflag(obedit, em, 2, dia, 0, B_SPHERE,1, SUBDIV_CORNER_PATH, 0);
|
||||
/* and now do imat */
|
||||
eve= em->verts.first;
|
||||
while(eve) {
|
||||
|
||||
@@ -362,9 +362,9 @@ void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcuts)
|
||||
fac= 1.0f;
|
||||
// XXX if(fbutton(&fac, 0.0f, 5.0f, 10, 10, "Smooth:")==0) return;
|
||||
fac= 0.292f*fac;
|
||||
esubdivideflag(obedit, em, SELECT,fac,0,B_SMOOTH,numcuts,SUBDIV_SELECT_LOOPCUT);
|
||||
esubdivideflag(obedit, em, SELECT,fac,0,B_SMOOTH,numcuts, SUBDIV_CORNER_PATH, SUBDIV_SELECT_LOOPCUT);
|
||||
} else {
|
||||
esubdivideflag(obedit, em, SELECT,0,0,0,numcuts,SUBDIV_SELECT_LOOPCUT);
|
||||
esubdivideflag(obedit, em, SELECT,0,0,0,numcuts,SUBDIV_CORNER_PATH, SUBDIV_SELECT_LOOPCUT);
|
||||
}
|
||||
/* if this was a single cut, enter edgeslide mode */
|
||||
if(numcuts == 1 && hasHidden == 0){
|
||||
@@ -629,6 +629,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
|
||||
int len=0;
|
||||
short numcuts= RNA_int_get(op->ptr, "num_cuts");
|
||||
short mode= RNA_int_get(op->ptr, "type");
|
||||
int corner_cut_pattern= RNA_enum_get(op->ptr,"corner_cut_pattern");
|
||||
|
||||
/* edit-object needed for matrix, and ar->regiondata for projections to work */
|
||||
if (ELEM3(NULL, obedit, ar, ar->regiondata))
|
||||
@@ -686,9 +687,9 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
|
||||
eed= eed->next;
|
||||
}
|
||||
|
||||
if (mode==KNIFE_MIDPOINT) esubdivideflag(obedit, em, SELECT, 0, 0, B_KNIFE, 1, SUBDIV_SELECT_ORIG);
|
||||
else if (mode==KNIFE_MULTICUT) esubdivideflag(obedit, em, SELECT, 0, 0, B_KNIFE, numcuts, SUBDIV_SELECT_ORIG);
|
||||
else esubdivideflag(obedit, em, SELECT, 0, 0, B_KNIFE|B_PERCENTSUBD, 1, SUBDIV_SELECT_ORIG);
|
||||
if (mode==KNIFE_MIDPOINT) esubdivideflag(obedit, em, SELECT, 0, 0, B_KNIFE, 1, SUBDIV_CORNER_INNERVERT, SUBDIV_SELECT_INNER);
|
||||
else if (mode==KNIFE_MULTICUT) esubdivideflag(obedit, em, SELECT, 0, 0, B_KNIFE, numcuts, SUBDIV_CORNER_INNERVERT, SUBDIV_SELECT_INNER);
|
||||
else esubdivideflag(obedit, em, SELECT, 0, 0, B_KNIFE|B_PERCENTSUBD, 1, SUBDIV_CORNER_INNERVERT, SUBDIV_SELECT_INNER);
|
||||
|
||||
eed=em->edges.first;
|
||||
while(eed){
|
||||
@@ -729,6 +730,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
|
||||
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
|
||||
RNA_def_int(ot->srna, "num_cuts", 1, 1, MAX_CUTS, "Number of Cuts", "Only for Multi-Cut", 1, MAX_CUTS);
|
||||
// doesn't work atm.. RNA_def_enum(ot->srna, "corner_cut_pattern", corner_type_items, SUBDIV_CORNER_INNERVERT, "Corner Cut Pattern", "Topology pattern to use to fill a face after cutting across its corner");
|
||||
|
||||
/* internal */
|
||||
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
|
||||
|
||||
@@ -90,6 +90,15 @@ static void waitcursor(int val) {}
|
||||
|
||||
/* XXX */
|
||||
|
||||
/* RNA corner cut enum property - used in multiple files for tools
|
||||
* that need this property for esubdivideflag() */
|
||||
EnumPropertyItem corner_type_items[] = {
|
||||
{SUBDIV_CORNER_PATH, "PATH", 0, "Path", ""},
|
||||
{SUBDIV_CORNER_INNERVERT, "INNER_VERTEX", 0, "Inner Vertex", ""},
|
||||
{SUBDIV_CORNER_FAN, "FAN", 0, "Fan", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
|
||||
/* local prototypes ---------------*/
|
||||
static void free_tagged_edges_faces(EditMesh *em, EditEdge *eed, EditFace *efa);
|
||||
int EdgeLoopDelete(EditMesh *em, wmOperator *op);
|
||||
@@ -2586,7 +2595,7 @@ static EditVert *subdivideedgenum(EditMesh *em, EditEdge *edge, int curpoint, in
|
||||
return ev;
|
||||
}
|
||||
|
||||
void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float fractal, int beauty, int numcuts, int seltype)
|
||||
void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float fractal, int beauty, int numcuts, int corner_pattern, int seltype)
|
||||
{
|
||||
EditFace *ef;
|
||||
EditEdge *eed, *cedge, *sort[4];
|
||||
@@ -2830,7 +2839,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
|
||||
(ef->e2->f & flag && ef->e4->f & flag)) {
|
||||
fill_quad_double_op(em, ef, gh, numcuts);
|
||||
}else{
|
||||
switch(0) { // XXX scene->toolsettings->cornertype) {
|
||||
switch(corner_pattern) {
|
||||
case 0: fill_quad_double_adj_path(em, ef, gh, numcuts); break;
|
||||
case 1: fill_quad_double_adj_inner(em, ef, gh, numcuts); break;
|
||||
case 2: fill_quad_double_adj_fan(em, ef, gh, numcuts); break;
|
||||
@@ -6727,6 +6736,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
|
||||
int cuts= RNA_int_get(op->ptr,"number_cuts");
|
||||
float smooth= 0.292f*RNA_float_get(op->ptr, "smoothness");
|
||||
float fractal= RNA_float_get(op->ptr, "fractal")/100;
|
||||
int corner_cut_pattern= RNA_enum_get(op->ptr,"corner_cut_pattern");
|
||||
int flag= 0;
|
||||
|
||||
if(smooth != 0.0f)
|
||||
@@ -6734,7 +6744,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
|
||||
if(fractal != 0.0f)
|
||||
flag |= B_FRACTAL;
|
||||
|
||||
esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, 0);
|
||||
esubdivideflag(obedit, em, 1, smooth, fractal, ts->editbutflag|flag, cuts, corner_cut_pattern, 0);
|
||||
|
||||
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
|
||||
@@ -6743,7 +6753,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
void MESH_OT_subdivide(wmOperatorType *ot)
|
||||
{
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Subdivide";
|
||||
ot->description= "Subdivide selected edges";
|
||||
@@ -6760,6 +6770,7 @@ void MESH_OT_subdivide(wmOperatorType *ot)
|
||||
RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10);
|
||||
RNA_def_float(ot->srna, "smoothness", 0.0f, 0.0f, FLT_MAX, "Smoothness", "Smoothness factor.", 0.0f, 1000.0f);
|
||||
RNA_def_float(ot->srna, "fractal", 0.0, 0.0f, FLT_MAX, "Fractal", "Fractal randomness factor.", 0.0f, 1000.0f);
|
||||
RNA_def_enum(ot->srna, "corner_cut_pattern", corner_type_items, SUBDIV_CORNER_INNERVERT, "Corner Cut Pattern", "Topology pattern to use to fill a face after cutting across its corner");
|
||||
}
|
||||
|
||||
/********************** Fill Operators *************************/
|
||||
|
||||
@@ -270,7 +270,7 @@ static void ringsel_finish(bContext *C, wmOperator *op)
|
||||
edgering_sel(lcd, cuts, 1);
|
||||
if (lcd->do_cut) {
|
||||
EditMesh *em = BKE_mesh_get_editmesh(lcd->ob->data);
|
||||
esubdivideflag(lcd->ob, em, SELECT, 0.0f, 0.0f, 0, cuts, SUBDIV_SELECT_LOOPCUT);
|
||||
esubdivideflag(lcd->ob, em, SELECT, 0.0f, 0.0f, 0, cuts, 0, SUBDIV_SELECT_LOOPCUT);
|
||||
|
||||
DAG_id_flush_update(lcd->ob->data, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, lcd->ob->data);
|
||||
|
||||
@@ -197,9 +197,16 @@ extern EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short st
|
||||
#define SUBDIV_SELECT_INNER_SEL 2
|
||||
#define SUBDIV_SELECT_LOOPCUT 3
|
||||
|
||||
/* edge subdivide corner cut types */
|
||||
#define SUBDIV_CORNER_PATH 0
|
||||
#define SUBDIV_CORNER_INNERVERT 1
|
||||
#define SUBDIV_CORNER_FAN 2
|
||||
|
||||
extern EnumPropertyItem corner_type_items[];
|
||||
|
||||
void join_triangles(EditMesh *em);
|
||||
int removedoublesflag(EditMesh *em, short flag, short automerge, float limit); /* return amount */
|
||||
void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float fractal, int beautify, int numcuts, int seltype);
|
||||
void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float fractal, int beautify, int numcuts, int corner_pattern, int seltype);
|
||||
int EdgeSlide(EditMesh *em, struct wmOperator *op, short immediate, float imperc);
|
||||
|
||||
void MESH_OT_merge(struct wmOperatorType *ot);
|
||||
|
||||
Reference in New Issue
Block a user