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:
authorNicholas Bishop <nicholasbishop@gmail.com>2011-11-02 04:17:37 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2011-11-02 04:17:37 +0400
commitb60f60453b6b70950257b269574aa51f00d55511 (patch)
tree3388c594c16ba4033ddf1b9df1954a6861f5cd2d /source/blender/editors/transform
parent90a19ce57893642263a0b91eed96ba1a710d44af (diff)
Function convertViewVec() contained some piece of code duplicated four
times, pulled out into separate function and cleaned up a bit. Should be no functional changes. Review link: http://codereview.appspot.com/5308073/
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform.c63
1 files changed, 22 insertions, 41 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 9c1d5adcd1b..759fefba438 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -118,10 +118,22 @@ void setTransformViewMatrices(TransInfo *t)
calculateCenter2D(t);
}
+static void convertViewVec2D(View2D *v2d, float *vec, int dx, int dy)
+{
+ float divx, divy;
+
+ divx= v2d->mask.xmax - v2d->mask.xmin;
+ divy= v2d->mask.ymax - v2d->mask.ymin;
+
+ vec[0]= (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
+ vec[1]= (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
+ vec[2]= 0.0f;
+}
+
void convertViewVec(TransInfo *t, float *vec, int dx, int dy)
{
- if (t->spacetype==SPACE_VIEW3D) {
- if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+ if(t->spacetype==SPACE_VIEW3D) {
+ if(t->ar->regiontype == RGN_TYPE_WINDOW) {
float mval_f[2];
mval_f[0]= dx;
mval_f[1]= dy;
@@ -129,50 +141,19 @@ void convertViewVec(TransInfo *t, float *vec, int dx, int dy)
}
}
else if(t->spacetype==SPACE_IMAGE) {
- View2D *v2d = t->view;
- float divx, divy, aspx, aspy;
-
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ float aspx, aspy;
- divx= v2d->mask.xmax-v2d->mask.xmin;
- divy= v2d->mask.ymax-v2d->mask.ymin;
+ convertViewVec2D(t->view, vec, dx, dy);
- vec[0]= aspx*(v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
- vec[1]= aspy*(v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
- vec[2]= 0.0f;
+ ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ vec[0]*= aspx;
+ vec[1]*= aspy;
}
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
- View2D *v2d = t->view;
- float divx, divy;
-
- divx= v2d->mask.xmax-v2d->mask.xmin;
- divy= v2d->mask.ymax-v2d->mask.ymin;
-
- vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx) / (divx);
- vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy) / (divy);
- vec[2]= 0.0f;
+ convertViewVec2D(t->view, vec, dx, dy);
}
- else if(t->spacetype==SPACE_NODE) {
- View2D *v2d = &t->ar->v2d;
- float divx, divy;
-
- divx= v2d->mask.xmax-v2d->mask.xmin;
- divy= v2d->mask.ymax-v2d->mask.ymin;
-
- vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
- vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
- vec[2]= 0.0f;
- }
- else if(t->spacetype==SPACE_SEQ) {
- View2D *v2d = &t->ar->v2d;
- float divx, divy;
-
- divx= v2d->mask.xmax-v2d->mask.xmin;
- divy= v2d->mask.ymax-v2d->mask.ymin;
-
- vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
- vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
- vec[2]= 0.0f;
+ else if(ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
+ convertViewVec2D(&t->ar->v2d, vec, dx, dy);
}
}