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/
This commit is contained in:
@@ -118,10 +118,22 @@ void setTransformViewMatrices(TransInfo *t)
|
|||||||
calculateCenter2D(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)
|
void convertViewVec(TransInfo *t, float *vec, int dx, int dy)
|
||||||
{
|
{
|
||||||
if (t->spacetype==SPACE_VIEW3D) {
|
if(t->spacetype==SPACE_VIEW3D) {
|
||||||
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
|
if(t->ar->regiontype == RGN_TYPE_WINDOW) {
|
||||||
float mval_f[2];
|
float mval_f[2];
|
||||||
mval_f[0]= dx;
|
mval_f[0]= dx;
|
||||||
mval_f[1]= dy;
|
mval_f[1]= dy;
|
||||||
@@ -129,50 +141,19 @@ void convertViewVec(TransInfo *t, float *vec, int dx, int dy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(t->spacetype==SPACE_IMAGE) {
|
else if(t->spacetype==SPACE_IMAGE) {
|
||||||
View2D *v2d = t->view;
|
float aspx, aspy;
|
||||||
float divx, divy, aspx, aspy;
|
|
||||||
|
convertViewVec2D(t->view, vec, dx, dy);
|
||||||
|
|
||||||
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
|
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
|
||||||
|
vec[0]*= aspx;
|
||||||
divx= v2d->mask.xmax-v2d->mask.xmin;
|
vec[1]*= aspy;
|
||||||
divy= v2d->mask.ymax-v2d->mask.ymin;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
|
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
|
||||||
View2D *v2d = t->view;
|
convertViewVec2D(t->view, vec, dx, 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;
|
|
||||||
}
|
}
|
||||||
else if(t->spacetype==SPACE_NODE) {
|
else if(ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
|
||||||
View2D *v2d = &t->ar->v2d;
|
convertViewVec2D(&t->ar->v2d, vec, dx, 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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user