diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-03-27 12:25:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-03-27 12:25:06 +0400 |
commit | 0e8e848588ec8b766e655463ace853db89d87032 (patch) | |
tree | f94ff6c827f875913f2d9d0891d0f716d12d1a59 /source/blender/src/transform_manipulator.c | |
parent | af9573e9eaf9314e9d07575802d34c17bb1091b3 (diff) |
Seperated out some functionality into 3 new functions.
EM_editselection_center
EM_editselection_normal
EM_editselection_plane
These functions are used by the manipulator to get data from an editselection. regardless of weather its a face/edge/vert.
Diffstat (limited to 'source/blender/src/transform_manipulator.c')
-rw-r--r-- | source/blender/src/transform_manipulator.c | 91 |
1 files changed, 7 insertions, 84 deletions
diff --git a/source/blender/src/transform_manipulator.c b/source/blender/src/transform_manipulator.c index 9eb6e85da68..815579ed24e 100644 --- a/source/blender/src/transform_manipulator.c +++ b/source/blender/src/transform_manipulator.c @@ -234,90 +234,13 @@ int calc_manipulator_stats(ScrArea *sa) /* USE LAST SELECTE WITH ACTIVE */ if (G.vd->around==V3D_ACTIVE && em->selected.last) { - /*selection types*/ - EditSelection *ese; - EditFace *efa; - EditEdge *eed; - /*eve alredy defined*/ - ese= em->selected.last; - if (ese->type==EDITVERT) { /*VERT*/ - eve= ese->data; - calc_tw_center(eve->co); - totsel= 1; - if (v3d->twmode == V3D_MANIP_NORMAL) - VecCopyf(normal, eve->no); - - /* make a fake plane thats at rightangles to the normal - we cant make a crossvec from a vec thats the same as the vec - unlikely but possible, so make sure if the normal is (0,0,1) - that vec isnt the same or in the same direction even.*/ - if (normal[0]<0.5) vec[0]=1; - else if (normal[1]<0.5) vec[1]=1; - else vec[2]=1; - Crossf(plane, normal, vec); - - } else if (ese->type==EDITEDGE) { /*EDGE*/ - eed= ese->data; - calc_tw_center(eed->v1->co); - calc_tw_center(eed->v2->co); - totsel= 2; - if (v3d->twmode == V3D_MANIP_NORMAL) { - VecCopyf(normal, eed->v1->no); - VECADD(normal, normal, eed->v2->no); - } - /*the plane is simple, it runs allong the edge - however selecting different edges can swap the direction of the y axis. - this makes it less likely for the y axis of the manipulator - (running along the edge).. to flip less often. - at least its more pradictable */ - if (eed->v2->co[1] > eed->v1->co[1]) /*check which to do first */ - VecSubf(plane, eed->v2->co, eed->v1->co); - else - VecSubf(plane, eed->v1->co, eed->v2->co); - - /* the 2 vertex normals will be close but not at rightangles to the edge - for rotate about edge we want them to be at right angles, so we need to - do some extra colculation to correct the vert normals, - we need the plane for this */ - Crossf(vec, normal, plane); - Crossf(normal, plane, vec); - - } else if (ese->type==EDITFACE) { /*FACE*/ - efa= ese->data; - calc_tw_center(efa->cent); - totsel=1; - - if (v3d->twmode == V3D_MANIP_NORMAL) - VecCopyf(normal, efa->n); - - if (efa->v4) { /*if its a quad- set the plane along the 2 longest edges.*/ - float vecA[3], vecB[3]; - VecSubf(vecA, efa->v4->co, efa->v3->co); - VecSubf(vecB, efa->v1->co, efa->v2->co); - VecAddf(plane, vecA, vecB); - - VecSubf(vecA, efa->v1->co, efa->v4->co); - VecSubf(vecB, efa->v2->co, efa->v3->co); - VecAddf(vec, vecA, vecB); - /*use the biggest edge length*/ - if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) - VecCopyf(plane, vec); - } else { - /*start with v1-2 */ - VecSubf(plane, efa->v1->co, efa->v2->co); - - /*test the edge between v2-3, use if longer */ - VecSubf(vec, efa->v2->co, efa->v3->co); - if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) - VecCopyf(plane, vec); - - /*test the edge between v1-3, use if longer */ - VecSubf(vec, efa->v3->co, efa->v1->co); - if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) - VecCopyf(plane, vec); - } - } - + 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; |