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-09-14 20:12:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-09-14 20:12:17 +0400
commit1bde4e3274042f08b60153f58273387801052a97 (patch)
tree39bb6f55ebebb9a4532d6d7a15dd6137a134aee6 /source/blender/src
parent6e38ff32bed6e28871545f352a41a9b7343ed34d (diff)
2D Cursor in UV window
this can be placed by the moused and used for transforming around. still need numeric location input but no room left in the image panel.
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/drawimage.c397
-rw-r--r--source/blender/src/editsima.c9
-rw-r--r--source/blender/src/header_image.c19
-rw-r--r--source/blender/src/space.c33
-rw-r--r--source/blender/src/transform_conversions.c12
-rw-r--r--source/blender/src/transform_generics.c20
6 files changed, 297 insertions, 193 deletions
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index 462c7a6d878..ae11bf1f800 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -367,218 +367,262 @@ void uvco_to_areaco_noclip(float *vec, int *mval)
mval[1]= y;
}
+static void drawcursor_sima(void)
+{
+ int wi, hi;
+ float w, h;
+
+ transform_width_height_tface_uv(&wi, &hi);
+ w = (((float)wi)/256.0f)*G.sima->zoom;
+ h = (((float)hi)/256.0f)*G.sima->zoom;
+
+ cpack(0xFFFFFF);
+ glTranslatef(G.v2d->cursor[0], G.v2d->cursor[1], 0.0f);
+ fdrawline(-0.05/w, 0, 0, 0.05/h);
+ fdrawline(0, 0.05/h, 0.05/w, 0);
+ fdrawline(0.05/w, 0, 0, -0.05/h);
+ fdrawline(0, -0.05/h, -0.05/w, 0);
+
+ setlinestyle(4);
+ cpack(0xFF);
+ fdrawline(-0.05/w, 0, 0, 0.05/h);
+ fdrawline(0, 0.05/h, 0.05/w, 0);
+ fdrawline(0.05/w, 0, 0, -0.05/h);
+ fdrawline(0, -0.05/h, -0.05/w, 0);
+
+
+ setlinestyle(0);
+ cpack(0x0);
+ fdrawline(-0.020/w, 0, -0.1/w, 0);
+ fdrawline(0.1/w, 0, .020/w, 0);
+ fdrawline(0, -0.020/h, 0, -0.1/h);
+ fdrawline(0, 0.1/h, 0, 0.020/h);
+
+ setlinestyle(1);
+ cpack(0xFFFFFF);
+ fdrawline(-0.020/w, 0, -0.1/w, 0);
+ fdrawline(0.1/w, 0, .020/w, 0);
+ fdrawline(0, -0.020/h, 0, -0.1/h);
+ fdrawline(0, 0.1/h, 0, 0.020/h);
+
+ glTranslatef(-G.v2d->cursor[0], -G.v2d->cursor[1], 0.0f);
+ setlinestyle(0);
+}
+
void draw_tfaces(void)
{
MTFace *tface,*activetface = NULL;
EditMesh *em = G.editMesh;
EditFace *efa;
- /*int a;*/
char col1[4], col2[4];
float pointsize= BIF_GetThemeValuef(TH_VERTEX_SIZE);
- if (G.obedit) {
- if (CustomData_has_layer(&em->fdata, CD_MTFACE)) {
- calc_image_view(G.sima, 'f'); /* float */
- myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
- glLoadIdentity();
-
- /* draw shadow mesh */
- if ((G.sima->flag & SI_DRAWSHADOW) && (G.obedit==OBACT)) { /* TODO - editmesh */
- DerivedMesh *dm;
+ if (!G.obedit || !CustomData_has_layer(&em->fdata, CD_MTFACE))
+ return;
+
+
+ calc_image_view(G.sima, 'f'); /* float */
+ myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
+ glLoadIdentity();
+
+ /* draw shadow mesh */
+ if ((G.sima->flag & SI_DRAWSHADOW) && (G.obedit==OBACT)) { /* TODO - editmesh */
+ DerivedMesh *dm;
- /* draw final mesh with modifiers applied */
- /* should test - editmesh_get_derived_cage_and_final */
- dm = editmesh_get_derived_base();
+ /* draw final mesh with modifiers applied */
+ /* should test - editmesh_get_derived_cage_and_final */
+ dm = editmesh_get_derived_base();
- glColor3ub(112, 112, 112);
- if (dm->drawUVEdges) dm->drawUVEdges(dm);
+ glColor3ub(112, 112, 112);
+ if (dm->drawUVEdges) dm->drawUVEdges(dm);
- dm->release(dm);
- }
- else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
- /* draw mesh without modifiers applied */
-
- if (G.obedit) {
- glColor3ub(112, 112, 112);
- for (efa= em->faces.first; efa; efa= efa->next) {
- /*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
- if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
- tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- glBegin(GL_LINE_LOOP);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glVertex2fv(tface->uv[2]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
- }
- }
- }
- }
+ dm->release(dm);
+ }
+ else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
+ /* draw mesh without modifiers applied */
- if((G.sima->flag & SI_DRAWTOOL) || !(G.obedit==OBACT))
- return; /* only draw shadow mesh */
-
- /* draw transparent faces */
- if(G.f & G_DRAWFACES) {
- BIF_GetThemeColor4ubv(TH_FACE, col1);
- BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- for (efa= em->faces.first; efa; efa= efa->next) {
- if(efa->f & SELECT) {
- tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
- (!efa->v4 || tface->flag & TF_SEL4))
- glColor4ubv((GLubyte *)col2);
- else
- glColor4ubv((GLubyte *)col1);
-
- glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glVertex2fv(tface->uv[2]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
- }
- }
- glDisable(GL_BLEND);
- }
-
+ if (G.obedit) {
+ glColor3ub(112, 112, 112);
for (efa= em->faces.first; efa; efa= efa->next) {
- if (efa->f & SELECT) {
+ /*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
+ if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-
- cpack(0x0);
- glBegin(GL_LINE_LOOP);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glVertex2fv(tface->uv[2]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
-
- setlinestyle(2);
- cpack(0xFFFFFF);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[0]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- else glVertex2fv(tface->uv[2]);
- glEnd();
-
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[1]);
- glVertex2fv(tface->uv[2]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
- setlinestyle(0);
- }
- }
-
- /* draw active face edges */
- /*if (activetface){*/
- /* colors: R=u G=v */
- activetface = get_active_mtface(&efa, NULL);
- if (activetface) {
- setlinestyle(2);
- tface=activetface;
- /*mface=activemface;*/
-
- cpack(0x0);
- glBegin(GL_LINE_LOOP);
- glVertex2fv(tface->uv[0]);
+ glBegin(GL_LINE_LOOP);
+ glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
-
- cpack(0xFF00);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glEnd();
+ glEnd();
+ }
+ }
+ }
+ }
- cpack(0xFF);
- glBegin(GL_LINE_STRIP);
+ if((G.sima->flag & SI_DRAWTOOL) || !(G.obedit==OBACT))
+ return; /* only draw shadow mesh */
+
+ /* draw transparent faces */
+ if(G.f & G_DRAWFACES) {
+ BIF_GetThemeColor4ubv(TH_FACE, col1);
+ BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
+ (!efa->v4 || tface->flag & TF_SEL4))
+ glColor4ubv((GLubyte *)col2);
+ else
+ glColor4ubv((GLubyte *)col1);
+
+ glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
glVertex2fv(tface->uv[0]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- else glVertex2fv(tface->uv[2]);
- glEnd();
-
- cpack(0xFFFFFF);
- glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
-
- setlinestyle(0);
}
+ }
+ glDisable(GL_BLEND);
+ }
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
+ cpack(0x0);
+ glBegin(GL_LINE_LOOP);
+ glVertex2fv(tface->uv[0]);
+ glVertex2fv(tface->uv[1]);
+ glVertex2fv(tface->uv[2]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
+ glEnd();
+
+ setlinestyle(2);
+ cpack(0xFFFFFF);
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(tface->uv[0]);
+ glVertex2fv(tface->uv[1]);
+ glEnd();
- /* unselected uv's */
- BIF_ThemeColor(TH_VERTEX);
- glPointSize(pointsize);
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(tface->uv[0]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
+ else glVertex2fv(tface->uv[2]);
+ glEnd();
+
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(tface->uv[1]);
+ glVertex2fv(tface->uv[2]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
+ glEnd();
+ setlinestyle(0);
+ }
+ }
- bglBegin(GL_POINTS);
- for (efa= em->faces.first; efa; efa= efa->next) {
- if (efa->f & SELECT) {
- tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
- if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
- if(tface->flag & TF_SEL3); else bglVertex2fv(tface->uv[2]);
- if(efa->v4) {
- if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
- }
- }
- }
- bglEnd();
+ /* draw active face edges */
+ /*if (activetface){*/
+ /* colors: R=u G=v */
+ activetface = get_active_mtface(&efa, NULL);
+ if (activetface) {
+ setlinestyle(2);
+ tface=activetface;
+ /*mface=activemface;*/
+
+ cpack(0x0);
+ glBegin(GL_LINE_LOOP);
+ glVertex2fv(tface->uv[0]);
+ glVertex2fv(tface->uv[1]);
+ glVertex2fv(tface->uv[2]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
+ glEnd();
+
+ cpack(0xFF00);
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(tface->uv[0]);
+ glVertex2fv(tface->uv[1]);
+ glEnd();
+
+ cpack(0xFF);
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(tface->uv[0]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
+ else glVertex2fv(tface->uv[2]);
+ glEnd();
+
+ cpack(0xFFFFFF);
+ glBegin(GL_LINE_STRIP);
+ glVertex2fv(tface->uv[1]);
+ glVertex2fv(tface->uv[2]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
+ glEnd();
+
+ setlinestyle(0);
+ }
- /* pinned uv's */
- /* give odd pointsizes odd pin pointsizes */
- glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
- cpack(0xFF);
+ /* unselected uv's */
+ BIF_ThemeColor(TH_VERTEX);
+ glPointSize(pointsize);
- bglBegin(GL_POINTS);
- for (efa= em->faces.first; efa; efa= efa->next) {
- if (efa->f & SELECT) {
- tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
- if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
- if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]);
- if(efa->v4) {
- if(tface->unwrap & TF_PIN4) bglVertex2fv(tface->uv[3]);
- }
- }
+ bglBegin(GL_POINTS);
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
+ if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
+ if(tface->flag & TF_SEL3); else bglVertex2fv(tface->uv[2]);
+ if(efa->v4) {
+ if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
}
- bglEnd();
+ }
+ }
+ bglEnd();
- /* selected uv's */
- BIF_ThemeColor(TH_VERTEX_SELECT);
- glPointSize(pointsize);
+ /* pinned uv's */
+ /* give odd pointsizes odd pin pointsizes */
+ glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
+ cpack(0xFF);
- bglBegin(GL_POINTS);
- for (efa= em->faces.first; efa; efa= efa->next) {
- if (efa->f & SELECT) {
- tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
- if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
- if(tface->flag & TF_SEL3) bglVertex2fv(tface->uv[2]);
- if(efa->v4) {
- if(tface->flag & TF_SEL4) bglVertex2fv(tface->uv[3]);
- }
- }
+ bglBegin(GL_POINTS);
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
+ if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
+ if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]);
+ if(efa->v4) {
+ if(tface->unwrap & TF_PIN4) bglVertex2fv(tface->uv[3]);
}
- bglEnd();
+ }
+ }
+ bglEnd();
+
+ /* selected uv's */
+ BIF_ThemeColor(TH_VERTEX_SELECT);
+ glPointSize(pointsize);
- glPointSize(1.0);
+ bglBegin(GL_POINTS);
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
+ if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
+ if(tface->flag & TF_SEL3) bglVertex2fv(tface->uv[2]);
+ if(efa->v4) {
+ if(tface->flag & TF_SEL4) bglVertex2fv(tface->uv[3]);
+ }
}
}
+ bglEnd();
+
+
+ /* Draw the cursor here, this should be in its own function really but it relys on the previous calls to set the view matrix */
+ drawcursor_sima();
+ glPointSize(1.0);
}
static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, short endx, short endy)
@@ -1717,8 +1761,9 @@ void drawimagespace(ScrArea *sa, void *spacedata)
glPixelZoom(1.0, 1.0);
- if(show_viewer==0)
+ if(show_viewer==0) {
draw_tfaces();
+ }
}
glPixelZoom(1.0, 1.0);
diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c
index ed5a1c73cb9..9ec9dc73a4d 100644
--- a/source/blender/src/editsima.c
+++ b/source/blender/src/editsima.c
@@ -895,6 +895,15 @@ void mouseco_to_curtile(void)
}
}
+/* Could be used for other 2D views also */
+void mouseco_to_cursor_sima(void)
+{
+ short mval[2];
+ getmouseco_areawin(mval);
+ areamouseco_to_ipoco(G.v2d, mval, &G.v2d->cursor[0], &G.v2d->cursor[1]);
+ scrarea_queue_winredraw(curarea);
+}
+
void stitch_uv_tface(int mode)
{
MTFace *tf;
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 649ce1438f9..dc18e8f60a4 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -1083,6 +1083,18 @@ static uiBlock *image_uvsmenu(void *arg_unused)
return block;
}
+static char *around_pup(void)
+{
+ static char string[512];
+ char *str = string;
+
+ str += sprintf(str, "%s", "Pivot: %t");
+ str += sprintf(str, "%s", "|Bounding Box Center %x0");
+ str += sprintf(str, "%s", "|Median Point %x3");
+ str += sprintf(str, "%s", "|2D Cursor %x1");
+ return string;
+}
+
void image_buttons(void)
{
Image *ima;
@@ -1158,6 +1170,13 @@ void image_buttons(void)
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, ID_IM, 0, (ID *)ima, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
+ /* UV EditMode buttons */
+ if (EM_texFaceCheck()) {
+ xco+=10;
+ uiDefIconTextButS(block, ICONTEXTROW,B_AROUND, ICON_ROTATE, around_pup(), xco,0,XIC+10,YIC, &(G.v2d->around), 0, 3.0, 0, 0, "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period) ");
+ xco+= XIC+15;
+ }
+
if (ima) {
RenderResult *rr= BKE_image_get_renderresult(ima);
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 2845b3340bb..8e8c4f4c400 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -4788,10 +4788,13 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else
sima_sample_color();
}
- else if(EM_texFaceCheck())
- gesture();
- else
+ else if(EM_texFaceCheck()) {
+ if (!gesture()) {
+ mouseco_to_cursor_sima();
+ }
+ } else {
sima_sample_color();
+ }
break;
case RIGHTMOUSE:
if(EM_texFaceCheck())
@@ -4908,8 +4911,30 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(G.qual==0)
image_viewcenter();
break;
+
+ case COMMAKEY:
+ if(G.qual==LR_SHIFTKEY) {
+ G.v2d->around= V3D_CENTROID;
+ } else if(G.qual==0) {
+ G.v2d->around= V3D_CENTER;
+ }
+
+ scrarea_queue_headredraw(curarea);
+ scrarea_queue_winredraw(curarea);
+ break;
+
+ case PERIODKEY:
+ if(G.qual==LR_CTRLKEY) {
+ G.v2d->around= V3D_LOCAL;
+ } else if(G.qual==0) {
+ G.v2d->around= V3D_CURSOR;
+ }
+
+ scrarea_queue_headredraw(curarea);
+ scrarea_queue_winredraw(curarea);
+ break;
}
- }
+ }
/* least intrusive nonumpad hack, only for plus/minus */
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 00df69ee631..2fdf68951b8 100644
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -1857,12 +1857,6 @@ static void createTransUVs(TransInfo *t)
if(is_uv_tface_editing_allowed()==0) return;
/* count */
- /*
- tf= me->mtface;
- mf= me->mface;
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(mf->v3 && mf->flag & ME_FACE_SEL) {
- */
for (efa= em->faces.first; efa; efa= efa->next) {
if (efa->f & SELECT) {
tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -1889,12 +1883,6 @@ static void createTransUVs(TransInfo *t)
td= t->data;
td2d= t->data2d;
- /*
- tf= me->mtface;
- mf= me->mface;
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(mf->v3 && mf->flag & ME_FACE_SEL) {
- */
for (efa= em->faces.first; efa; efa= efa->next) {
if (efa->f & SELECT) {
tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c
index 33ced3b292c..8e92fdda38a 100644
--- a/source/blender/src/transform_generics.c
+++ b/source/blender/src/transform_generics.c
@@ -464,6 +464,8 @@ void initTrans (TransInfo *t)
if(t->spacetype==SPACE_VIEW3D) {
if(G.vd->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
t->around = G.vd->around;
+ } else if(t->spacetype==SPACE_IMAGE) {
+ t->around = G.v2d->around;
}
else
t->around = V3D_CENTER;
@@ -654,6 +656,19 @@ void calculateCenterCursor(TransInfo *t)
calculateCenter2D(t);
}
+void calculateCenterCursor2D(TransInfo *t)
+{
+ float aspx=1.0, aspy=1.0;
+
+ if(t->spacetype==SPACE_IMAGE) /* only space supported right now but may change */
+ transform_aspect_ratio_tface_uv(&aspx, &aspy);
+ if (G.v2d) {
+ t->center[0] = G.v2d->cursor[0] * aspx;
+ t->center[1] = G.v2d->cursor[1] * aspy;
+ }
+ calculateCenter2D(t);
+}
+
void calculateCenterMedian(TransInfo *t)
{
float partial[3] = {0.0f, 0.0f, 0.0f};
@@ -717,7 +732,10 @@ void calculateCenter(TransInfo *t)
calculateCenterMedian(t);
break;
case V3D_CURSOR:
- calculateCenterCursor(t);
+ if(t->spacetype==SPACE_IMAGE)
+ calculateCenterCursor2D(t);
+ else
+ calculateCenterCursor(t);
break;
case V3D_LOCAL:
/* Individual element center uses median center for helpline and such */