diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-12-23 08:04:03 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-12-23 08:04:03 +0300 |
commit | 9282d305bdc56522543129436db1e8a5d19cf39f (patch) | |
tree | b6d0cdcc7dd3f4113cf9e4f9813c40f44d29746e /source/blender/editors/transform/transform_snap.c | |
parent | de724a258eda45d1fed2b2176006c3b2df8abea2 (diff) | |
parent | 646a96bf8edc211a06f3df652101c265ee166e8d (diff) |
Merge branch 'master' into texture_nodes_refactortexture_nodes_refactor
Conflicts:
source/blender/nodes/texture/nodes/node_texture_math.c
Diffstat (limited to 'source/blender/editors/transform/transform_snap.c')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 73 |
1 files changed, 55 insertions, 18 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 8a3e8f19db4..4a2927ace00 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -59,6 +59,7 @@ #include "BKE_anim.h" /* for duplis */ #include "BKE_context.h" #include "BKE_editmesh.h" +#include "BKE_sequencer.h" #include "BKE_main.h" #include "BKE_tracking.h" @@ -341,22 +342,15 @@ void applyProject(TransInfo *t) if (t->tsnap.align && (t->flag & T_OBJECT)) { /* handle alignment as well */ const float *original_normal; - float axis[3]; float mat[3][3]; - float angle; float totmat[3][3], smat[3][3]; - float eul[3], fmat[3][3], quat[4]; + float eul[3], fmat[3][3]; float obmat[3][3]; /* In pose mode, we want to align normals with Y axis of bones... */ original_normal = td->axismtx[2]; - cross_v3_v3v3(axis, original_normal, no); - angle = saacos(dot_v3v3(original_normal, no)); - - axis_angle_to_quat(quat, axis, angle); - - quat_to_mat3(mat, quat); + rotation_between_vecs_to_mat3(mat, original_normal, no); mul_m3_m3m3(totmat, mat, td->mtx); mul_m3_m3m3(smat, td->smtx, totmat); @@ -1543,8 +1537,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY; invert_m4_m4(imat, obmat); - copy_m3_m4(timat, imat); - transpose_m3(timat); + transpose_m3_m4(timat, imat); copy_v3_v3(ray_start_local, ray_start); copy_v3_v3(ray_normal_local, ray_normal); @@ -1956,21 +1949,32 @@ static bool snapObjectsRay(Scene *scene, short snap_mode, Base *base_act, View3D (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != base_act))) { Object *ob = base->object; - + Object *ob_snap = ob; + bool use_obedit = false; + + /* for linked objects, use the same object but a different matrix */ + if (obedit && ob->data == obedit->data) { + use_obedit = true; + ob_snap = obedit; + } + if (ob->transflag & OB_DUPLI) { DupliObject *dupli_ob; ListBase *lb = object_duplilist(G.main->eval_ctx, scene, ob); for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) { - retval |= snapObject(scene, snap_mode, ar, dupli_ob->ob, dupli_ob->mat, false, + bool use_obedit_dupli = (obedit && dupli_ob->ob->data == obedit->data); + Object *dupli_snap = (use_obedit_dupli) ? obedit : dupli_ob->ob; + + retval |= snapObject(scene, snap_mode, ar, dupli_snap, dupli_ob->mat, use_obedit_dupli, r_ob, r_obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist); } free_object_duplilist(lb); } - - retval |= snapObject(scene, snap_mode, ar, ob, ob->obmat, false, + + retval |= snapObject(scene, snap_mode, ar, ob_snap, ob->obmat, use_obedit, r_ob, r_obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_ray_dist); } @@ -2101,8 +2105,7 @@ static bool peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[4][4], invert_m4_m4(imat, obmat); - copy_m3_m4(timat, imat); - transpose_m3(timat); + transpose_m3_m4(timat, imat); copy_v3_v3(ray_start_local, ray_start); copy_v3_v3(ray_normal_local, ray_normal); @@ -2265,7 +2268,7 @@ static bool peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, } } - BLI_sortlist(depth_peels, cmpPeel); + BLI_listbase_sort(depth_peels, cmpPeel); removeDoublesPeel(depth_peels); return retval; @@ -2428,6 +2431,27 @@ void snapGridIncrement(TransInfo *t, float *val) snapGridIncrementAction(t, val, action); } +int snapSequenceBounds(TransInfo *t, const int mval[2]) +{ + float xmouse, ymouse; + int frame; + int mframe; + TransSeq *ts = t->customData; + /* reuse increment, strictly speaking could be another snap mode, but leave as is */ + if (!(t->modifiers & MOD_SNAP_INVERT)) + return 0; + + /* convert to frame range */ + UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse); + mframe = iroundf(xmouse); + /* now find the closest sequence */ + frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true); + + if (!ts->snap_left) + frame = frame - (ts->max - ts->min); + + return frame; +} static void applyGridIncrement(TransInfo *t, float *val, int max_index, const float fac[3], GearsType action) { @@ -2455,6 +2479,19 @@ static void applyGridIncrement(TransInfo *t, float *val, int max_index, const fl ED_space_image_get_uv_aspect(t->sa->spacedata.first, asp, asp + 1); } } + else if ((t->spacetype == SPACE_IPO) && (t->mode == TFM_TRANSLATION)) { + View2D *v2d = &t->ar->v2d; + View2DGrid *grid; + SpaceIpo *sipo = t->sa->spacedata.first; + int unity = V2D_UNIT_VALUES; + int unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; + + /* grid */ + grid = UI_view2d_grid_calc(t->scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, t->ar->winx, t->ar->winy); + + UI_view2d_grid_size(grid, &asp[0], &asp[1]); + UI_view2d_grid_free(grid); + } for (i = 0; i <= max_index; i++) { val[i] = fac[action] * asp[i] * floorf(val[i] / (fac[action] * asp[i]) + 0.5f); |