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:
authorCampbell Barton <ideasman42@gmail.com>2007-03-01 13:51:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-03-01 13:51:28 +0300
commite966aa549e44fb96848506b3d84607ee2411c861 (patch)
tree48660f364d8adcb0787a616fe6d402b2405b9843 /source/blender/src/meshtools.c
parentdafdc0e8363ad4889112651c0fffedaca03bbae2 (diff)
added face sorting from the distance to cursor. (near to far and far to near)
Diffstat (limited to 'source/blender/src/meshtools.c')
-rw-r--r--source/blender/src/meshtools.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c
index 4a33994588e..75c144f5467 100644
--- a/source/blender/src/meshtools.c
+++ b/source/blender/src/meshtools.c
@@ -497,7 +497,7 @@ void sort_faces(void)
if(G.obedit) return;
if(ob->type!=OB_MESH) return;
- event = pupmenu("Soft Faces by%t|View Axis (back to front)%x1|View Axis (front to back)%x2|Z Axis%x3");
+ event = pupmenu("Soft Faces by%t|View Axis (back to front)%x1|View Axis (front to back)%x2|Cursor Distance (near to far)%x3|Cursor Distance (far to near)%x4|Z Axis%x5");
if (event==-1) return;
me= ob->data;
@@ -513,16 +513,27 @@ void sort_faces(void)
/* sort index list instead of faces itself
and apply this permutation to all face layers */
- if (event == 3) {
+ if (event == 5) {
qsort(index, me->totface, sizeof(int), verg_mface);
} else { /* event is 1 or 2*/
MFace *mf;
float vec[3];
float mat[4][4];
+ float cur[3];
if (!G.vd) return;
- Mat4MulMat4(mat, OBACT->obmat, G.vd->viewmat); /* apply the view matrix to the object matrix */
+ if (event == 1 || event == 2)
+ Mat4MulMat4(mat, OBACT->obmat, G.vd->viewmat); /* apply the view matrix to the object matrix */
+ else if (event == 3 || event == 4) { /* sort from cursor */
+ if( G.vd && G.vd->localview ) {
+ VECCOPY(cur, G.vd->cursor);
+ } else {
+ VECCOPY(cur, G.scene->cursor);
+ }
+ Mat4Invert(mat, OBACT->obmat);
+ Mat4MulVecfl(mat, cur);
+ }
face_sort_floats = (float *) MEM_mallocN(sizeof(float) * me->totface, "sort faces float");
@@ -539,12 +550,18 @@ void sort_faces(void)
VECMUL(vec, 1.0f/3.0f);
} /* done */
- Mat4MulVecfl(mat, vec);
- if (event==2)
- face_sort_floats[i] = -vec[2]; /* front to back */
- else
- face_sort_floats[i] = vec[2]; /* back to front */
-
+ if (event == 1 || event == 2) { /* sort on view axis */
+ Mat4MulVecfl(mat, vec);
+ if (event==2)
+ face_sort_floats[i] = -vec[2]; /* front to back */
+ else
+ face_sort_floats[i] = vec[2]; /* back to front */
+ } else { /* distance from cursor*/
+ if (event==3)
+ face_sort_floats[i] = VecLenf(cur, vec); /* back to front */
+ else if (event==4)
+ face_sort_floats[i] = -VecLenf(cur, vec); /* front to back*/
+ }
}
qsort(index, me->totface, sizeof(int), vert_mface_floats);
MEM_freeN(face_sort_floats);