diff options
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 102 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 7 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 48 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 67 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 10 |
9 files changed, 182 insertions, 73 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index b210ce82acb..bbc4e0e4783 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -89,6 +89,7 @@ void load_editMesh(Scene *scene, Object *ob); void remake_editMesh(Scene *scene, Object *ob); void free_editMesh(struct EditMesh *em); +void recalc_editnormals(struct EditMesh *em); void EM_init_index_arrays(struct EditMesh *em, int forVert, int forEdge, int forFace); void EM_free_index_arrays(void); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 8000d227885..90a328bb49a 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -127,8 +127,6 @@ extern EditFace *exist_face(EditMesh *em, EditVert *v1, EditVert *v2, EditVert * extern void flipface(EditMesh *em, EditFace *efa); // flips for normal direction extern int compareface(EditFace *vl1, EditFace *vl2); -void recalc_editnormals(EditMesh *em); - /* flag for selection bits, *nor will be filled with normal for extrusion constraint */ /* return value defines if such normal was set */ extern short extrudeflag_face_indiv(EditMesh *em, short flag, float *nor); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7807ab32eff..e513a4fcbbc 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -59,6 +59,9 @@ #include "DNA_userdef_types.h" #include "DNA_view3d_types.h" #include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" + +#include "RNA_access.h" //#include "BIF_editview.h" /* arrows_move_cursor */ #include "BIF_gl.h" @@ -560,8 +563,6 @@ void transformEvent(TransInfo *t, wmEvent *event) float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}}; char cmode = constraintModeToChar(t); - t->event = event; - t->redraw |= handleMouseInput(t, &t->mouse, event); if (event->type == MOUSEMOVE) @@ -569,6 +570,8 @@ void transformEvent(TransInfo *t, wmEvent *event) t->mval[0] = event->x - t->ar->winrct.xmin; t->mval[1] = event->y - t->ar->winrct.ymin; + t->redraw = 1; + applyMouseInput(t, &t->mouse, t->mval, t->values); } @@ -577,9 +580,16 @@ void transformEvent(TransInfo *t, wmEvent *event) /* enforce redraw of transform when modifiers are used */ case LEFTCTRLKEY: case RIGHTCTRLKEY: + t->modifiers |= MOD_SNAP_GEARS; t->redraw = 1; break; + case LEFTSHIFTKEY: + case RIGHTSHIFTKEY: + t->modifiers |= MOD_CONSTRAINT_PLANE; + t->redraw = 1; + break; + case SPACEKEY: if ((t->spacetype==SPACE_VIEW3D) && event->alt) { #if 0 // TRANSFORM_FIX_ME @@ -597,7 +607,6 @@ void transformEvent(TransInfo *t, wmEvent *event) } break; - case MIDDLEMOUSE: if ((t->flag & T_NO_CONSTRAINT)==0) { /* exception for switching to dolly, or trackball, in camera view */ @@ -610,7 +619,7 @@ void transformEvent(TransInfo *t, wmEvent *event) } } else { - t->flag |= T_MMB_PRESSED; + t->modifiers |= MOD_CONSTRAINT_SELECT; if (t->con.mode & CON_APPLY) { stopConstraint(t); } @@ -867,11 +876,22 @@ void transformEvent(TransInfo *t, wmEvent *event) } else { switch (event->type){ - /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still - after releasing modifer key */ + case LEFTSHIFTKEY: + case RIGHTSHIFTKEY: + t->modifiers &= ~MOD_CONSTRAINT_PLANE; + t->redraw = 1; + break; + + case LEFTCTRLKEY: + case RIGHTCTRLKEY: + t->modifiers &= ~MOD_SNAP_GEARS; + /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still + after releasing modifer key */ + //t->redraw = 1; + break; case MIDDLEMOUSE: if ((t->flag & T_NO_CONSTRAINT)==0) { - t->flag &= ~T_MMB_PRESSED; + t->modifiers &= ~MOD_CONSTRAINT_SELECT; postSelectConstraint(t); t->redraw = 1; } @@ -928,8 +948,19 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float return success; } -void initTransform(bContext *C, TransInfo *t, int mode, int options, wmEvent *event) +void saveTransform(bContext *C, TransInfo *t, wmOperator *op) +{ + RNA_int_set(op->ptr, "mode", t->mode); + RNA_int_set(op->ptr, "options", t->options); + RNA_float_set_array(op->ptr, "values", t->values); +} + +void initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) { + int mode = RNA_int_get(op->ptr, "mode"); + int options = RNA_int_get(op->ptr, "options"); + float values[4]; + /* added initialize, for external calls to set stuff in TransInfo, like undo string */ t->state = TRANS_RUNNING; @@ -1053,19 +1084,25 @@ void initTransform(bContext *C, TransInfo *t, int mode, int options, wmEvent *ev initNodeTranslate(t); break; } + + + + RNA_float_get_array(op->ptr, "values", values); + + /* overwrite initial values if operator supplied a non-null vector */ + if (!QuatIsNul(values)) + { + QUATCOPY(t->values, values); /* vec-4 */ + } + } void transformApply(TransInfo *t) { - if (1) // MOUSE MOVE - { - if (t->flag & T_MMB_PRESSED) - t->con.mode |= CON_SELECT; - t->redraw = 1; - } if (t->redraw) { - // RESET MOUSE MOVE + if (t->modifiers & MOD_CONSTRAINT_SELECT) + t->con.mode |= CON_SELECT; selectConstraint(t); if (t->transform) { @@ -1090,15 +1127,25 @@ void transformApply(TransInfo *t) int transformEnd(bContext *C, TransInfo *t) { + int exit_code = OPERATOR_RUNNING_MODAL; + if (t->state != TRANS_RUNNING) { /* handle restoring objects */ - if(t->state == TRANS_CANCEL) { + if(t->state == TRANS_CANCEL) + { + exit_code = OPERATOR_CANCELLED; + + /* TRANSFORM_FIX_ME fix jesty's node stuff, shouldn't be exceptional at this level */ if(t->spacetype == SPACE_NODE) restoreTransNodes(t); else restoreTransObjects(t); // calls recalcData() } + else + { + exit_code = OPERATOR_FINISHED; + } /* free data */ postTrans(t); @@ -1119,12 +1166,9 @@ int transformEnd(bContext *C, TransInfo *t) else ED_undo_push(C, transform_to_undostr(t)); } t->undostr= NULL; - - return 1; } - t->event = NULL; - return 0; + return exit_code; } /* ************************** Manipulator init and main **************************** */ @@ -3980,6 +4024,7 @@ int Align(TransInfo *t, short mval[2]) /* ---------------- Special Helpers for Various Settings ------------- */ + /* This function returns the snapping 'mode' for Animation Editors only * We cannot use the standard snapping due to NLA-strip scaling complexities. */ @@ -4008,14 +4053,15 @@ static short getAnimEdit_SnapMode(TransInfo *t) autosnap= snla->autosnap; } else { - // FIXME: this still toggles the modes... - if (t->event->ctrl) - autosnap= SACTSNAP_STEP; - else if (t->event->shift) - autosnap= SACTSNAP_FRAME; - else if (t->event->alt) - autosnap= SACTSNAP_MARKER; - else + // TRANSFORM_FIX_ME This needs to use proper defines for t->modifiers +// // FIXME: this still toggles the modes... +// if (ctrl) +// autosnap= SACTSNAP_STEP; +// else if (shift) +// autosnap= SACTSNAP_FRAME; +// else if (alt) +// autosnap= SACTSNAP_MARKER; +// else autosnap= SACTSNAP_OFF; } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 244a532b187..078109a0a1f 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -46,6 +46,7 @@ struct bPose; struct bConstraint; struct BezTriple; struct wmOperatorType; +struct wmOperator; struct bContext; struct wmEvent; struct ARegion; @@ -187,6 +188,7 @@ typedef struct MouseInput { typedef struct TransInfo { int mode; /* current mode */ int flag; /* generic flags for special behaviors */ + int modifiers; /* special modifiers, by function, not key */ short state; /* current state (running, canceled,...)*/ int options; /* current context/options for transform */ float val; /* init value for some transformations (and rotation angle) */ @@ -239,7 +241,6 @@ typedef struct TransInfo { struct ScrArea *sa; struct ARegion *ar; struct Scene *scene; - struct wmEvent *event; /* last event, reset at the start of each transformApply and nulled at the transformEnd */ short mval[2]; /* current mouse position */ struct Object *obedit; } TransInfo; @@ -282,9 +283,6 @@ typedef struct TransInfo { #define T_PROP_EDIT (1 << 11) #define T_PROP_CONNECTED (1 << 12) - /* if MMB is pressed or not */ -#define T_MMB_PRESSED (1 << 13) - #define T_V3D_ALIGN (1 << 14) /* for 2d views like uv or ipo */ #define T_2D_EDIT (1 << 15) @@ -294,6 +292,13 @@ typedef struct TransInfo { /* auto-ik is on */ #define T_AUTOIK (1 << 18) +/* TransInfo->modifiers */ +#define MOD_CONSTRAINT_SELECT 0x01 +#define MOD_PRECISION 0x02 +#define MOD_SNAP_GEARS 0x04 +#define MOD_CONSTRAINT_PLANE 0x08 + + /* ******************************************************************************** */ /* transinfo->con->mode */ @@ -342,7 +347,8 @@ typedef struct TransInfo { void TFM_OT_transform(struct wmOperatorType *ot); -void initTransform(struct bContext *C, struct TransInfo *t, int mode, int context, struct wmEvent *event); +void initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event); +void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op); void transformEvent(TransInfo *t, struct wmEvent *event); void transformApply(TransInfo *t); int transformEnd(struct bContext *C, TransInfo *t); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index cdde416ef9a..c2a53b8a3d9 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -906,7 +906,6 @@ static void setNearestAxis2d(TransInfo *t) static void setNearestAxis3d(TransInfo *t) { - wmEvent *event = t->event; float zfac; float mvec[3], axis[3], proj[3]; float len[3]; @@ -950,7 +949,7 @@ static void setNearestAxis3d(TransInfo *t) } if (len[0] <= len[1] && len[0] <= len[2]) { - if (event->shift) { + if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS1|CON_AXIS2); sprintf(t->con.text, " locking %s X axis", t->spacename); } @@ -960,7 +959,7 @@ static void setNearestAxis3d(TransInfo *t) } } else if (len[1] <= len[0] && len[1] <= len[2]) { - if (event->shift) { + if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS0|CON_AXIS2); sprintf(t->con.text, " locking %s Y axis", t->spacename); } @@ -970,7 +969,7 @@ static void setNearestAxis3d(TransInfo *t) } } else if (len[2] <= len[1] && len[2] <= len[0]) { - if (event->shift) { + if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS0|CON_AXIS1); sprintf(t->con.text, " locking %s Z axis", t->spacename); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 283d59da482..e817b069034 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -96,6 +96,7 @@ #endif #include "ED_view3d.h" +#include "ED_mesh.h" //#include "BSE_editaction_types.h" //#include "BDR_unwrapper.h" @@ -437,6 +438,7 @@ void recalcData(TransInfo *t) if (G.sima->flag & SI_LIVE_UNWRAP) unwrap_lscm_live_re_solve(); } else { + EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh /* mirror modifier clipping? */ if(t->state != TRANS_CANCEL) { if ((G.qual & LR_CTRLKEY)==0) { @@ -450,7 +452,7 @@ void recalcData(TransInfo *t) DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */ - recalc_editnormals(); + recalc_editnormals(em); } } else if ELEM(t->obedit->type, OB_CURVE, OB_SURF) { @@ -573,8 +575,34 @@ void recalcData(TransInfo *t) flushTransParticles(t); } #endif - if (1) { - //else { + if (t->obedit) { + if (t->obedit->type == OB_MESH) { + if(t->spacetype==SPACE_IMAGE) { + flushTransUVs(t); + /* TRANSFORM_FIX_ME */ +// if (G.sima->flag & SI_LIVE_UNWRAP) +// unwrap_lscm_live_re_solve(); + } else { + EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh; + /* mirror modifier clipping? */ + if(t->state != TRANS_CANCEL) { + /* TRANSFORM_FIX_ME */ +// if ((G.qual & LR_CTRLKEY)==0) { +// /* Only retopo if not snapping, Note, this is the only case of G.qual being used, but we have no T_SHIFT_MOD - Campbell */ +// retopo_do_all(); +// } + clipMirrorModifier(t, t->obedit); + } + if((t->options & CTX_NO_MIRROR) == 0 && (t->scene->toolsettings->editbutflag & B_MESH_X_MIRROR)) + editmesh_apply_to_mirror(t); + + DAG_object_flush_update(t->scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */ + + recalc_editnormals(em); + } + } + } + else { for(base= FIRSTBASE; base; base= base->next) { Object *ob= base->object; @@ -686,6 +714,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event) t->flag = 0; + t->redraw = 1; /* redraw first time */ + t->propsize = 1.0f; /* TRANSFORM_FIX_ME this needs to be saved in scene or something */ /* setting PET flag */ @@ -696,8 +726,16 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event) t->flag |= T_PROP_CONNECTED; // yes i know, has to become define } - t->imval[0] = event->x - t->ar->winrct.xmin; - t->imval[1] = event->y - t->ar->winrct.ymin; + if (event) + { + t->imval[0] = event->x - t->ar->winrct.xmin; + t->imval[1] = event->y - t->ar->winrct.ymin; + } + else + { + t->imval[0] = 0; + t->imval[1] = 0; + } t->con.imval[0] = t->imval[0]; t->con.imval[1] = t->imval[1]; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 343a65abd6c..3272c35f5fa 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -309,6 +309,7 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event) case RIGHTSHIFTKEY: if (event->val) { + t->modifiers |= MOD_PRECISION; /* shift is modifier for higher precision transform * store the mouse position where the normal movement ended */ mi->precision_mval[0] = event->x - t->ar->winrct.xmin; @@ -317,6 +318,7 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event) } else { + t->modifiers &= ~MOD_PRECISION; mi->precision = 0; } redraw = 1; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index c61910aea39..35d1f45bf33 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" #include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" #include "RNA_access.h" #include "RNA_define.h" @@ -43,50 +44,71 @@ static void transformops_exit(bContext *C, wmOperator *op) { + saveTransform(C, op->customdata, op); MEM_freeN(op->customdata); op->customdata = NULL; } static void transformops_data(bContext *C, wmOperator *op, wmEvent *event) { - int mode = RNA_int_get(op->ptr, "mode"); - int options = RNA_int_get(op->ptr, "options"); - TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data"); + if (op->customdata == NULL) + { + TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data"); + + initTransform(C, t, op, event); - initTransform(C, t, mode, options, event); - - /* store data */ - op->customdata = t; + /* store data */ + op->customdata = t; + } } static int transform_modal(bContext *C, wmOperator *op, wmEvent *event) { + int exit_code; + TransInfo *t = op->customdata; transformEvent(t, event); transformApply(t); - if (transformEnd(C, t)) + + exit_code = transformEnd(C, t); + + if (exit_code != OPERATOR_RUNNING_MODAL) { transformops_exit(C, op); - return OPERATOR_FINISHED; - } - else - { - return OPERATOR_RUNNING_MODAL; } + + return exit_code; } -static int transform_exec(bContext *C, wmOperator *op) +static int transform_cancel(bContext *C, wmOperator *op) { TransInfo *t = op->customdata; + t->state = TRANS_CANCEL; + transformEnd(C, t); + transformops_exit(C, op); + + return OPERATOR_FINISHED; +} + +static int transform_exec(bContext *C, wmOperator *op) +{ + TransInfo *t; + + transformops_data(C, op, NULL); + + t = op->customdata; + + t->options |= CTX_AUTOCONFIRM; + transformApply(t); transformEnd(C, t); - ED_region_tag_redraw(CTX_wm_region(C)); + //ED_region_tag_redraw(CTX_wm_region(C)); transformops_exit(C, op); @@ -95,18 +117,13 @@ static int transform_exec(bContext *C, wmOperator *op) static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event) { - float value[4]; + float values[4]; - RNA_float_get_array(op->ptr, "value", value); + RNA_float_get_array(op->ptr, "values", values); - /* makes op->customdata */ transformops_data(C, op, event); - if(!QuatIsNul(value)) { - TransInfo *t = op->customdata; - - VECCOPY(t->values, value); /* SHOULD BE VEC-4 */ - + if(!QuatIsNul(values)) { return transform_exec(C, op); } else { @@ -125,17 +142,19 @@ void TFM_OT_transform(struct wmOperatorType *ot) /* identifiers */ ot->name = "Transform"; ot->idname = "TFM_OT_transform"; + ot->flag= OPTYPE_REGISTER; /* 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_property(ot->srna, "mode", PROP_INT, PROP_NONE); RNA_def_property(ot->srna, "options", PROP_INT, PROP_NONE); - prop = RNA_def_property(ot->srna, "value", PROP_FLOAT, PROP_VECTOR); + prop = RNA_def_property(ot->srna, "values", PROP_FLOAT, PROP_VECTOR); RNA_def_property_array(prop, 4); RNA_def_property_float_array_default(prop, value); } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 7755eba2746..875b45297bf 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -123,7 +123,7 @@ int BIF_snappingSupported(Object *obedit) void drawSnapping(TransInfo *t) { if ((t->tsnap.status & (SNAP_ON|POINT_INIT|TARGET_INIT)) == (SNAP_ON|POINT_INIT|TARGET_INIT) && - (t->event->ctrl)) + (t->modifiers & MOD_SNAP_GEARS)) { char col[4] = {1, 0, 1}; @@ -223,7 +223,7 @@ int handleSnapping(TransInfo *t, wmEvent *event) void applySnapping(TransInfo *t, float *vec) { if ((t->tsnap.status & SNAP_ON) && - (t->event->ctrl)) + (t->modifiers & MOD_SNAP_GEARS)) { double current = PIL_check_seconds_timer(); @@ -1281,13 +1281,13 @@ void snapGrid(TransInfo *t, float *val) { invert = U.flag & USER_AUTOGRABGRID; if(invert) { - action = (t->event->ctrl) ? NO_GEARS: BIG_GEARS; + action = (t->modifiers & MOD_SNAP_GEARS) ? NO_GEARS: BIG_GEARS; } else { - action = (t->event->ctrl) ? BIG_GEARS : NO_GEARS; + action = (t->modifiers & MOD_SNAP_GEARS) ? BIG_GEARS : NO_GEARS; } - if (action == BIG_GEARS && (t->event->shift)) { + if (action == BIG_GEARS && (t->modifiers & MOD_PRECISION)) { action = SMALL_GEARS; } |