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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2005-04-23 00:16:02 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2005-04-23 00:16:02 +0400
commit6a00fcd90ca8a2c4bd3a0429d37be2ce6c2ac77a (patch)
tree8dadc718838f5d6711917b73991c2fdc2d9a28d6 /source/blender/src
parent43835d4d0450c15c4d8e962c0b979b34325f4c97 (diff)
Add "View Selected" (numpad .-key) for faceselect mode and the uv editor.
Also includes some 2d vector operations (subtract, dot, normalise).
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/drawimage.c29
-rw-r--r--source/blender/src/editface.c48
-rw-r--r--source/blender/src/editsima.c39
-rw-r--r--source/blender/src/header_image.c3
-rw-r--r--source/blender/src/space.c4
-rw-r--r--source/blender/src/view.c5
6 files changed, 128 insertions, 0 deletions
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index b10837a9bfd..6eda482f840 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -1020,3 +1020,32 @@ void image_home(void)
scrarea_queue_winredraw(curarea);
}
+void image_viewcentre(void)
+{
+ float size, min[2], max[2], d[2], xim=256.0f, yim=256.0f;
+
+ if( is_uv_tface_editing_allowed()==0 ) return;
+
+ if (!minmax_tface_uv(min, max)) return;
+
+ if(G.sima->image && G.sima->image->ibuf) {
+ xim= G.sima->image->ibuf->x;
+ yim= G.sima->image->ibuf->y;
+ }
+
+ G.sima->xof= ((min[0] + max[0])*0.5f - 0.5f)*xim;
+ G.sima->yof= ((min[1] + max[1])*0.5f - 0.5f)*yim;
+
+ d[0] = max[0] - min[0];
+ d[1] = max[1] - min[1];
+ size= 0.5*MAX2(d[0], d[1])*MAX2(xim, yim)/256.0f;
+
+ if(size<=0.01) size= 0.01;
+
+ G.sima->zoom= 1.0/size;
+
+ calc_image_view(G.sima, 'p');
+
+ scrarea_queue_winredraw(curarea);
+}
+
diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c
index f2a8dbcf316..a9864ccd303 100644
--- a/source/blender/src/editface.c
+++ b/source/blender/src/editface.c
@@ -844,6 +844,54 @@ void rotate_uv_tface()
allqueue(REDRAWIMAGE, 0);
}
+void minmax_tface(float *min, float *max)
+{
+ Object *ob;
+ Mesh *me;
+ MFace *mf;
+ TFace *tf;
+ MVert *mv;
+ int a;
+ float vec[3], bmat[3][3];
+
+ ob = OBACT;
+ if (ob==0) return;
+ me= get_mesh(ob);
+ if(me==0 || me->tface==0) return;
+
+ Mat3CpyMat4(bmat, ob->obmat);
+
+ mv= me->mvert;
+ mf= me->mface;
+ tf= me->tface;
+ for (a=me->totface; a>0; a--, mf++, tf++) {
+ if (!mf->v3 || tf->flag & TF_HIDE || !(tf->flag & TF_SELECT))
+ continue;
+
+ VECCOPY(vec, (mv+mf->v1)->co);
+ Mat3MulVecfl(bmat, vec);
+ VecAddf(vec, vec, ob->obmat[3]);
+ DO_MINMAX(vec, min, max);
+
+ VECCOPY(vec, (mv+mf->v2)->co);
+ Mat3MulVecfl(bmat, vec);
+ VecAddf(vec, vec, ob->obmat[3]);
+ DO_MINMAX(vec, min, max);
+
+ VECCOPY(vec, (mv+mf->v3)->co);
+ Mat3MulVecfl(bmat, vec);
+ VecAddf(vec, vec, ob->obmat[3]);
+ DO_MINMAX(vec, min, max);
+
+ if (mf->v4) {
+ VECCOPY(vec, (mv+mf->v4)->co);
+ Mat3MulVecfl(bmat, vec);
+ VecAddf(vec, vec, ob->obmat[3]);
+ DO_MINMAX(vec, min, max);
+ }
+ }
+}
+
/**
* Returns the face under the give position in screen coordinates.
* Code extracted from face_select routine.
diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c
index 25c1d82fb7f..4de8824cb6c 100644
--- a/source/blender/src/editsima.c
+++ b/source/blender/src/editsima.c
@@ -1739,3 +1739,42 @@ void pin_tface_uv(int mode)
scrarea_queue_winredraw(curarea);
}
+int minmax_tface_uv(float *min, float *max)
+{
+ Mesh *me;
+ TFace *tf;
+ MFace *mf;
+ int a, sel;
+
+ if( is_uv_tface_editing_allowed()==0 ) return 0;
+ me= get_mesh(OBACT);
+
+ INIT_MINMAX2(min, max);
+
+ sel= 0;
+ mf= (MFace*)me->mface;
+ tf= (TFace*)me->tface;
+ for(a=me->totface; a>0; a--, tf++, mf++) {
+ if(tf->flag & TF_HIDE);
+ else if(mf->v3 && (tf->flag & TF_SELECT)) {
+
+ if (tf->flag & TF_SEL1) {
+ DO_MINMAX2(tf->uv[0], min, max);
+ }
+ if (tf->flag & TF_SEL2) {
+ DO_MINMAX2(tf->uv[1], min, max);
+ }
+ if (tf->flag & TF_SEL3) {
+ DO_MINMAX2(tf->uv[2], min, max);
+ }
+ if (mf->v4 && tf->flag & TF_SEL4) {
+ DO_MINMAX2(tf->uv[3], min, max);
+ }
+
+ sel = 1;
+ }
+ }
+
+ return sel;
+}
+
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 346a59bad00..e0af6971959 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -411,6 +411,8 @@ static void do_image_viewmenu(void *arg, int event)
case 8: /* Paint Panel... */
add_blockhandler(curarea, IMAGE_HANDLER_PAINT, UI_PNL_UNSTOW);
break;
+ case 9:
+ image_viewcentre();
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -444,6 +446,7 @@ static uiBlock *image_viewmenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View Selected|NumPad .", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
if(!curarea->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 6b3d5b2bd76..28fd15279ea 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -3835,6 +3835,10 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case WKEY:
transform_tface_uv('w');
break;
+ case PADPERIOD:
+ if(G.qual==0)
+ image_viewcentre();
+ break;
}
}
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index c67f6681da6..15852b64de0 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -75,6 +75,7 @@
#include "BSE_drawview.h" /* For inner_play_anim_loop */
#include "BDR_drawobject.h" /* For draw_object */
+#include "BDR_editface.h" /* For minmax_tface */
#include "mydevice.h"
#include "blendef.h"
@@ -1006,6 +1007,10 @@ void centreview() /* like a localview without local! */
ok= 1;
}
+ else if (G.f & G_FACESELECT) {
+ minmax_tface(min, max);
+ ok= 1;
+ }
else {
base= FIRSTBASE;
while(base) {