Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-02-18 01:19:02 +0300
committerMartin Poirier <theeth@yahoo.com>2008-02-18 01:19:02 +0300
commit83ddab60b72b693faa77068d77eb35f5555b81d2 (patch)
tree1442000f4bf7ba64fb26b376a7299b3a72bb5713 /source/blender/src/transform_manipulator.c
parent417687c4ff052fccd6b8da3931fc85d231504773 (diff)
== Transform Orientations ==
Merge Normal orientation calculations with Custom Orientations, to make it work the same all accross the table: - One or more faces: use average face normal (first edge of faces define tangent) - One edge: use edge itself as normal (vertex normals define tangent) - One vertex: use vertex normal (tangent is perpendicular to normal and z-axis) - Two vertices => edge orientation - Two vertices => face orientation *I tested quite a bit but please report any bugs this might have caused.* ADDED FILE WARNING: source/blender/src/transform_orientations.c
Diffstat (limited to 'source/blender/src/transform_manipulator.c')
-rw-r--r--source/blender/src/transform_manipulator.c102
1 files changed, 48 insertions, 54 deletions
diff --git a/source/blender/src/transform_manipulator.c b/source/blender/src/transform_manipulator.c
index 13a8552b844..734d917e911 100644
--- a/source/blender/src/transform_manipulator.c
+++ b/source/blender/src/transform_manipulator.c
@@ -234,53 +234,20 @@ int calc_manipulator_stats(ScrArea *sa)
EditMesh *em = G.editMesh;
EditVert *eve;
float vec[3]= {0,0,0};
- int no_faces= 1;
/* USE LAST SELECTE WITH ACTIVE */
if (G.vd->around==V3D_ACTIVE && em->selected.last) {
EM_editselection_center(vec, em->selected.last);
calc_tw_center(vec);
totsel= 1;
- if (v3d->twmode == V3D_MANIP_NORMAL) {
- EM_editselection_normal(normal, em->selected.last);
- EM_editselection_plane(plane, em->selected.last);
- } /* NORMAL OPERATION */
} else {
- if(v3d->twmode == V3D_MANIP_NORMAL) {
- EditFace *efa;
-
- for(efa= em->faces.first; efa; efa= efa->next) {
- if(efa->f & SELECT) {
- no_faces= 0;
- VECADD(normal, normal, efa->n);
- VecSubf(vec, efa->v2->co, efa->v1->co);
- VECADD(plane, plane, vec);
- }
- }
- }
-
/* do vertices for center, and if still no normal found, use vertex normals */
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->f & SELECT) {
- if(no_faces) VECADD(normal, normal, eve->no);
-
totsel++;
calc_tw_center(eve->co);
}
}
- /* the edge case... */
- if(no_faces && v3d->twmode == V3D_MANIP_NORMAL) {
- EditEdge *eed;
-
- for(eed= em->edges.first; eed; eed= eed->next) {
- if(eed->f & SELECT) {
- /* ok we got an edge, only use one, and as normal */
- VECCOPY(plane, normal);
- VecSubf(normal, eed->v2->co, eed->v1->co);
- break;
- }
- }
- }
}
} /* end editmesh */
else if (G.obedit->type==OB_ARMATURE){
@@ -314,22 +281,18 @@ int calc_manipulator_stats(ScrArea *sa)
if( (bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT ) {
calc_tw_center(bezt->vec[1]);
totsel++;
- VecSubf(normal, bezt->vec[0], bezt->vec[2]);
}
else {
if(bezt->f1) {
calc_tw_center(bezt->vec[0]);
- VecSubf(normal, bezt->vec[0], bezt->vec[1]);
totsel++;
}
if(bezt->f2) {
calc_tw_center(bezt->vec[1]);
- VecSubf(normal, bezt->vec[0], bezt->vec[2]);
totsel++;
}
if(bezt->f3) {
calc_tw_center(bezt->vec[2]);
- VecSubf(normal, bezt->vec[1], bezt->vec[2]);
totsel++;
}
}
@@ -364,23 +327,6 @@ int calc_manipulator_stats(ScrArea *sa)
}
ml= ml->next;
}
- /* normal manipulator */
- if(totsel==1){
- float mat1[4][4];
-
- /* Rotation of MetaElem is stored in quat */
- QuatToMat4(ml_sel->quat, mat1);
-
- /* Translation of MetaElem */
- mat1[3][0]= ml_sel->x;
- mat1[3][1]= ml_sel->y;
- mat1[3][2]= ml_sel->z;
-
- VECCOPY(normal, mat1[2]);
- VECCOPY(plane, mat1[1]);
-
- VecMulf(plane, -1.0);
- }
}
else if(G.obedit->type==OB_LATTICE) {
BPoint *bp;
@@ -490,6 +436,54 @@ int calc_manipulator_stats(ScrArea *sa)
case V3D_MANIP_NORMAL:
if(G.obedit || (ob->flag & OB_POSEMODE)) {
+ float mat[3][3];
+ int type;
+
+ strcpy(t->spacename, "normal");
+
+ type = getTransformOrientation(normal, plane, 0);
+
+ switch (type)
+ {
+ case ORIENTATION_NORMAL:
+ if (createSpaceNormalTangent(mat, normal, plane) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ case ORIENTATION_VERT:
+ if (createSpaceNormal(mat, normal) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ case ORIENTATION_EDGE:
+ if (createSpaceNormalTangent(mat, normal, plane) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ case ORIENTATION_FACE:
+ if (createSpaceNormalTangent(mat, normal, plane) == 0)
+ {
+ type = ORIENTATION_NONE;
+ }
+ break;
+ }
+
+ if (type == ORIENTATION_NONE)
+ {
+ Mat4One(v3d->twmat);
+ }
+ else
+ {
+ Mat4CpyMat3(v3d->twmat, mat);
+ }
+ break;
+ }
+ /* pose mode is a bit weird, so keep it separated */
+ else if (ob->flag & OB_POSEMODE)
+ {
strcpy(t->spacename, "normal");
if(normal[0]!=0.0 || normal[1]!=0.0 || normal[2]!=0.0) {
float imat[3][3], mat[3][3];