diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2010-09-04 22:49:07 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2010-09-04 22:49:07 +0400 |
commit | 90b464d3728d9ed8ec26fdf59058d236b99dbcd9 (patch) | |
tree | e88cab4fb1358e962b19f658064ca8c9f8d29f5b /source/blender/editors/transform | |
parent | 08d02dd04d836976b25793bb1d4c6a86b3f924c7 (diff) | |
parent | b0b787ef38f9947b3176642556f5282eb3518f69 (diff) |
COLLADA branch: merge from trunk -r 28015:31610.soc-2009-chingachgook
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/CMakeLists.txt | 34 | ||||
-rw-r--r-- | source/blender/editors/transform/Makefile | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 305 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 22 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 214 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 72 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 8 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 67 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 18 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 33 |
12 files changed, 505 insertions, 291 deletions
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt new file mode 100644 index 00000000000..e67771270cf --- /dev/null +++ b/source/blender/editors/transform/CMakeLists.txt @@ -0,0 +1,34 @@ +# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +FILE(GLOB SRC *.c) + +SET(INC + ../../blenkernel + ../../blenlib + ../include + ../../../../intern/guardedalloc + ../../makesdna + ../../makesrna + ../../windowmanager +) + +BLENDERLIB(bf_editor_transform "${SRC}" "${INC}") diff --git a/source/blender/editors/transform/Makefile b/source/blender/editors/transform/Makefile index 607038b413b..9d23b763cd6 100644 --- a/source/blender/editors/transform/Makefile +++ b/source/blender/editors/transform/Makefile @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2007 Blender Foundation # All rights reserved. diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 498313838df..a16417b846f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -33,10 +33,6 @@ #include <math.h> #include <float.h> -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - #ifndef WIN32 #include <unistd.h> #else @@ -67,7 +63,6 @@ //#include "BIF_editsima.h" //#include "BIF_editparticle.h" -#include "BKE_action.h" #include "BKE_nla.h" //#include "BKE_bad_level_calls.h"/* popmenu and error */ #include "BKE_bmesh.h" @@ -76,8 +71,6 @@ #include "BKE_global.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" -#include "BKE_context.h" #include "BKE_unit.h" //#include "BSE_view.h" @@ -206,17 +199,33 @@ void projectIntView(TransInfo *t, float *vec, int *adr) UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1); } - else if(ELEM3(t->spacetype, SPACE_IPO, SPACE_NLA, SPACE_ACTION)) { + else if(t->spacetype == SPACE_ACTION) { + SpaceAction *sact = t->sa->spacedata.first; + int out[2] = {0, 0}; + + if (sact->flag & SACTION_DRAWTIME) { + //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); + + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); + } + else { + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); + } + + adr[0]= out[0]; + adr[1]= out[1]; + } + else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { int out[2] = {0, 0}; - UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1); + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } else if(t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */ int out[2] = {0, 0}; - UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1); + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } @@ -246,9 +255,8 @@ void projectFloatView(TransInfo *t, float *vec, float *adr) void applyAspectRatio(TransInfo *t, float *vec) { - SpaceImage *sima= t->sa->spacedata.first; - if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { + SpaceImage *sima= t->sa->spacedata.first; float aspx, aspy; if((sima->flag & SI_COORDFLOATS)==0) { @@ -267,9 +275,8 @@ void applyAspectRatio(TransInfo *t, float *vec) void removeAspectRatio(TransInfo *t, float *vec) { - SpaceImage *sima= t->sa->spacedata.first; - if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { + SpaceImage *sima= t->sa->spacedata.first; float aspx, aspy; if((sima->flag & SI_COORDFLOATS)==0) { @@ -301,14 +308,14 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_ACTION) { //SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first; - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); } else if (t->spacetype == SPACE_IPO) { //SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first; - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); } else if (t->spacetype == SPACE_NLA) { - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); } else if(t->spacetype == SPACE_NODE) { @@ -334,7 +341,7 @@ static void viewRedrawPost(TransInfo *t) if(t->spacetype == SPACE_VIEW3D) { /* if autokeying is enabled, send notifiers that keyframes were added */ if (IS_AUTOKEY_ON(t->scene)) - WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME_EDIT, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); } #if 0 // TRANSFORM_FIX_ME @@ -469,6 +476,8 @@ static void view_editmove(unsigned short event) #define TFM_MODAL_REMOVE_SNAP 17 /* 18 and 19 used by numinput, defined in transform.h * */ +#define TFM_MODAL_PROPSIZE_UP 20 +#define TFM_MODAL_PROPSIZE_DOWN 21 /* called in transform_ops.c, on each regeneration of keymaps */ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf) @@ -493,6 +502,8 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""}, {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""}, {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""}, + {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""}, + {TFM_MODAL_PROPSIZE_DOWN, "PROPORTIONAL_SIZE_DOWN", 0, "Decrease Poportional Influence", ""}, {0, NULL, 0, NULL, NULL}}; wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map"); @@ -522,6 +533,11 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_UP); WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_DOWN); + + WM_modalkeymap_add_item(keymap, PAGEUPKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP); + WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_DOWN); + WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP); + WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_DOWN); return keymap; } @@ -702,6 +718,20 @@ int transformEvent(TransInfo *t, wmEvent *event) removeSnapPoint(t); t->redraw |= TREDRAW_HARD; break; + case TFM_MODAL_PROPSIZE_UP: + if(t->flag & T_PROP_EDIT) { + t->prop_size*= 1.1f; + calculatePropRatio(t); + } + t->redraw |= TREDRAW_HARD; + break; + case TFM_MODAL_PROPSIZE_DOWN: + if (t->flag & T_PROP_EDIT) { + t->prop_size*= 0.90909090f; + calculatePropRatio(t); + } + t->redraw |= TREDRAW_HARD; + break; default: handled = 0; break; @@ -926,10 +956,6 @@ int transformEvent(TransInfo *t, wmEvent *event) if (t->flag & T_AUTOIK) { transform_autoik_update(t, 1); } - else if(t->flag & T_PROP_EDIT) { - t->prop_size*= 1.1f; - calculatePropRatio(t); - } else view_editmove(event->type); t->redraw= 1; break; @@ -945,10 +971,6 @@ int transformEvent(TransInfo *t, wmEvent *event) if (t->flag & T_AUTOIK) { transform_autoik_update(t, -1); } - else if (t->flag & T_PROP_EDIT) { - t->prop_size*= 0.90909090f; - calculatePropRatio(t); - } else view_editmove(event->type); t->redraw= 1; break; @@ -1342,17 +1364,17 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } - /* XXX convert stupid flag to enum */ + /* convert flag to enum */ switch(t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { case (T_PROP_EDIT|T_PROP_CONNECTED): - proportional = 2; + proportional = PROP_EDIT_CONNECTED; break; case T_PROP_EDIT: - proportional = 1; + proportional = PROP_EDIT_ON; break; default: - proportional = 0; + proportional = PROP_EDIT_OFF; } // If modal, save settings back in scene if not set as operator argument @@ -1360,14 +1382,17 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) /* save settings if not set in operator */ if (RNA_struct_find_property(op->ptr, "proportional") && !RNA_property_is_set(op->ptr, "proportional")) { - ts->proportional = proportional; + if (t->obedit) + ts->proportional = proportional; + else + ts->proportional_objects = (proportional != PROP_EDIT_OFF); } if (RNA_struct_find_property(op->ptr, "proportional_size") && !RNA_property_is_set(op->ptr, "proportional_size")) { ts->proportional_size = t->prop_size; } - if (RNA_struct_find_property(op->ptr, "proportional_editing_falloff") && !RNA_property_is_set(op->ptr, "proportional_editing_falloff")) { + if (RNA_struct_find_property(op->ptr, "proportional_edit_falloff") && !RNA_property_is_set(op->ptr, "proportional_edit_falloff")) { ts->prop_mode = t->prop_mode; } @@ -1390,7 +1415,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if (RNA_struct_find_property(op->ptr, "proportional")) { RNA_enum_set(op->ptr, "proportional", proportional); - RNA_enum_set(op->ptr, "proportional_editing_falloff", t->prop_mode); + RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode); RNA_float_set(op->ptr, "proportional_size", t->prop_size); } @@ -1432,6 +1457,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } +/* note: caller needs to free 't' on a 0 return */ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int mode) { int options = 0; @@ -1925,39 +1951,50 @@ static void constraintTransLim(TransInfo *t, TransData *td) } } +static void constraintob_from_transdata(bConstraintOb *cob, TransData *td) +{ + /* Make a temporary bConstraintOb for use by limit constraints + * - they only care that cob->matrix is correctly set ;-) + * - current space should be local + */ + memset(cob, 0, sizeof(bConstraintOb)); + if (td->rotOrder == ROT_MODE_QUAT) { + /* quats */ + if (td->ext) { + /* objects and bones do normalization first too, otherwise + we don't necessarily end up with a rotation matrix, and + then conversion back to quat gives a different result */ + float quat[4]; + copy_qt_qt(quat, td->ext->quat); + normalize_qt(quat); + quat_to_mat4(cob->matrix, quat); + } + else + return; + } + else if (td->rotOrder == ROT_MODE_AXISANGLE) { + /* axis angle */ + if (td->ext) + axis_angle_to_mat4(cob->matrix, &td->ext->quat[1], td->ext->quat[0]); + else + return; + } + else { + /* eulers */ + if (td->ext) + eulO_to_mat4(cob->matrix, td->ext->rot, td->rotOrder); + else + return; + } +} + static void constraintRotLim(TransInfo *t, TransData *td) { if (td->con) { bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT); bConstraintOb cob; bConstraint *con; - - /* Make a temporary bConstraintOb for using these limit constraints - * - they only care that cob->matrix is correctly set ;-) - * - current space should be local - */ - memset(&cob, 0, sizeof(bConstraintOb)); - if (td->rotOrder == ROT_MODE_QUAT) { - /* quats */ - if (td->ext) - quat_to_mat4( cob.matrix,td->ext->quat); - else - return; - } - else if (td->rotOrder == ROT_MODE_AXISANGLE) { - /* axis angle */ - if (td->ext) - axis_angle_to_mat4( cob.matrix,&td->ext->quat[1], td->ext->quat[0]); - else - return; - } - else { - /* eulers */ - if (td->ext) - eulO_to_mat4( cob.matrix,td->ext->rot, td->rotOrder); - else - return; - } + int dolimit = 0; /* Evaluate valid constraints */ for (con= td->con; con; con= con->next) { @@ -1973,6 +2010,16 @@ static void constraintRotLim(TransInfo *t, TransData *td) /* only use it if it's tagged for this purpose */ if ((data->flag2 & LIMIT_TRANSFORM)==0) continue; + + /* skip incompatable spacetypes */ + if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL)) + continue; + + /* only do conversion if necessary, to preserve quats and eulers */ + if(!dolimit) { + constraintob_from_transdata(&cob, td); + dolimit= 1; + } /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { @@ -1980,10 +2027,6 @@ static void constraintRotLim(TransInfo *t, TransData *td) copy_m4_m4(tmat, cob.matrix); mul_m4_m3m4(cob.matrix, td->mtx, tmat); } - else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { - /* skip... incompatable spacetype */ - continue; - } /* do constraint */ cti->evaluate_constraint(con, &cob, NULL); @@ -1997,18 +2040,20 @@ static void constraintRotLim(TransInfo *t, TransData *td) } } - /* copy results from cob->matrix */ - if (td->rotOrder == ROT_MODE_QUAT) { - /* quats */ - mat4_to_quat( td->ext->quat,cob.matrix); - } - else if (td->rotOrder == ROT_MODE_AXISANGLE) { - /* axis angle */ - mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix); - } - else { - /* eulers */ - mat4_to_eulO( td->ext->rot, td->rotOrder,cob.matrix); + if(dolimit) { + /* copy results from cob->matrix */ + if (td->rotOrder == ROT_MODE_QUAT) { + /* quats */ + mat4_to_quat( td->ext->quat,cob.matrix); + } + else if (td->rotOrder == ROT_MODE_AXISANGLE) { + /* axis angle */ + mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix); + } + else { + /* eulers */ + mat4_to_eulO( td->ext->rot, td->rotOrder,cob.matrix); + } } } } @@ -2127,21 +2172,19 @@ void initWarp(TransInfo *t) /* we need min/max in view space */ for(i = 0; i < t->total; i++) { float center[3]; - VECCOPY(center, t->data[i].center); + copy_v3_v3(center, t->data[i].center); mul_m3_v3(t->data[i].mtx, center); mul_m4_v3(t->viewmat, center); - sub_v3_v3v3(center, center, t->viewmat[3]); + sub_v3_v3(center, t->viewmat[3]); if (i) minmax_v3_v3v3(min, max, center); else { - VECCOPY(max, center); - VECCOPY(min, center); + copy_v3_v3(max, center); + copy_v3_v3(min, center); } } - - t->center[0]= (min[0]+max[0])/2.0f; - t->center[1]= (min[1]+max[1])/2.0f; - t->center[2]= (min[2]+max[2])/2.0f; + + mid_v3_v3v3(t->center, min, max); if (max[0] == min[0]) max[0] += 0.1; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */ @@ -2186,12 +2229,12 @@ int Warp(TransInfo *t, short mval[2]) VECCOPY(cursor, curs); VECCOPY(gcursor, cursor); if (t->flag & T_EDIT) { - sub_v3_v3v3(cursor, cursor, t->obedit->obmat[3]); - sub_v3_v3v3(gcursor, gcursor, t->obedit->obmat[3]); + sub_v3_v3(cursor, t->obedit->obmat[3]); + sub_v3_v3(gcursor, t->obedit->obmat[3]); mul_m3_v3(t->data->smtx, gcursor); } mul_m4_v3(t->viewmat, cursor); - sub_v3_v3v3(cursor, cursor, t->viewmat[3]); + sub_v3_v3(cursor, t->viewmat[3]); /* amount of radians for warp */ circumfac = t->values[0]; @@ -2230,7 +2273,7 @@ int Warp(TransInfo *t, short mval[2]) VECCOPY(vec, td->iloc); mul_m3_v3(td->mtx, vec); mul_m4_v3(t->viewmat, vec); - sub_v3_v3v3(vec, vec, t->viewmat[3]); + sub_v3_v3(vec, t->viewmat[3]); dist= vec[0]-cursor[0]; @@ -2246,10 +2289,10 @@ int Warp(TransInfo *t, short mval[2]) loc[2]= vec[2]; mul_m4_v3(t->viewinv, loc); - sub_v3_v3v3(loc, loc, t->viewinv[3]); + sub_v3_v3(loc, t->viewinv[3]); mul_m3_v3(td->smtx, loc); - sub_v3_v3v3(loc, loc, td->iloc); + sub_v3_v3(loc, td->iloc); mul_v3_fl(loc, td->factor); add_v3_v3v3(td->loc, td->iloc, loc); } @@ -2374,8 +2417,8 @@ int Shear(TransInfo *t, short mval[2]) mul_m3_v3(tmat, vec); - add_v3_v3v3(vec, vec, t->center); - sub_v3_v3v3(vec, vec, td->center); + add_v3_v3(vec, t->center); + sub_v3_v3(vec, td->center); mul_v3_fl(vec, td->factor); @@ -2554,11 +2597,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { mul_m3_v3(tmat, vec); - add_v3_v3v3(vec, vec, center); + add_v3_v3(vec, center); if (t->flag & T_POINTS) - sub_v3_v3v3(vec, vec, td->iloc); + sub_v3_v3(vec, td->iloc); else - sub_v3_v3v3(vec, vec, td->center); + sub_v3_v3(vec, td->center); mul_v3_fl(vec, td->factor); @@ -2846,7 +2889,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short mul_m3_v3(mat, vec); // Applying rotation mul_m3_v3(imtx, vec); // To Local space - add_v3_v3v3(vec, vec, center); + add_v3_v3(vec, center); /* vec now is the location where the object has to be */ sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location @@ -2918,9 +2961,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* translation */ sub_v3_v3v3(vec, td->center, center); mul_m3_v3(mat, vec); - add_v3_v3v3(vec, vec, center); + add_v3_v3(vec, center); /* vec now is the location where the object has to be */ - sub_v3_v3v3(vec, vec, td->center); + sub_v3_v3(vec, td->center); mul_m3_v3(td->smtx, vec); protectedTransBits(td->protectflag, vec); @@ -3481,7 +3524,7 @@ void initTilt(TransInfo *t) t->num.increment = t->snap[1]; - t->flag |= T_NO_CONSTRAINT; + t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } @@ -3672,7 +3715,7 @@ int PushPull(TransInfo *t, short mval[2]) if (isLockConstraint(t)) { float dvec[3]; project_v3_v3v3(dvec, vec, axis); - sub_v3_v3v3(vec, vec, dvec); + sub_v3_v3(vec, dvec); } else { project_v3_v3v3(vec, vec, axis); @@ -4091,7 +4134,7 @@ void initBoneEnvelope(TransInfo *t) t->num.increment = t->snap[1]; - t->flag |= T_NO_CONSTRAINT; + t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } int BoneEnvelope(TransInfo *t, short mval[2]) @@ -4313,7 +4356,7 @@ static int createSlideVerts(TransInfo *t) // populate the SlideVerts - vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts gh"); look = vertlist; while(look) { i=0; @@ -4467,7 +4510,7 @@ static int createSlideVerts(TransInfo *t) sub_v3_v3v3(vec, co2, co); } - add_v3_v3v3(start, start, vec); + add_v3_v3(start, vec); if (v3d) { view3d_project_float(t->ar, tempsv->down->v1->co, co, projectMat); @@ -4480,7 +4523,7 @@ static int createSlideVerts(TransInfo *t) sub_v3_v3v3(vec, co, co2); } - add_v3_v3v3(end, end, vec); + add_v3_v3(end, vec); totvec += 1.0f; nearest = (EditVert*)look->link; @@ -4492,7 +4535,7 @@ static int createSlideVerts(TransInfo *t) look = look->next; } - add_v3_v3v3(start, start, end); + add_v3_v3(start, end); mul_v3_fl(start, 0.5*(1.0/totvec)); VECCOPY(vec, start); start[0] = t->mval[0]; @@ -4514,7 +4557,7 @@ static int createSlideVerts(TransInfo *t) for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) { - uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts2 gh"); for(ev=em->verts.first;ev;ev=ev->next) { ev->tmp.l = 0; @@ -4670,7 +4713,7 @@ void initEdgeSlide(TransInfo *t) t->num.increment = t->snap[1]; - t->flag |= T_NO_CONSTRAINT; + t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } int doEdgeSlide(TransInfo *t, float perc) @@ -4736,10 +4779,11 @@ int doEdgeSlide(TransInfo *t, float perc) //Non prop code look = vertlist; while(look) { - float newlen; + float newlen, edgelen; ev = look->link; tempsv = BLI_ghash_lookup(vertgh,ev); - newlen = (len / len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co)); + edgelen = len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co); + newlen = (edgelen != 0.0f)? (len / edgelen): 0.0f; if(newlen > 1.0) {newlen = 1.0;} if(newlen < 0.0) {newlen = 0.0;} if(flip == 0) { @@ -4840,7 +4884,7 @@ void initBoneRoll(TransInfo *t) t->num.increment = 1.0f; - t->flag |= T_NO_CONSTRAINT; + t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } int BoneRoll(TransInfo *t, short mval[2]) @@ -5270,27 +5314,27 @@ static short getAnimEdit_DrawTime(TransInfo *t) /* This function is used by Animation Editor specific transform functions to do * the Snap Keyframe to Nearest Frame/Marker */ -static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, short autosnap) +static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, AnimData *adt, short autosnap) { /* snap key to nearest frame? */ if (autosnap == SACTSNAP_FRAME) { const Scene *scene= t->scene; - const short doTime= getAnimEdit_DrawTime(t); + const short doTime= 0; //XXX doesn't work - getAnimEdit_DrawTime(t); const double secf= FPS; double val; - + /* convert frame to nla-action time (if needed) */ if (adt) val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val= *(td->val); - + /* do the snapping to nearest frame/second */ if (doTime) val= (float)( floor((val/secf) + 0.5f) * secf ); else val= (float)( floor(val+0.5f) ); - + /* convert frame out of nla-action time */ if (adt) *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); @@ -5300,23 +5344,34 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho /* snap key to nearest marker? */ else if (autosnap == SACTSNAP_MARKER) { float val; - + /* convert frame to nla-action time (if needed) */ if (adt) val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val= *(td->val); - + /* snap to nearest marker */ // TODO: need some more careful checks for where data comes from val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val); - + /* convert frame out of nla-action time */ if (adt) *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); else *(td->val)= val; } + + /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect) + * offset them by the same amount so that the general angles are maintained (i.e. won't change while + * handles are free-to-roam and keyframes are snap-locked) + */ + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { + td2d->h1[0] = td2d->ih1[0] + *td->val - td->ival; + } + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { + td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival; + } } /* ----------------- Translation ----------------------- */ @@ -5379,6 +5434,7 @@ static void headerTimeTranslate(TransInfo *t, char *str) static void applyTimeTranslate(TransInfo *t, float sval) { TransData *td = t->data; + TransData2D *td2d = t->data2d; Scene *scene = t->scene; int i; @@ -5387,16 +5443,18 @@ static void applyTimeTranslate(TransInfo *t, float sval) const short autosnap= getAnimEdit_SnapMode(t); - float deltax, val; + float deltax, val, valprev; /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++, td2d++) { /* it is assumed that td->extra is a pointer to the AnimData, * whose active action is where this keyframe comes from * (this is only valid when not in NLA) */ AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL; + valprev = *td->val; + /* check if any need to apply nla-mapping */ if (adt && t->spacetype != SPACE_SEQ) { deltax = t->values[0]; @@ -5426,7 +5484,7 @@ static void applyTimeTranslate(TransInfo *t, float sval) } /* apply nearest snapping */ - doAnimEdit_SnapFrame(t, td, adt, autosnap); + doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); } } @@ -5637,6 +5695,7 @@ static void headerTimeScale(TransInfo *t, char *str) { static void applyTimeScale(TransInfo *t) { Scene *scene = t->scene; TransData *td = t->data; + TransData2D *td2d = t->data2d; int i; const short autosnap= getAnimEdit_SnapMode(t); @@ -5644,7 +5703,7 @@ static void applyTimeScale(TransInfo *t) { const double secf= FPS; - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++, td2d++) { /* it is assumed that td->extra is a pointer to the AnimData, * whose active action is where this keyframe comes from * (this is only valid when not in NLA) @@ -5670,7 +5729,7 @@ static void applyTimeScale(TransInfo *t) { *(td->val) += startx; /* apply nearest snapping */ - doAnimEdit_SnapFrame(t, td, adt, autosnap); + doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); } } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index ef13634a6ae..c1e62eb563c 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -151,6 +151,9 @@ typedef struct TransDataExtension { typedef struct TransData2D { float loc[3]; /* Location of data used to transform (x,y,0) */ float *loc2d; /* Pointer to real 2d location of data */ + + float *h1, *h2; /* Pointer to handle locations, if handles aren't being moved independantly*/ + float ih1[2], ih2[2]; } TransData2D; /* we need to store 2 handles for each transdata incase the other handle wasnt selected */ @@ -427,6 +430,8 @@ typedef struct TransInfo { #define TD_NOTIMESNAP (1 << 14) /* for Graph Editor autosnap, indicates that point should not undergo autosnapping */ #define TD_INTVALUES (1 << 15) /* for Graph Editor - curves that can only have int-values need their keyframes tagged with this */ #define TD_MIRROR_EDGE (1 << 16) /* For editmode mirror, clamp to x = 0 */ +#define TD_MOVEHANDLE1 (1 << 17) /* For fcurve handles, move them along with their keyframes */ +#define TD_MOVEHANDLE2 (1 << 18) /* transsnap->status */ #define SNAP_FORCED 1 diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 14d0676786e..1e6916f0a86 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -32,17 +32,12 @@ #include <string.h> #include <math.h> -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - #ifndef WIN32 #include <unistd.h> #else #include <io.h> #endif -#include "MEM_guardedalloc.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -54,7 +49,6 @@ #include "BIF_glutil.h" #include "BKE_context.h" -#include "BKE_global.h" #include "BKE_utildefines.h" #include "ED_image.h" @@ -528,6 +522,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) { if (t->flag & T_EDIT) { float obmat[3][3]; copy_m3_m4(obmat, t->scene->obedit->obmat); + normalize_m3(obmat); setConstraint(t, obmat, mode, text); } else { @@ -623,8 +618,10 @@ void drawConstraint(const struct bContext *C, TransInfo *t) if (tc->mode & CON_SELECT) { float vec[3]; char col2[3] = {255,255,255}; + int depth_test_enabled; + convertViewVec(t, vec, (short)(t->mval[0] - t->con.imval[0]), (short)(t->mval[1] - t->con.imval[1])); - add_v3_v3v3(vec, vec, tc->center); + add_v3_v3(vec, tc->center); drawLine(t, tc->center, tc->mtx[0], 'x', 0); drawLine(t, tc->center, tc->mtx[1], 'y', 0); @@ -632,15 +629,18 @@ void drawConstraint(const struct bContext *C, TransInfo *t) glColor3ubv((GLubyte *)col2); - glDisable(GL_DEPTH_TEST); + depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); + if(depth_test_enabled) + glDisable(GL_DEPTH_TEST); + setlinestyle(1); glBegin(GL_LINE_STRIP); glVertex3fv(tc->center); glVertex3fv(vec); glEnd(); setlinestyle(0); - // TRANSFORM_FIX_ME - //if(G.vd->zbuf) + + if(depth_test_enabled) glEnable(GL_DEPTH_TEST); } @@ -856,7 +856,7 @@ static void setNearestAxis3d(TransInfo *t) mul_v3_fl(axis, zfac); /* now we can project to get window coordinate */ - add_v3_v3v3(axis, axis, t->con.center); + add_v3_v3(axis, t->con.center); projectIntView(t, axis, icoord); axis[0] = (float)(icoord[0] - t->center2d[0]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index f9c537e1c20..5609b7068b3 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -35,8 +35,6 @@ #include <string.h> #include <math.h> -#include "MEM_guardedalloc.h" - #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_lattice_types.h" @@ -47,41 +45,30 @@ #include "DNA_sequence_types.h" #include "DNA_view3d_types.h" #include "DNA_constraint_types.h" +#include "DNA_scene_types.h" +#include "DNA_meshdata_types.h" + +#include "MEM_guardedalloc.h" -#include "BKE_anim.h" #include "BKE_action.h" #include "BKE_armature.h" -#include "BKE_blender.h" -#include "BKE_cloth.h" #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_constraint.h" #include "BKE_depsgraph.h" -#include "BKE_displist.h" -#include "BKE_DerivedMesh.h" -#include "BKE_effect.h" -#include "BKE_font.h" #include "BKE_fcurve.h" #include "BKE_global.h" -#include "BKE_lattice.h" #include "BKE_key.h" #include "BKE_main.h" -#include "BKE_mball.h" -#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_nla.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_sequencer.h" #include "BKE_pointcache.h" -#include "BKE_softbody.h" -#include "BKE_utildefines.h" #include "BKE_bmesh.h" -#include "BKE_context.h" -#include "BKE_report.h" #include "BKE_scene.h" -#include "BIF_gl.h" #include "ED_anim_api.h" #include "ED_armature.h" @@ -94,6 +81,7 @@ #include "ED_mesh.h" #include "ED_types.h" #include "ED_uvedit.h" +#include "ED_curve.h" /* for ED_curve_editnurbs */ #include "UI_view2d.h" @@ -659,7 +647,8 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb) } } -/* sets transform flags in the bones, returns total */ +/* sets transform flags in the bones + * returns total number of bones with BONE_TRANSFORM */ int count_set_pose_transflags(int *out_mode, short around, Object *ob) { bArmature *arm= ob->data; @@ -1347,12 +1336,14 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) int count=0, countsel=0; int propmode = t->flag & T_PROP_EDIT; short hide_handles = (cu->drawflag & CU_HIDE_HANDLES); - + ListBase *nurbs; + /* to be sure */ if(cu->editnurb==NULL) return; /* count total of vertices, check identical as in 2nd loop for making transdata! */ - for(nu= cu->editnurb->first; nu; nu= nu->next) { + nurbs= ED_curve_editnurbs(cu); + for(nu= nurbs->first; nu; nu= nu->next) { if(nu->type == CU_BEZIER) { for(a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) { if(bezt->hide==0) { @@ -1388,7 +1379,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) invert_m3_m3(smtx, mtx); td = t->data; - for(nu= cu->editnurb->first; nu; nu= nu->next) { + for(nu= nurbs->first; nu; nu= nu->next) { if(nu->type == CU_BEZIER) { TransData *head, *tail; head = tail = td; @@ -1541,7 +1532,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) static void createTransLatticeVerts(bContext *C, TransInfo *t) { - Lattice *latt = ((Lattice*)t->obedit->data)->editlatt; + Lattice *latt = ((Lattice*)t->obedit->data)->editlatt->latt; TransData *td = NULL; BPoint *bp; float mtx[3][3], smtx[3][3]; @@ -1772,14 +1763,17 @@ static int connectivity_edge(float mtx[][3], EditVert *v1, EditVert *v2) float edge_len; int done = 0; + /* note: hidden verts are not being checked for, this assumes + * flushing of hidden faces & edges is working right */ + + if (v1->f2 + v2->f2 == 4) + return 0; + sub_v3_v3v3(edge_vec, v1->co, v2->co); mul_m3_v3(mtx, edge_vec); edge_len = len_v3(edge_vec); - if (v1->f2 + v2->f2 == 4) - return 0; - if (v1->f2) { if (v2->f2) { if (v2->tmp.fp + edge_len + THRESHOLD < v1->tmp.fp) { @@ -1845,7 +1839,7 @@ static void editmesh_set_connectivity_distance(EditMesh *em, float mtx[][3]) /* do internal edges for quads */ for(efa= em->faces.first; efa; efa= efa->next) { - if (efa->v4) { + if (efa->v4 && efa->h==0) { done |= connectivity_edge(mtx, efa->v1, efa->v3); done |= connectivity_edge(mtx, efa->v2, efa->v4); } @@ -2283,7 +2277,7 @@ void flushTransNodes(TransInfo *t) #define XXX_DURIAN_ANIM_TX_HACK void flushTransSeq(TransInfo *t) { - ListBase *seqbasep= seq_give_editing(t->scene, FALSE)->seqbasep; /* Editing null check alredy done */ + ListBase *seqbasep= seq_give_editing(t->scene, FALSE)->seqbasep; /* Editing null check already done */ int a, new_frame; TransData *td= NULL; TransData2D *td2d= NULL; @@ -2896,7 +2890,7 @@ static void posttrans_fcurve_clean (FCurve *fcu) * (if any keyframes were found, or the whole curve wasn't affected) */ if ((len) && (len != fcu->totvert)) { - for (i = 0; i < fcu->totvert; i++) { + for (i= fcu->totvert-1; i >= 0; i--) { BezTriple *bezt= &fcu->bezt[i]; if (BEZSELECTED(bezt) == 0) { @@ -2906,7 +2900,7 @@ static void posttrans_fcurve_clean (FCurve *fcu) delete_fcurve_key(fcu, i, 0); break; } - else if (bezt->vec[1][0] > selcache[index]) + else if (bezt->vec[1][0] < selcache[index]) break; } } @@ -2972,9 +2966,8 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra) bezt->f1 |= SELECT; bezt->f3 |= SELECT; - /* increment by 3, as there are 3 points (3 * x-coordinates) that need transform */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) - count += 3; + count += 1; } } @@ -3023,9 +3016,10 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt) * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data * on the named side are used. */ -static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, char side, float cfra) +static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FCurve *fcu, AnimData *adt, char side, float cfra) { BezTriple *bezt; + TransData2D *td2d = *td2dv; int i; if (fcu == NULL) @@ -3033,22 +3027,27 @@ static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, c for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { /* only add selected keyframes (for now, proportional edit is not enabled) */ - if (BEZSELECTED(bezt)) { + if (bezt->f2 & SELECT) { /* note this MUST match count_fcurve_keys(), so can't use BEZSELECTED() macro */ /* only add if on the right 'side' of the current frame */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { - /* each control point needs to be added separetely */ - TimeToTransData(td, bezt->vec[0], adt); - td++; - TimeToTransData(td, bezt->vec[1], adt); - td++; - TimeToTransData(td, bezt->vec[2], adt); + /*set flags to move handles as necassary*/ + td->flag |= TD_MOVEHANDLE1|TD_MOVEHANDLE2; + td2d->h1 = bezt->vec[0]; + td2d->h2 = bezt->vec[2]; + + VECCOPY2D(td2d->ih1, td2d->h1); + VECCOPY2D(td2d->ih2, td2d->h2); + td++; + td2d++; } } } + *td2dv = td2d; + return td; } @@ -3116,6 +3115,7 @@ static void createTransActionData(bContext *C, TransInfo *t) { Scene *scene= t->scene; TransData *td = NULL; + TransData2D *td2d = NULL; tGPFtransdata *tfd = NULL; bAnimContext ac; @@ -3179,7 +3179,9 @@ static void createTransActionData(bContext *C, TransInfo *t) t->total= count; t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)"); + t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "transdata2d"); td= t->data; + td2d = t->data2d; if (ac.datatype == ANIMCONT_GPENCIL) { if (t->mode == TFM_TIME_SLIDE) { @@ -3216,7 +3218,7 @@ static void createTransActionData(bContext *C, TransInfo *t) else cfra = (float)CFRA; - td= FCurveToTransData(td, fcu, adt, t->frame_side, cfra); + td= ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra); //} } @@ -3248,8 +3250,13 @@ static void createTransActionData(bContext *C, TransInfo *t) /* Helper function for createTransGraphEditData, which is reponsible for associating * source data with transform data */ -static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, float *loc, float *cent, short selected, short ishandle, short intvals) +static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, BezTriple *bezt, + int bi, short selected, short ishandle, short intvals, + float mtx[3][3], float smtx[3][3]) { + float *loc = bezt->vec[bi]; + float *cent = bezt->vec[1]; + /* New location from td gets dumped onto the old-location of td2d, which then * gets copied to the actual data at td2d->loc2d (bezt->vec[n]) * @@ -3280,7 +3287,21 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, VECCOPY(td->center, cent); VECCOPY(td->iloc, td->loc); } - + + if (td->flag & TD_MOVEHANDLE1) { + td2d->h1 = bezt->vec[0]; + VECCOPY2D(td2d->ih1, td2d->h1); + } + else + td2d->h1 = NULL; + + if (td->flag & TD_MOVEHANDLE2) { + td2d->h2 = bezt->vec[2]; + VECCOPY2D(td2d->ih2, td2d->h2); + } + else + td2d->h2 = NULL; + memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; @@ -3300,9 +3321,10 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, td->flag |= TD_NOTIMESNAP; if (intvals) td->flag |= TD_INTVALUES; - - unit_m3(td->mtx); - unit_m3(td->smtx); + + /* copy space-conversion matrices for dealing with non-uniform scales */ + copy_m3_m3(td->mtx, mtx); + copy_m3_m3(td->smtx, smtx); } static void createTransGraphEditData(bContext *C, TransInfo *t) @@ -3323,6 +3345,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) BezTriple *bezt; int count=0, i; float cfra; + float mtx[3][3], smtx[3][3]; /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -3366,7 +3389,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { - if (sipo->around == V3D_LOCAL) { + if (sipo->around == V3D_LOCAL && !ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE)) { /* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't * don't get moved wrong */ @@ -3376,6 +3399,15 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } else if (bezt->f2 & SELECT) count++; // TODO: could this cause problems? } + else if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { + /* for 'normal' pivots - just include anything that is selected. + this works a bit differently in translation modes */ + if (bezt->f2 & SELECT) count++; + else { + if (bezt->f1 & SELECT) count++; + if (bezt->f3 & SELECT) count++; + } + } else { /* for 'normal' pivots - just include anything that is selected */ if (bezt->f1 & SELECT) count++; @@ -3403,12 +3435,31 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) td= t->data; td2d= t->data2d; + /* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */ + unit_m3(mtx); + unit_m3(smtx); + + if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { + float xscale, yscale; + + /* apply scale factors to x and y axes of space-conversion matrices */ + UI_view2d_getscale(v2d, &xscale, &yscale); + + /* mtx is data to global (i.e. view) conversion */ + mul_v3_fl(mtx[0], xscale); + mul_v3_fl(mtx[1], yscale); + + /* smtx is global (i.e. view) to data conversion */ + if (IS_EQ(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale); + if (IS_EQ(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale); + } + /* loop 2: build transdata arrays */ for (ale= anim_data.first; ale; ale= ale->next) { AnimData *adt= ANIM_nla_mapping_get(&ac, ale); FCurve *fcu= (FCurve *)ale->key_data; short intvals= (fcu->flag & FCURVE_INT_VALUES); - + /* convert current-frame to action-time (slightly less accurate, espcially under * higher scaling ratios, but is faster than converting all points) */ @@ -3429,23 +3480,34 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) TransDataCurveHandleFlags *hdata = NULL; short h1=1, h2=1; - /* only include handles if selected, irrespective of the interpolation modes */ - if (bezt->f1 & SELECT) { - hdata = initTransDataCurveHandles(td, bezt); - bezt_to_transdata(td++, td2d++, adt, bezt->vec[0], bezt->vec[1], 1, 1, intvals); - } - else - h1= 0; - if (bezt->f3 & SELECT) { - if (hdata==NULL) + /* only include handles if selected, irrespective of the interpolation modes. + * also, only treat handles specially if the center point isn't selected. + */ + if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(bezt->f2 & SELECT)) { + if (bezt->f1 & SELECT) { hdata = initTransDataCurveHandles(td, bezt); - bezt_to_transdata(td++, td2d++, adt, bezt->vec[2], bezt->vec[1], 1, 1, intvals); + bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx); + } + else + h1= 0; + + if (bezt->f3 & SELECT) { + if (hdata==NULL) + hdata = initTransDataCurveHandles(td, bezt); + bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx); + } + else + h2= 0; } - else - h2= 0; /* only include main vert if selected */ if (bezt->f2 & SELECT) { + /* move handles relative to center */ + if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { + if (bezt->f1 & SELECT) td->flag |= TD_MOVEHANDLE1; + if (bezt->f3 & SELECT) td->flag |= TD_MOVEHANDLE2; + } + /* if scaling around individuals centers, do not include keyframes */ if (sipo->around != V3D_LOCAL) { /* if handles were not selected, store their selection status */ @@ -3454,7 +3516,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) hdata = initTransDataCurveHandles(td, bezt); } - bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals); + bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, mtx, smtx); } /* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...): @@ -3700,7 +3762,7 @@ void flushTransGraphData(TransInfo *t) break; } } - + /* we need to unapply the nla-mapping from the time in some situations */ if (adt) td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP); @@ -3712,6 +3774,16 @@ void flushTransGraphData(TransInfo *t) td2d->loc2d[1]= (float)((int)td2d->loc[1]); else td2d->loc2d[1]= td2d->loc[1]; + + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { + td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0]; + td2d->h1[1] = td2d->ih1[1] + td->loc[1] - td->iloc[1]; + } + + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { + td2d->h2[0] = td2d->ih2[0] + td->loc[0] - td->iloc[0]; + td2d->h2[1] = td2d->ih2[1] + td->loc[1] - td->iloc[1]; + } } } @@ -4299,7 +4371,11 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t) /* if parent selected, deselect */ while(parsel) { - if(parsel->flag & SELECT) break; + if(parsel->flag & SELECT) { + Base *parbase = object_in_scene(parsel, scene); + if TESTBASELIB_BGMODE(v3d, scene, parbase) + break; + } parsel= parsel->parent; } @@ -4319,7 +4395,7 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t) } /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ - DAG_scene_flush_update(t->scene, -1, 0); + DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ @@ -4397,7 +4473,7 @@ static int count_proportional_objects(TransInfo *t) /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ - DAG_scene_flush_update(t->scene, -1, 0); + DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ @@ -4421,7 +4497,7 @@ static void clear_trans_object_base_flags(TransInfo *t) if(base->flag & BA_WAS_SEL) base->flag |= SELECT; - base->flag &= ~(BA_WAS_SEL|BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA|BA_DO_IPO|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT); + base->flag &= ~(BA_WAS_SEL|BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA|BA_TEMP_TAG|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT); } } @@ -4451,7 +4527,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, /* only insert into active keyingset * NOTE: we assume here that the active Keying Set does not need to have its iterator overridden spe */ - ANIM_apply_keyingset(C, NULL, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); + ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); } else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) { AnimData *adt= ob->adt; @@ -4560,9 +4636,9 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); /* only insert into active keyingset? */ - // TODO: move this first case out of the loop if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (active_ks)) { - ANIM_apply_keyingset(C, NULL, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); + /* run the active Keying Set on the current datasource */ + ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); } /* only insert into available channels? */ else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) { @@ -4748,7 +4824,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) // fixme... some of this stuff is not good if (ob) { if (ob->pose || ob_get_key(ob)) - DAG_id_flush_update(&ob->id, OB_RECALC); + DAG_id_flush_update(&ob->id, OB_RECALC_ALL); else DAG_id_flush_update(&ob->id, OB_RECALC_OB); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8bbeec63155..15e2d32cc94 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -39,7 +39,11 @@ #include "DNA_lattice_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" +#include "DNA_meshdata_types.h" #include "DNA_view3d_types.h" +#include "DNA_modifier_types.h" #include "RNA_access.h" @@ -54,23 +58,14 @@ #include "BKE_animsys.h" #include "BKE_action.h" -#include "BKE_anim.h" #include "BKE_armature.h" -#include "BKE_cloth.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" -#include "BKE_depsgraph.h" #include "BKE_fcurve.h" -#include "BKE_global.h" -#include "BKE_group.h" #include "BKE_lattice.h" -#include "BKE_key.h" #include "BKE_mesh.h" -#include "BKE_modifier.h" #include "BKE_nla.h" -#include "BKE_object.h" -#include "BKE_utildefines.h" #include "BKE_context.h" #include "ED_anim_api.h" @@ -84,6 +79,7 @@ #include "ED_space_api.h" #include "ED_uvedit.h" #include "ED_view3d.h" +#include "ED_curve.h" /* for ED_curve_editnurbs */ //#include "BDR_unwrapper.h" @@ -189,8 +185,8 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) copy_v3_v3(iloc, td->iloc); if (mmd->mirror_ob) { - mul_v3_m4v3(loc, mtx, loc); - mul_v3_m4v3(iloc, mtx, iloc); + mul_m4_v3(mtx, loc); + mul_m4_v3(mtx, iloc); } clip = 0; @@ -218,7 +214,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) } if (clip) { if (mmd->mirror_ob) { - mul_v3_m4v3(loc, imtx, loc); + mul_m4_v3(imtx, loc); } copy_v3_v3(td->loc, loc); } @@ -636,14 +632,15 @@ void recalcData(TransInfo *t) if (t->obedit) { if ELEM(t->obedit->type, OB_CURVE, OB_SURF) { Curve *cu= t->obedit->data; - Nurb *nu= cu->editnurb->first; + ListBase *nurbs= ED_curve_editnurbs(cu); + Nurb *nu= nurbs->first; if(t->state != TRANS_CANCEL) { clipMirrorModifier(t, t->obedit); } DAG_id_flush_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */ - + if (t->state == TRANS_CANCEL) { while(nu) { calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */ @@ -662,7 +659,7 @@ void recalcData(TransInfo *t) Lattice *la= t->obedit->data; DAG_id_flush_update(t->obedit->data, OB_RECALC_DATA); /* sets recalc flags */ - if(la->editlatt->flag & LT_OUTSIDE) outside_lattice(la->editlatt); + if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt); } else if (t->obedit->type == OB_MESH) { EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh; @@ -810,7 +807,7 @@ void recalcData(TransInfo *t) /* sets recalc flags fully, instead of flushing existing ones * otherwise proxies don't function correctly */ - DAG_id_flush_update(&ob->id, OB_RECALC); + DAG_id_flush_update(&ob->id, OB_RECALC_OB); } } @@ -960,7 +957,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) { t->current_orientation = RNA_enum_get(op->ptr, "constraint_orientation"); - if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C) - 1) + if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C)) { t->current_orientation = V3D_MANIP_GLOBAL; } @@ -1031,9 +1028,9 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) { switch(RNA_enum_get(op->ptr, "proportional")) { - case 2: /* XXX connected constant */ + case PROP_EDIT_CONNECTED: t->flag |= T_PROP_CONNECTED; - case 1: /* XXX prop on constant */ + case PROP_EDIT_ON: t->flag |= T_PROP_EDIT; break; } @@ -1043,11 +1040,19 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* use settings from scene only if modal */ if (t->flag & T_MODAL) { - if ((t->options & CTX_NO_PET) == 0 && (ts->proportional != PROP_EDIT_OFF)) { - t->flag |= T_PROP_EDIT; + if ((t->options & CTX_NO_PET) == 0) + { + if (t->obedit && ts->proportional != PROP_EDIT_OFF) + { + t->flag |= T_PROP_EDIT; - if(ts->proportional == PROP_EDIT_CONNECTED) - t->flag |= T_PROP_CONNECTED; + if(ts->proportional == PROP_EDIT_CONNECTED) + t->flag |= T_PROP_CONNECTED; + } + else if (t->obedit == NULL && ts->proportional_objects) + { + t->flag |= T_PROP_EDIT; + } } } } @@ -1068,9 +1073,9 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->prop_size = 1.0f; } - if (op && RNA_struct_find_property(op->ptr, "proportional_editing_falloff") && RNA_property_is_set(op->ptr, "proportional_editing_falloff")) + if (op && RNA_struct_find_property(op->ptr, "proportional_edit_falloff") && RNA_property_is_set(op->ptr, "proportional_edit_falloff")) { - t->prop_mode = RNA_enum_get(op->ptr, "proportional_editing_falloff"); + t->prop_mode = RNA_enum_get(op->ptr, "proportional_edit_falloff"); } else { @@ -1167,6 +1172,7 @@ static void restoreElement(TransData *td) { if (td->val) { *td->val = td->ival; } + if (td->ext && (td->flag&TD_NO_EXT)==0) { if (td->ext->rot) { VECCOPY(td->ext->rot, td->ext->irot); @@ -1188,11 +1194,23 @@ static void restoreElement(TransData *td) { void restoreTransObjects(TransInfo *t) { TransData *td; - + TransData2D *td2d; + for (td = t->data; td < t->data + t->total; td++) { restoreElement(td); } + for (td2d=t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) { + if (td2d->h1) { + td2d->h1[0] = td2d->ih1[0]; + td2d->h1[1] = td2d->ih1[1]; + } + if (td2d->h2) { + td2d->h2[0] = td2d->ih2[0]; + td2d->h2[1] = td2d->ih2[1]; + } + } + unit_m3(t->mat); recalcData(t); @@ -1276,7 +1294,7 @@ void calculateCenterMedian(TransInfo *t) if (t->data[i].flag & TD_SELECTED) { if (!(t->data[i].flag & TD_NOCENTER)) { - add_v3_v3v3(partial, partial, t->data[i].center); + add_v3_v3(partial, t->data[i].center); total++; } } diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index d7ebd28f604..54a86b3dca1 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -197,17 +197,17 @@ void InputCustomRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[ mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2]; mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3]; - distance = (mdx*dx + mdy*dy) / length; + distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; } else { short mdx, mdy; mdx = mval[0] - data[2]; mdy = mval[1] - data[3]; - distance = (mdx*dx + mdy*dy) / length; + distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; } - output[0] = distance / length; + output[0] = (length != 0.0f)? distance / length: 0.0f; } } @@ -237,7 +237,7 @@ void InputAngle(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; /* If the angle is zero, because of lack of precision close to the 1.0 value in acos - * approximate the angle with the oposite side of the normalized triangle + * approximate the angle with the opposite side of the normalized triangle * This is a good approximation here since the smallest acos value seems to be around * 0.02 degree and lower values don't even have a 0.01% error compared to the approximation * */ diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index b11f35dd363..396cb15e61a 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -51,15 +51,11 @@ #include "RNA_access.h" #include "BKE_action.h" -#include "BKE_armature.h" #include "BKE_context.h" #include "BKE_global.h" -#include "BKE_lattice.h" #include "BKE_mesh.h" -#include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" #include "BLI_math.h" #include "BLI_editVert.h" @@ -73,6 +69,7 @@ #include "ED_mesh.h" #include "ED_particle.h" #include "ED_view3d.h" +#include "ED_curve.h" /* for ED_curve_editnurbs */ #include "UI_resources.h" @@ -122,7 +119,7 @@ static void calc_tw_center(Scene *scene, float *co) float *max= scene->twmax; DO_MINMAX(co, min, max); - add_v3_v3v3(twcent, twcent, co); + add_v3_v3(twcent, co); } static void protectflag_to_drawflags(short protectflag, short *drawflags) @@ -291,7 +288,7 @@ int calc_manipulator_stats(const bContext *C) bArmature *arm= obedit->data; EditBone *ebo; for (ebo= arm->edbo->first; ebo; ebo=ebo->next){ - if(ebo->layer & arm->layer) { + if(ebo->layer & arm->layer && !(ebo->flag & BONE_HIDDEN_A)) { if (ebo->flag & BONE_TIPSEL) { calc_tw_center(scene, ebo->tail); totsel++; @@ -311,8 +308,9 @@ int calc_manipulator_stats(const bContext *C) Nurb *nu; BezTriple *bezt; BPoint *bp; + ListBase *nurbs= ED_curve_editnurbs(cu); - nu= cu->editnurb->first; + nu= nurbs->first; while(nu) { if(nu->type == CU_BEZIER) { bezt= nu->bezt; @@ -381,9 +379,9 @@ int calc_manipulator_stats(const bContext *C) BPoint *bp; Lattice *lt= obedit->data; - bp= lt->editlatt->def; + bp= lt->editlatt->latt->def; - a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; while(a--) { if(bp->f1 & SELECT) { calc_tw_center(scene, bp->vec); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index eba6482c884..10047c5a0f7 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -32,7 +32,6 @@ #include "BLI_math.h" -#include "BKE_utildefines.h" #include "BKE_context.h" #include "BKE_global.h" @@ -61,6 +60,7 @@ char OP_RESIZE[] = "TRANSFORM_OT_resize"; char OP_SHEAR[] = "TRANSFORM_OT_shear"; char OP_WARP[] = "TRANSFORM_OT_warp"; char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten"; +char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull"; char OP_TILT[] = "TRANSFORM_OT_tilt"; char OP_TRACKBALL[] = "TRANSFORM_OT_trackball"; char OP_MIRROR[] = "TRANSFORM_OT_mirror"; @@ -75,6 +75,7 @@ void TRANSFORM_OT_resize(struct wmOperatorType *ot); void TRANSFORM_OT_shear(struct wmOperatorType *ot); void TRANSFORM_OT_warp(struct wmOperatorType *ot); void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot); +void TRANSFORM_OT_push_pull(struct wmOperatorType *ot); void TRANSFORM_OT_tilt(struct wmOperatorType *ot); void TRANSFORM_OT_trackball(struct wmOperatorType *ot); void TRANSFORM_OT_mirror(struct wmOperatorType *ot); @@ -91,6 +92,7 @@ TransformModeItem transform_modes[] = {OP_SHEAR, TFM_SHEAR, TRANSFORM_OT_shear}, {OP_WARP, TFM_WARP, TRANSFORM_OT_warp}, {OP_SHRINK_FATTEN, TFM_SHRINKFATTEN, TRANSFORM_OT_shrink_fatten}, + {OP_PUSH_PULL, TFM_PUSHPULL, TRANSFORM_OT_push_pull}, {OP_TILT, TFM_TILT, TRANSFORM_OT_tilt}, {OP_TRACKBALL, TFM_TRACKBALL, TRANSFORM_OT_trackball}, {OP_MIRROR, TFM_MIRROR, TRANSFORM_OT_mirror}, @@ -278,7 +280,7 @@ static int transformops_data(bContext *C, wmOperator *op, wmEvent *event) int retval = 1; if (op->customdata == NULL) { - TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data"); + TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2"); TransformModeItem *tmode; int mode = -1; @@ -300,7 +302,12 @@ static int transformops_data(bContext *C, wmOperator *op, wmEvent *event) G.moving = 1; /* store data */ - op->customdata = t; + if(retval) { + op->customdata = t; + } + else { + MEM_freeN(t); + } } return retval; /* return 0 on error */ @@ -389,15 +396,20 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) { prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_array(prop, 3); + /* Make this not hidden when there's a nice axis selection widget */ + RNA_def_property_flag(prop, PROP_HIDDEN); RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs"); + } if (flags & P_CONSTRAINT) { - RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", ""); + prop= RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", ""); prop= RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE); RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation"); RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf); + + } if (flags & P_MIRROR) @@ -409,28 +421,33 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) if (flags & P_PROPORTIONAL) { RNA_def_enum(ot->srna, "proportional", proportional_editing_items, 0, "Proportional Editing", ""); - RNA_def_enum(ot->srna, "proportional_editing_falloff", proportional_falloff_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode."); + RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode."); RNA_def_float(ot->srna, "proportional_size", 1, 0, FLT_MAX, "Proportional Size", "", 0, 100); } if (flags & P_SNAP) { - RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", ""); + prop= RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); if (flags & P_GEO_SNAP) { - RNA_def_enum(ot->srna, "snap_target", snap_target_items, 0, "Target", ""); - RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX); - + prop= RNA_def_enum(ot->srna, "snap_target", snap_target_items, 0, "Target", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(prop, PROP_HIDDEN); + if (flags & P_ALIGN_SNAP) { - RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", ""); - RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX); + prop= RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop= RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(prop, PROP_HIDDEN); } } } // Add confirm method all the time. At the end because it's not really that important and should be hidden prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button"); - //RNA_def_property_flag(prop, PROP_HIDDEN); + RNA_def_property_flag(prop, PROP_HIDDEN); } void TRANSFORM_OT_translate(struct wmOperatorType *ot) @@ -448,7 +465,7 @@ void TRANSFORM_OT_translate(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_areaactive; - RNA_def_float_vector(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); + RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL|P_MIRROR|P_ALIGN_SNAP); } @@ -579,6 +596,26 @@ void TRANSFORM_OT_shear(struct wmOperatorType *ot) // XXX Shear axis? } +void TRANSFORM_OT_push_pull(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Push/Pull"; + ot->description= "Push/Pull selected items"; + ot->idname = OP_PUSH_PULL; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + + /* api callbacks */ + ot->invoke = transform_invoke; + ot->exec = transform_exec; + ot->modal = transform_modal; + ot->cancel = transform_cancel; + ot->poll = ED_operator_areaactive; + + RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX); + + Transform_Properties(ot, P_PROPORTIONAL|P_MIRROR|P_SNAP); +} + void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot) { /* identifiers */ @@ -814,7 +851,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac km = WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0); km = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(km->ptr, "path", "tool_settings.snap"); + RNA_string_set(km->ptr, "data_path", "tool_settings.snap"); km = WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); @@ -892,7 +929,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac km = WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0); km = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(km->ptr, "path", "tool_settings.snap"); + RNA_string_set(km->ptr, "data_path", "tool_settings.snap"); break; default: break; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index d509ce97015..210ab0d45a8 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -34,7 +34,6 @@ #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BKE_global.h" #include "BKE_utildefines.h" #include "BKE_armature.h" #include "BKE_context.h" @@ -51,6 +50,7 @@ #include "ED_armature.h" #include "ED_mesh.h" +#include "ED_curve.h" /* for ED_curve_editnurbs */ #include "RNA_define.h" @@ -517,6 +517,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) case V3D_MANIP_GIMBAL: unit_m3(t->spacemtx); if (gimbal_axis(ob, t->spacemtx)) { + strcpy(t->spacename, "gimbal"); break; } /* no gimbal fallthrough to normal */ @@ -725,7 +726,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], for (eve = em->verts.first; eve; eve = eve->next) { if ( eve->f & SELECT ) { - add_v3_v3v3(normal, normal, eve->no); + add_v3_v3(normal, eve->no); } } normalize_v3(normal); @@ -739,8 +740,9 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], Nurb *nu; BezTriple *bezt; int a; - - for (nu = cu->editnurb->first; nu; nu = nu->next) + ListBase *nurbs= ED_curve_editnurbs(cu); + + for (nu = nurbs->first; nu; nu = nu->next) { /* only bezier has a normal */ if(nu->type == CU_BEZIER) @@ -832,10 +834,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], float vec[3]; sub_v3_v3v3(vec, ebone->tail, ebone->head); normalize_v3(vec); - add_v3_v3v3(normal, normal, vec); + add_v3_v3(normal, vec); vec_roll_to_mat3(vec, ebone->roll, mat); - add_v3_v3v3(plane, plane, mat[2]); + add_v3_v3(plane, mat[2]); } } } @@ -875,8 +877,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], /* use channels to get stats */ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) { - add_v3_v3v3(normal, normal, pchan->pose_mat[2]); - add_v3_v3v3(plane, plane, pchan->pose_mat[1]); + add_v3_v3(normal, pchan->pose_mat[2]); + add_v3_v3(plane, pchan->pose_mat[1]); } } negate_v3(plane); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index b49e1b05de3..778698d3060 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -36,6 +36,7 @@ #include "DNA_armature_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_meshdata_types.h" // Temporary, for snapping to other unselected meshes #include "DNA_space_types.h" #include "DNA_screen_types.h" @@ -53,15 +54,12 @@ //#include "editmesh.h" //#include "BIF_editsima.h" #include "BIF_gl.h" -#include "BIF_glutil.h" //#include "BIF_mywindow.h" //#include "BIF_screen.h" //#include "BIF_editsima.h" //#include "BIF_drawimage.h" //#include "BIF_editmesh.h" -#include "BKE_global.h" -#include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_object.h" #include "BKE_anim.h" /* for duplis */ @@ -279,7 +277,7 @@ void applyProject(TransInfo *t) mul_m3_v3(td->smtx, tvec); - add_v3_v3v3(td->loc, td->loc, tvec); + add_v3_v3(td->loc, tvec); } //XXX constraintTransLim(t, td); @@ -442,9 +440,9 @@ void initSnapping(TransInfo *t, wmOperator *op) normalize_v3(t->tsnap.snapNormal); } - if (RNA_struct_find_property(op->ptr, "snap_project")) + if (RNA_struct_find_property(op->ptr, "use_snap_project")) { - t->tsnap.project = RNA_boolean_get(op->ptr, "snap_project"); + t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project"); } } } @@ -912,7 +910,7 @@ void TargetSnapMedian(TransInfo *t) for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { - add_v3_v3v3(t->tsnap.snapTarget, t->tsnap.snapTarget, td->center); + add_v3_v3(t->tsnap.snapTarget, td->center); } mul_v3_fl(t->tsnap.snapTarget, 1.0 / i); @@ -1030,7 +1028,7 @@ int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4 VECCOPY(intersect, ray_normal_local); mul_v3_fl(intersect, lambda); - add_v3_v3v3(intersect, intersect, ray_start_local); + add_v3_v3(intersect, ray_start_local); VECCOPY(location, intersect); @@ -1730,7 +1728,7 @@ int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta VECCOPY(intersect, ray_normal_local); mul_v3_fl(intersect, lambda); - add_v3_v3v3(intersect, intersect, ray_start_local); + add_v3_v3(intersect, ray_start_local); VECCOPY(location, intersect); @@ -1760,7 +1758,7 @@ int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_sta VECCOPY(intersect, ray_normal_local); mul_v3_fl(intersect, lambda); - add_v3_v3v3(intersect, intersect, ray_start_local); + add_v3_v3(intersect, ray_start_local); VECCOPY(location, intersect); @@ -1897,26 +1895,13 @@ void snapGridAction(TransInfo *t, float *val, GearsType action) { void snapGrid(TransInfo *t, float *val) { - int invert; GearsType action; // Only do something if using Snap to Grid if (t->tsnap.mode != SCE_SNAP_MODE_INCREMENT) return; - if(t->mode==TFM_ROTATION || t->mode==TFM_WARP || t->mode==TFM_TILT || t->mode==TFM_TRACKBALL || t->mode==TFM_BONE_ROLL) - invert = U.flag & USER_AUTOROTGRID; - else if(t->mode==TFM_RESIZE || t->mode==TFM_SHEAR || t->mode==TFM_BONESIZE || t->mode==TFM_SHRINKFATTEN || t->mode==TFM_CURVE_SHRINKFATTEN) - invert = U.flag & USER_AUTOSIZEGRID; - else - invert = U.flag & USER_AUTOGRABGRID; - - if(invert) { - action = activeSnap(t) ? NO_GEARS: BIG_GEARS; - } - else { - action = activeSnap(t) ? BIG_GEARS : NO_GEARS; - } + action = activeSnap(t) ? BIG_GEARS : NO_GEARS; if (action == BIG_GEARS && (t->modifiers & MOD_PRECISION)) { action = SMALL_GEARS; |