Revision: 36216
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36216
Author:   campbellbarton
Date:     2011-04-19 05:34:05 +0000 (Tue, 19 Apr 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/mesh/editmesh_add.c
    trunk/blender/source/blender/editors/space_view3d/view3d_snap.c

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c      2011-04-19 
04:19:09 UTC (rev 36215)
+++ trunk/blender/source/blender/editors/curve/editcurve.c      2011-04-19 
05:34:05 UTC (rev 36216)
@@ -4413,11 +4413,10 @@
        Nurb *nu, *newnu= NULL;
        BezTriple *bezt, *newbezt = NULL;
        BPoint *bp, *newbp = NULL;
-       float mat[3][3],imat[3][3], temp[3];
+       float imat[4][4], temp[3];
        int ok= 0;
 
-       copy_m3_m4(mat, obedit->obmat);
-       invert_m3_m3(imat,mat);
+       invert_m4_m4(imat, obedit->obmat);
 
        findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp);
 
@@ -4451,11 +4450,15 @@
                                temp[0] = 1;
                                temp[1] = 0;
                                temp[2] = 0;
+
                                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);
-                               add_v3_v3v3(newbezt->vec[2], 
newbezt->vec[1],temp);
+                               sub_v3_v3v3(newbezt->vec[0], 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;
                                nu= newnu;
                        } else if(nu->pntsv == 1) {
@@ -4473,9 +4476,7 @@
                                newnu->orderu= 2;
                                newnu->pntsu= 1;
 
-                               copy_v3_v3(newbp->vec, location);
-                               sub_v3_v3(newbp->vec, obedit->obmat[3]);
-                               mul_m3_v3(imat,newbp->vec);
+                               mul_v3_m4v3(newbp->vec, imat, location);
                                newbp->vec[3]= 1.0;
 
                                newnu->knotsu= newnu->knotsv= NULL;
@@ -4555,9 +4556,7 @@
                                copy_v3_v3(newbezt->vec[2], bezt->vec[2]);
                        }
                        else {
-                               copy_v3_v3(newbezt->vec[1], location);
-                               sub_v3_v3(newbezt->vec[1], obedit->obmat[3]);
-                               mul_m3_v3(imat,newbezt->vec[1]);
+                               mul_v3_m4v3(newbezt->vec[1], imat, location);
                                sub_v3_v3v3(temp, newbezt->vec[1],temp);
                                add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp);
                                add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp);
@@ -4622,9 +4621,7 @@
                                copy_v3_v3(newbp->vec, bp->vec);
                        }
                        else {
-                               copy_v3_v3(newbp->vec, location);
-                               sub_v3_v3(newbp->vec, obedit->obmat[3]);
-                               mul_m3_v3(imat,newbp->vec);
+                               mul_v3_m4v3(newbp->vec, imat, location);
                                newbp->vec[3]= 1.0;
 
                                if(!newnu && nu->orderu<4 && 
nu->orderu<=nu->pntsu)
@@ -4666,13 +4663,33 @@
 static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        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")) {
+               Curve *cu;
+               ViewContext vc;
+               float location[3];
+               short mval[2];
+
+               Nurb *nu;
+               BezTriple *bezt;
+               BPoint *bp;
+
                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[1]= event->y - vc.ar->winrct.ymin;
                

Modified: trunk/blender/source/blender/editors/mesh/editmesh_add.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_add.c    2011-04-19 
04:19:09 UTC (rev 36215)
+++ trunk/blender/source/blender/editors/mesh/editmesh_add.c    2011-04-19 
05:34:05 UTC (rev 36216)
@@ -139,7 +139,7 @@
 
        /* call extrude? */
        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;
                float vec[3], cent[3], mat[3][3];
                float nor[3]= {0.0, 0.0, 0.0};
@@ -246,21 +246,17 @@
        }
        else if(vc.em->selectmode & SCE_SELECT_VERTEX) {
 
-               float mat[3][3],imat[3][3];
-               float *curs= give_cursor(vc.scene, vc.v3d);
+               float imat[4][4];
+               const float *curs= give_cursor(vc.scene, vc.v3d);
                
                copy_v3_v3(min, curs);
                view3d_get_view_aligned_coordinate(&vc, min, event->mval);
                
                eve= addvertlist(vc.em, 0, NULL);
 
-               copy_m3_m4(mat, vc.obedit->obmat);
-               invert_m3_m3(imat, mat);
+               invert_m4_m4(imat, vc.obedit->obmat);
+               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;
        }
 

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_snap.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_snap.c     
2011-04-19 04:19:09 UTC (rev 36215)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_snap.c     
2011-04-19 05:34:05 UTC (rev 36216)
@@ -788,9 +788,7 @@
                        VECCOPY(curs, centroid);
                }
                else {
-                       curs[0]= (min[0]+max[0])/2;
-                       curs[1]= (min[1]+max[1])/2;
-                       curs[2]= (min[2]+max[2])/2;
+                       mid_v3_v3v3(curs, min, max);
                }
                MEM_freeN(transvmain);
                transvmain= NULL;
@@ -828,9 +826,7 @@
                                VECCOPY(curs, centroid);
                        }
                        else {
-                               curs[0]= (min[0]+max[0])/2;
-                               curs[1]= (min[1]+max[1])/2;
-                               curs[2]= (min[2]+max[2])/2;
+                               mid_v3_v3v3(curs, min, max);
                        }
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to