[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55771] trunk/blender/source/blender: fix [#34802] Individual Transformation Confusing in Edit Mode
Campbell Barton
ideasman42 at gmail.com
Thu Apr 4 11:20:47 CEST 2013
Revision: 55771
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55771
Author: campbellbarton
Date: 2013-04-04 09:20:46 +0000 (Thu, 04 Apr 2013)
Log Message:
-----------
fix [#34802] Individual Transformation Confusing in Edit Mode
Individual transformation now works in editmode mesh faces/edge, armature bones and metaballs.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_marking.c
trunk/blender/source/blender/editors/transform/transform_constraints.c
trunk/blender/source/blender/editors/transform/transform_conversions.c
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_marking.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_marking.c 2013-04-04 08:47:07 UTC (rev 55770)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_marking.c 2013-04-04 09:20:46 UTC (rev 55771)
@@ -619,7 +619,7 @@
}
else if (ese->htype == BM_FACE) {
BMFace *efa = (BMFace *)ese->ele;
- BM_face_calc_center_bounds(efa, r_center);
+ BM_face_calc_center_mean(efa, r_center);
}
}
Modified: trunk/blender/source/blender/editors/transform/transform_constraints.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_constraints.c 2013-04-04 08:47:07 UTC (rev 55770)
+++ trunk/blender/source/blender/editors/transform/transform_constraints.c 2013-04-04 09:20:46 UTC (rev 55771)
@@ -557,13 +557,17 @@
void setLocalConstraint(TransInfo *t, int mode, const char text[])
{
+ /* edit-mode now allows local transforms too */
+#if 0
if (t->flag & T_EDIT) {
float obmat[3][3];
copy_m3_m4(obmat, t->scene->obedit->obmat);
normalize_m3(obmat);
setConstraint(t, obmat, mode, text);
}
- else {
+ else
+#endif
+ {
if (t->total == 1) {
setConstraint(t, t->data->axismtx, mode, text);
}
@@ -743,37 +747,42 @@
static void drawObjectConstraint(TransInfo *t)
{
- int i;
- TransData *td = t->data;
-
/* Draw the first one lighter because that's the one who controls the others.
* Meaning the transformation is projected on that one and just copied on the others
* constraint space.
* In a nutshell, the object with light axis is controlled by the user and the others follow.
* Without drawing the first light, users have little clue what they are doing.
*/
- if (t->con.mode & CON_AXIS0) {
- drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', DRAWLIGHT);
- }
- if (t->con.mode & CON_AXIS1) {
- drawLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', DRAWLIGHT);
- }
- if (t->con.mode & CON_AXIS2) {
- drawLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', DRAWLIGHT);
- }
+ short options = DRAWLIGHT;
+ TransData *td = t->data;
+ int i;
- td++;
+ for (i = 0; i < t->total; i++, td++) {
+ float co[3];
- for (i = 1; i < t->total; i++, td++) {
+ if (t->flag & T_OBJECT) {
+ copy_v3_v3(co, td->ob->obmat[3]);
+ }
+ else if (t->flag & T_EDIT) {
+ mul_v3_m4v3(co, t->obedit->obmat, td->center);
+ }
+ else if (t->flag & T_POSE) {
+ mul_v3_m4v3(co, t->poseobj->obmat, td->center);
+ }
+ else {
+ copy_v3_v3(co, td->center);
+ }
+
if (t->con.mode & CON_AXIS0) {
- drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0);
+ drawLine(t, td->center, td->axismtx[0], 'X', options);
}
if (t->con.mode & CON_AXIS1) {
- drawLine(t, td->ob->obmat[3], td->axismtx[1], 'Y', 0);
+ drawLine(t, td->center, td->axismtx[1], 'Y', options);
}
if (t->con.mode & CON_AXIS2) {
- drawLine(t, td->ob->obmat[3], td->axismtx[2], 'Z', 0);
+ drawLine(t, td->center, td->axismtx[2], 'Z', options);
}
+ options &= ~DRAWLIGHT;
}
}
Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c 2013-04-04 08:47:07 UTC (rev 55770)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c 2013-04-04 09:20:46 UTC (rev 55771)
@@ -1236,6 +1236,8 @@
copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
+ quat_to_mat3(td->axismtx, ml->quat);
+
if (ml->flag & SELECT) td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
else td->flag = TD_USEQUAT;
@@ -1858,32 +1860,29 @@
MEM_freeN(tots);
}
-/* loop-in-a-loop I know, but we need it! (ton) */
-static void get_face_center(float r_cent[3], BMVert *eve)
-
+static BMElem *bm_vert_single_select_face(BMVert *eve)
{
- BMFace *efa;
+ BMElem *ele;
BMIter iter;
- BM_ITER_ELEM (efa, &iter, eve, BM_FACES_OF_VERT) {
- if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
- BM_face_calc_center_mean(efa, r_cent);
- break;
+ BM_ITER_ELEM (ele, &iter, eve, BM_FACES_OF_VERT) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ return ele;
}
}
+ return NULL;
}
-
-static void get_edge_center(float r_cent[3], BMVert *eve)
+static BMElem *bm_vert_single_select_edge(BMVert *eve)
{
- BMEdge *eed;
+ BMElem *ele;
BMIter iter;
- BM_ITER_ELEM (eed, &iter, eve, BM_EDGES_OF_VERT) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- mid_v3_v3v3(r_cent, eed->v1->co, eed->v2->co);
- break;
+ BM_ITER_ELEM (ele, &iter, eve, BM_EDGES_OF_VERT) {
+ if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
+ return ele;
}
}
+ return NULL;
}
/* way to overwrite what data is edited with transform */
@@ -1895,26 +1894,54 @@
// td->loc = key->co;
//else
td->loc = eve->co;
+ copy_v3_v3(td->iloc, td->loc);
- copy_v3_v3(td->center, td->loc);
if (t->around == V3D_LOCAL) {
- if (em->selectmode & SCE_SELECT_FACE)
- get_face_center(td->center, eve);
- else if (em->selectmode & SCE_SELECT_EDGE)
- get_edge_center(td->center, eve);
+ BMElem *ele;
+ bool is_axismat_set = false;
+
+ if (em->selectmode & (SCE_SELECT_FACE | SCE_SELECT_EDGE) &&
+ (ele = ((em->selectmode & SCE_SELECT_FACE) ?
+ bm_vert_single_select_face(eve) :
+ bm_vert_single_select_edge(eve))))
+ {
+ float normal[3], tangent[3];
+
+ BMEditSelection ese;
+ ese.next = ese.prev = NULL;
+ ese.ele = ele;
+ ese.htype = ele->head.htype;
+
+ BM_editselection_center(&ese, td->center);
+ BM_editselection_normal(&ese, normal);
+ BM_editselection_plane(&ese, tangent);
+
+ if (createSpaceNormalTangent(td->axismtx, normal, tangent)) {
+ is_axismat_set = true;
+ }
+ }
+
+ /* for verts or fallback when createSpaceNormalTangent fails */
+ if (is_axismat_set == false) {
+ axis_dominant_v3_to_m3(td->axismtx, eve->no);
+ invert_m3(td->axismtx);
+ }
}
- copy_v3_v3(td->iloc, td->loc);
+ else {
+ copy_v3_v3(td->center, td->loc);
- // Setting normals
- copy_v3_v3(td->axismtx[2], eve->no);
- td->axismtx[0][0] =
- td->axismtx[0][1] =
- td->axismtx[0][2] =
- td->axismtx[1][0] =
- td->axismtx[1][1] =
- td->axismtx[1][2] = 0.0f;
+ /* Setting normals */
+ copy_v3_v3(td->axismtx[2], eve->no);
+ td->axismtx[0][0] =
+ td->axismtx[0][1] =
+ td->axismtx[0][2] =
+ td->axismtx[1][0] =
+ td->axismtx[1][1] =
+ td->axismtx[1][2] = 0.0f;
+ }
+
td->ext = NULL;
td->val = NULL;
td->extra = NULL;
More information about the Bf-blender-cvs
mailing list