forked from bartvdbraak/blender
fix [#27016] Add new vertex at wrong position ( bpy.ops.mesh.dupli_extrude_cursor() )
also found curve click-extrude was always aligning the new points depth to (0,0,0), now work the same as mesh edit - align to the selected point or the cursor if none are seleted.
This commit is contained in:
parent
ba229e3859
commit
1d536da57e
@ -4413,11 +4413,10 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
Nurb *nu, *newnu= NULL;
|
Nurb *nu, *newnu= NULL;
|
||||||
BezTriple *bezt, *newbezt = NULL;
|
BezTriple *bezt, *newbezt = NULL;
|
||||||
BPoint *bp, *newbp = NULL;
|
BPoint *bp, *newbp = NULL;
|
||||||
float mat[3][3],imat[3][3], temp[3];
|
float imat[4][4], temp[3];
|
||||||
int ok= 0;
|
int ok= 0;
|
||||||
|
|
||||||
copy_m3_m4(mat, obedit->obmat);
|
invert_m4_m4(imat, obedit->obmat);
|
||||||
invert_m3_m3(imat,mat);
|
|
||||||
|
|
||||||
findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp);
|
findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp);
|
||||||
|
|
||||||
@ -4451,10 +4450,14 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
temp[0] = 1;
|
temp[0] = 1;
|
||||||
temp[1] = 0;
|
temp[1] = 0;
|
||||||
temp[2] = 0;
|
temp[2] = 0;
|
||||||
|
|
||||||
copy_v3_v3(newbezt->vec[1], location);
|
copy_v3_v3(newbezt->vec[1], location);
|
||||||
sub_v3_v3(newbezt->vec[1], obedit->obmat[3]);
|
sub_v3_v3v3(newbezt->vec[0], newbezt->vec[1], temp);
|
||||||
sub_v3_v3v3(newbezt->vec[0], newbezt->vec[1],temp);
|
add_v3_v3v3(newbezt->vec[2], newbezt->vec[1], temp);
|
||||||
add_v3_v3v3(newbezt->vec[2], newbezt->vec[1],temp);
|
|
||||||
|
mul_m4_v3(imat, newbezt->vec[0]);
|
||||||
|
mul_m4_v3(imat, newbezt->vec[1]);
|
||||||
|
mul_m4_v3(imat, newbezt->vec[2]);
|
||||||
|
|
||||||
ok= 1;
|
ok= 1;
|
||||||
nu= newnu;
|
nu= newnu;
|
||||||
@ -4473,9 +4476,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
newnu->orderu= 2;
|
newnu->orderu= 2;
|
||||||
newnu->pntsu= 1;
|
newnu->pntsu= 1;
|
||||||
|
|
||||||
copy_v3_v3(newbp->vec, location);
|
mul_v3_m4v3(newbp->vec, imat, location);
|
||||||
sub_v3_v3(newbp->vec, obedit->obmat[3]);
|
|
||||||
mul_m3_v3(imat,newbp->vec);
|
|
||||||
newbp->vec[3]= 1.0;
|
newbp->vec[3]= 1.0;
|
||||||
|
|
||||||
newnu->knotsu= newnu->knotsv= NULL;
|
newnu->knotsu= newnu->knotsv= NULL;
|
||||||
@ -4555,9 +4556,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
copy_v3_v3(newbezt->vec[2], bezt->vec[2]);
|
copy_v3_v3(newbezt->vec[2], bezt->vec[2]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copy_v3_v3(newbezt->vec[1], location);
|
mul_v3_m4v3(newbezt->vec[1], imat, location);
|
||||||
sub_v3_v3(newbezt->vec[1], obedit->obmat[3]);
|
|
||||||
mul_m3_v3(imat,newbezt->vec[1]);
|
|
||||||
sub_v3_v3v3(temp, newbezt->vec[1],temp);
|
sub_v3_v3v3(temp, newbezt->vec[1],temp);
|
||||||
add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp);
|
add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp);
|
||||||
add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp);
|
add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp);
|
||||||
@ -4622,9 +4621,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
|
|||||||
copy_v3_v3(newbp->vec, bp->vec);
|
copy_v3_v3(newbp->vec, bp->vec);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
copy_v3_v3(newbp->vec, location);
|
mul_v3_m4v3(newbp->vec, imat, location);
|
||||||
sub_v3_v3(newbp->vec, obedit->obmat[3]);
|
|
||||||
mul_m3_v3(imat,newbp->vec);
|
|
||||||
newbp->vec[3]= 1.0;
|
newbp->vec[3]= 1.0;
|
||||||
|
|
||||||
if(!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu)
|
if(!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu)
|
||||||
@ -4666,13 +4663,33 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
|
|||||||
static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
||||||
ViewContext vc;
|
|
||||||
float location[3] = {0.0f, 0.0f, 0.0f};
|
|
||||||
short mval[2];
|
|
||||||
|
|
||||||
if(rv3d && !RNA_property_is_set(op->ptr, "location")) {
|
if(rv3d && !RNA_property_is_set(op->ptr, "location")) {
|
||||||
|
Curve *cu;
|
||||||
|
ViewContext vc;
|
||||||
|
float location[3];
|
||||||
|
short mval[2];
|
||||||
|
|
||||||
|
Nurb *nu;
|
||||||
|
BezTriple *bezt;
|
||||||
|
BPoint *bp;
|
||||||
|
|
||||||
view3d_set_viewcontext(C, &vc);
|
view3d_set_viewcontext(C, &vc);
|
||||||
|
|
||||||
|
cu= vc.obedit->data;
|
||||||
|
|
||||||
|
findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp);
|
||||||
|
|
||||||
|
if(bezt) {
|
||||||
|
mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]);
|
||||||
|
}
|
||||||
|
else if (bp) {
|
||||||
|
mul_v3_m4v3(location, vc.obedit->obmat, bp->vec);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
copy_v3_v3(location, give_cursor(vc.scene, vc.v3d));
|
||||||
|
}
|
||||||
|
|
||||||
mval[0]= event->x - vc.ar->winrct.xmin;
|
mval[0]= event->x - vc.ar->winrct.xmin;
|
||||||
mval[1]= event->y - vc.ar->winrct.ymin;
|
mval[1]= event->y - vc.ar->winrct.ymin;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
|
|||||||
|
|
||||||
/* call extrude? */
|
/* call extrude? */
|
||||||
if(done) {
|
if(done) {
|
||||||
short rot_src= RNA_boolean_get(op->ptr, "rotate_source");
|
const short rot_src= RNA_boolean_get(op->ptr, "rotate_source");
|
||||||
EditEdge *eed;
|
EditEdge *eed;
|
||||||
float vec[3], cent[3], mat[3][3];
|
float vec[3], cent[3], mat[3][3];
|
||||||
float nor[3]= {0.0, 0.0, 0.0};
|
float nor[3]= {0.0, 0.0, 0.0};
|
||||||
@ -246,20 +246,16 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
|
|||||||
}
|
}
|
||||||
else if(vc.em->selectmode & SCE_SELECT_VERTEX) {
|
else if(vc.em->selectmode & SCE_SELECT_VERTEX) {
|
||||||
|
|
||||||
float mat[3][3],imat[3][3];
|
float imat[4][4];
|
||||||
float *curs= give_cursor(vc.scene, vc.v3d);
|
const float *curs= give_cursor(vc.scene, vc.v3d);
|
||||||
|
|
||||||
copy_v3_v3(min, curs);
|
copy_v3_v3(min, curs);
|
||||||
view3d_get_view_aligned_coordinate(&vc, min, event->mval);
|
view3d_get_view_aligned_coordinate(&vc, min, event->mval);
|
||||||
|
|
||||||
eve= addvertlist(vc.em, 0, NULL);
|
eve= addvertlist(vc.em, 0, NULL);
|
||||||
|
|
||||||
copy_m3_m4(mat, vc.obedit->obmat);
|
invert_m4_m4(imat, vc.obedit->obmat);
|
||||||
invert_m3_m3(imat, mat);
|
mul_v3_m4v3(eve->co, imat, min);
|
||||||
|
|
||||||
copy_v3_v3(eve->co, min);
|
|
||||||
mul_m3_v3(imat, eve->co);
|
|
||||||
sub_v3_v3v3(eve->co, eve->co, vc.obedit->obmat[3]);
|
|
||||||
|
|
||||||
eve->f= SELECT;
|
eve->f= SELECT;
|
||||||
}
|
}
|
||||||
|
@ -788,9 +788,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op))
|
|||||||
VECCOPY(curs, centroid);
|
VECCOPY(curs, centroid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
curs[0]= (min[0]+max[0])/2;
|
mid_v3_v3v3(curs, min, max);
|
||||||
curs[1]= (min[1]+max[1])/2;
|
|
||||||
curs[2]= (min[2]+max[2])/2;
|
|
||||||
}
|
}
|
||||||
MEM_freeN(transvmain);
|
MEM_freeN(transvmain);
|
||||||
transvmain= NULL;
|
transvmain= NULL;
|
||||||
@ -828,9 +826,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op))
|
|||||||
VECCOPY(curs, centroid);
|
VECCOPY(curs, centroid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
curs[0]= (min[0]+max[0])/2;
|
mid_v3_v3v3(curs, min, max);
|
||||||
curs[1]= (min[1]+max[1])/2;
|
|
||||||
curs[2]= (min[2]+max[2])/2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user