diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
commit | 27b3ea622f8bd313a8e2827dfec752bf2125566c (patch) | |
tree | f212e49d224ce8e1cfc3b17a64ae524711494391 /source/blender/editors/transform/transform_constraints.c | |
parent | 372dff8d1dc7e24d4b2cd37de245588ecfce8bfa (diff) | |
parent | de80e687689032cb85179a1f7e89750573631d5d (diff) |
Merge remote-tracking branch 'origin/master' into cycles_camera_nodescycles_camera_nodes
Note: the branch currently crashes in blender_camera_nodes.cpp:
BL::NodeTree b_ntree = b_data.node_groups[nodes_tree_name];
The crash was introduced in:
cb7cf523e5c000609f32a382e2c0fcc57f635a42
Conflicts:
intern/cycles/SConscript
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/blender_camera.cpp
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
Diffstat (limited to 'source/blender/editors/transform/transform_constraints.c')
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index d8f17315c01..895c8a81044 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -46,13 +46,14 @@ #include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_string.h" +#include "BLI_rect.h" #include "BKE_context.h" #include "ED_image.h" #include "ED_view3d.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "UI_resources.h" @@ -202,13 +203,13 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3], return; } - copy_v3_v3(t_con_center, t->con.center); + copy_v3_v3(t_con_center, t->center_global); /* checks for center being too close to the view center */ viewAxisCorrectCenter(t, t_con_center); angle = fabsf(angle_v3v3(axis, t->viewinv[2])); - if (angle > (float)M_PI / 2.0f) { + if (angle > (float)M_PI_2) { angle = (float)M_PI - angle; } angle = RAD2DEGF(angle); @@ -276,7 +277,7 @@ static void planeProjection(TransInfo *t, const float in[3], float out[3]) { float vec[3], factor, norm[3]; - add_v3_v3v3(vec, in, t->con.center); + add_v3_v3v3(vec, in, t->center_global); getViewVector(t, vec, norm); sub_v3_v3v3(vec, out, in); @@ -309,7 +310,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, const float in[3 mul_m3_v3(t->con.pmtx, out); // With snap, a projection is alright, no need to correct for view alignment - if (!(t->tsnap.mode != SCE_SNAP_MODE_INCREMENT && activeSnap(t))) { + if (!(!ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID) && activeSnap(t))) { if (getConstraintSpaceDimension(t) == 2) { if (out[0] != 0.0f || out[1] != 0.0f || out[2] != 0.0f) { planeProjection(t, in, out); @@ -687,11 +688,11 @@ void drawConstraint(TransInfo *t) int depth_test_enabled; convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1])); - add_v3_v3(vec, tc->center); + add_v3_v3(vec, t->center_global); - drawLine(t, tc->center, tc->mtx[0], 'X', 0); - drawLine(t, tc->center, tc->mtx[1], 'Y', 0); - drawLine(t, tc->center, tc->mtx[2], 'Z', 0); + drawLine(t, t->center_global, tc->mtx[0], 'X', 0); + drawLine(t, t->center_global, tc->mtx[1], 'Y', 0); + drawLine(t, t->center_global, tc->mtx[2], 'Z', 0); glColor3ubv((GLubyte *)col2); @@ -701,7 +702,7 @@ void drawConstraint(TransInfo *t) setlinestyle(1); glBegin(GL_LINE_STRIP); - glVertex3fv(tc->center); + glVertex3fv(t->center_global); glVertex3fv(vec); glEnd(); setlinestyle(0); @@ -711,13 +712,13 @@ void drawConstraint(TransInfo *t) } if (tc->mode & CON_AXIS0) { - drawLine(t, tc->center, tc->mtx[0], 'X', DRAWLIGHT); + drawLine(t, t->center_global, tc->mtx[0], 'X', DRAWLIGHT); } if (tc->mode & CON_AXIS1) { - drawLine(t, tc->center, tc->mtx[1], 'Y', DRAWLIGHT); + drawLine(t, t->center_global, tc->mtx[1], 'Y', DRAWLIGHT); } if (tc->mode & CON_AXIS2) { - drawLine(t, tc->center, tc->mtx[2], 'Z', DRAWLIGHT); + drawLine(t, t->center_global, tc->mtx[2], 'Z', DRAWLIGHT); } } } @@ -728,7 +729,6 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if (t->flag & T_PROP_EDIT) { RegionView3D *rv3d = CTX_wm_region_view3d(C); float tmat[4][4], imat[4][4]; - float center[3]; int depth_test_enabled; UI_ThemeColor(TH_GRID); @@ -744,25 +744,21 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) glPushMatrix(); - copy_v3_v3(center, t->center); - - if ((t->spacetype == SPACE_VIEW3D) && t->obedit) { - mul_m4_v3(t->obedit->obmat, center); /* because t->center is in local space */ + if (t->spacetype == SPACE_VIEW3D) { + /* pass */ } else if (t->spacetype == SPACE_IMAGE) { - float aspx, aspy; - - if (t->options & CTX_MASK) { - /* untested - mask aspect is TODO */ - ED_space_image_get_aspect(t->sa->spacedata.first, &aspx, &aspy); - } - else if (t->options & CTX_PAINT_CURVE) { - aspx = aspy = 1.0; - } - else { - ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); - } - glScalef(1.0f / aspx, 1.0f / aspy, 1.0); + glScalef(1.0f / t->aspect[0], 1.0f / t->aspect[1], 1.0f); + } + else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) { + /* only scale y */ + rcti *mask = &t->ar->v2d.mask; + rctf *datamask = &t->ar->v2d.cur; + float xsize = BLI_rctf_size_x(datamask); + float ysize = BLI_rctf_size_y(datamask); + float xmask = BLI_rcti_size_x(mask); + float ymask = BLI_rcti_size_y(mask); + glScalef(1.0f, (ysize / xsize) * (xmask / ymask), 1.0f); } depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); @@ -770,7 +766,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) glDisable(GL_DEPTH_TEST); set_inverted_drawing(1); - drawcircball(GL_LINE_LOOP, center, t->prop_size, imat); + drawcircball(GL_LINE_LOOP, t->center_global, t->prop_size, imat); set_inverted_drawing(0); if (depth_test_enabled) @@ -859,21 +855,15 @@ void getConstraintMatrix(TransInfo *t) unit_m3(t->con.pmtx); if (!(t->con.mode & CON_AXIS0)) { - t->con.pmtx[0][0] = - t->con.pmtx[0][1] = - t->con.pmtx[0][2] = 0.0f; + zero_v3(t->con.pmtx[0]); } if (!(t->con.mode & CON_AXIS1)) { - t->con.pmtx[1][0] = - t->con.pmtx[1][1] = - t->con.pmtx[1][2] = 0.0f; + zero_v3(t->con.pmtx[1]); } if (!(t->con.mode & CON_AXIS2)) { - t->con.pmtx[2][0] = - t->con.pmtx[2][1] = - t->con.pmtx[2][2] = 0.0f; + zero_v3(t->con.pmtx[2]); } mul_m3_m3m3(mat, t->con.pmtx, t->con.imtx); @@ -961,7 +951,7 @@ static void setNearestAxis3d(TransInfo *t) mul_v3_fl(axis, zfac); /* now we can project to get window coordinate */ - add_v3_v3(axis, t->con.center); + add_v3_v3(axis, t->center_global); projectFloatView(t, axis, axis_2d); sub_v2_v2v2(axis, axis_2d, t->center2d); |