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-04-10 15:45:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-04-10 15:45:07 +0400
commit5a3ab0e32ecff0f1ff4cfc8cedf64f63b2291a5b (patch)
treecb38143220cd31d4cbe3775bb57853e46f3ffc9e /source/blender/src/meshtools.c
parenta64339d319a9e2b4de31adca0e546d3109c5f041 (diff)
Found a bug where "make dupes real" would crash, when the group was an extternal link. - 1 liner fix from Ton.
Also added "sort faces by selection" to the sort menu. DNA_meshdata_types use C comments for GCC verbose warnings to be quiet
Diffstat (limited to 'source/blender/src/meshtools.c')
-rw-r--r--source/blender/src/meshtools.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c
index e61cfd12a86..90689feee2c 100644
--- a/source/blender/src/meshtools.c
+++ b/source/blender/src/meshtools.c
@@ -477,7 +477,7 @@ void sort_faces(void)
if(G.obedit) return;
if(ob->type!=OB_MESH) return;
- event = pupmenu("Sort 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|Randomize%x5");
+ event = pupmenu("Sort 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|Selected First%x5|Selected Last%x6|Randomize%x7");
if (event==-1) return;
me= ob->data;
@@ -493,12 +493,12 @@ void sort_faces(void)
/* sort index list instead of faces itself
and apply this permutation to all face layers */
- if (event == 5) {
+ if (event == 7) {
/* Random */
for(i=0; i<me->totface; i++) {
face_sort_floats[i] = BLI_frand();
}
- qsort(index, me->totface, sizeof(int), float_sort);
+ qsort(index, me->totface, sizeof(int), float_sort);
} else { /* event is 1 or 2*/
MFace *mf;
float vec[3];
@@ -521,28 +521,39 @@ void sort_faces(void)
mf= me->mface;
for(i=0; i<me->totface; i++, mf++) {
- /* find the faces center */
- VECADD(vec, (me->mvert+mf->v1)->co, (me->mvert+mf->v2)->co);
- if (mf->v4) {
- VECADD(vec, vec, (me->mvert+mf->v3)->co);
- VECADD(vec, vec, (me->mvert+mf->v4)->co);
- VECMUL(vec, 0.25f);
- } else {
- VECADD(vec, vec, (me->mvert+mf->v3)->co);
- VECMUL(vec, 1.0f/3.0f);
- } /* done */
- 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*/
+ if (event==5) {
+ /*selected first*/
+ if (mf->flag & ME_FACE_SEL) face_sort_floats[i] = 0.0;
+ else face_sort_floats[i] = 1.0;
+ } else if (event==6) {
+ /*selected last*/
+ if (mf->flag & ME_FACE_SEL) face_sort_floats[i] = 1.0;
+ else face_sort_floats[i] = 0.0;
+ } else {
+ /* find the faces center */
+ VECADD(vec, (me->mvert+mf->v1)->co, (me->mvert+mf->v2)->co);
+ if (mf->v4) {
+ VECADD(vec, vec, (me->mvert+mf->v3)->co);
+ VECADD(vec, vec, (me->mvert+mf->v4)->co);
+ VECMUL(vec, 0.25f);
+ } else {
+ VECADD(vec, vec, (me->mvert+mf->v3)->co);
+ VECMUL(vec, 1.0f/3.0f);
+ } /* done */
+
+ 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), float_sort);