diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-03-14 13:45:42 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-03-14 13:45:42 +0300 |
commit | 7609370d504de51371b96d8e6807ec6f62ee6c69 (patch) | |
tree | 70c34d8fd214dd963602ceff0f2f247704fd1295 /source | |
parent | 2d1ef275f2299c71dade74743cdca0c771648333 (diff) |
Bugfixes:
- Sync Markers option works for local markers (or any other list of
markers in future) too now.
- Apply Pose to Restpose operator now displays a warning if an action
was found (warning about the action now being invalid)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 48 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 52 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/poseUtils.c | 4 | ||||
-rw-r--r-- | source/blender/editors/include/ED_markers.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 35 |
7 files changed, 76 insertions, 71 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index aa057e22d20..a1a8b1b28cb 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -78,9 +78,6 @@ int scene_camera_switch_update(struct Scene *scene); char *scene_find_marker_name(struct Scene *scene, int frame); char *scene_find_last_marker_name(struct Scene *scene, int frame); -int scene_marker_tfm_translate(struct Scene *scene, int delta, unsigned int flag); -int scene_marker_tfm_extend(struct Scene *scene, int delta, int flag, int frame, char side); -int scene_marker_tfm_scale(struct Scene *scene, float value, int flag); struct Base *scene_add_base(struct Scene *sce, struct Object *ob); void scene_deselect_all(struct Scene *sce); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6151bd8a735..c4eefb16348 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -832,54 +832,6 @@ char *scene_find_last_marker_name(Scene *scene, int frame) return best_marker ? best_marker->name : NULL; } -/* markers need transforming from different parts of the code so have - * a generic function to do this */ -int scene_marker_tfm_translate(Scene *scene, int delta, unsigned int flag) -{ - TimeMarker *marker; - int tot= 0; - - for (marker= scene->markers.first; marker; marker= marker->next) { - if ((marker->flag & flag) == flag) { - marker->frame += delta; - tot++; - } - } - - return tot; -} - -int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char side) -{ - TimeMarker *marker; - int tot= 0; - - for (marker= scene->markers.first; marker; marker= marker->next) { - if ((marker->flag & flag) == flag) { - if((side=='L' && marker->frame < frame) || (side=='R' && marker->frame >= frame)) { - marker->frame += delta; - tot++; - } - } - } - - return tot; -} - -int scene_marker_tfm_scale(struct Scene *scene, float value, int flag) -{ - TimeMarker *marker; - int tot= 0; - - for (marker= scene->markers.first; marker; marker= marker->next) { - if ((marker->flag & flag) == flag) { - marker->frame= CFRA + (int)floorf(((float)(marker->frame - CFRA) * value) + 0.5f); - tot++; - } - } - - return tot; -} Base *scene_add_base(Scene *sce, Object *ob) { diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index b6450ada96f..c802ba621f1 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -68,6 +68,7 @@ #include "ED_util.h" #include "ED_numinput.h" #include "ED_object.h" +#include "ED_transform.h" #include "ED_types.h" /* ************* Marker API **************** */ @@ -114,6 +115,57 @@ ListBase *ED_animcontext_get_markers(const bAnimContext *ac) /* --------------------------------- */ +/* Apply some transformation to markers after the fact + * < markers: list of markers to affect - this may or may not be the scene markers list, so don't assume anything + * < scene: current scene (for getting current frame) + * < mode: (TfmMode) transform mode that this transform is for + * < value: from the transform code, this is t->vec[0] (which is delta transform for grab/extend, and scale factor for scale) + * < side: (B/L/R) for 'extend' functionality, which side of current frame to use + */ +int ED_markers_post_apply_transform (ListBase *markers, Scene *scene, int mode, float value, char side) +{ + TimeMarker *marker; + float cfra = (float)CFRA; + int changed = 0; + + /* sanity check */ + if (markers == NULL) + return changed; + + /* affect selected markers - it's unlikely that we will want to affect all in this way? */ + for (marker = markers->first; marker; marker = marker->next) { + if (marker->flag & SELECT) { + switch (mode) { + case TFM_TIME_TRANSLATE: + case TFM_TIME_EXTEND: + { + /* apply delta if marker is on the right side of the current frame */ + if ((side=='B') || + (side=='L' && marker->frame < cfra) || + (side=='R' && marker->frame >= cfra)) + { + marker->frame += (int)floorf(value + 0.5f); + changed++; + } + } + break; + + case TFM_TIME_SCALE: + { + /* rescale the distance between the marker and the current frame */ + marker->frame= cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); + changed++; + } + break; + } + } + } + + return changed; +} + +/* --------------------------------- */ + /* Get the marker that is closest to this point */ /* XXX for select, the min_dist should be small */ TimeMarker *ED_markers_find_nearest_marker (ListBase *markers, float x) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 8d555e17d8f..1709d8cb085 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -638,6 +638,8 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) /* helpful warnings... */ // TODO: add warnings to be careful about actions, applying deforms first, etc. + if (ob->adt && ob->adt->action) + BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose"); /* Get editbones of active armature to alter */ ED_armature_to_edit(ob); diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 693dfe02aed..16e84db0ba7 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -211,7 +211,7 @@ void poseAnim_mapping_reset (ListBase *pfLinks) } /* perform autokeyframing after changes were made + confirmed */ -void poseAnim_mapping_autoKeyframe (bContext *C, Scene *scene, Object *ob, ListBase *pfLinks, float UNUSED(cframe)) +void poseAnim_mapping_autoKeyframe (bContext *C, Scene *scene, Object *ob, ListBase *pfLinks, float cframe) { /* insert keyframes as necessary if autokeyframing */ if (autokeyframe_cfra_can_key(scene, &ob->id)) { @@ -235,7 +235,7 @@ void poseAnim_mapping_autoKeyframe (bContext *C, Scene *scene, Object *ob, ListB } /* insert keyframes for all relevant bones in one go */ - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); + ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cframe); BLI_freelistN(&dsources); } } diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h index 728d9253760..f804e052301 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -36,6 +36,7 @@ struct wmKeyConfig; struct bContext; struct bAnimContext; +struct Scene; struct TimeMarker; /* Drawing API ------------------------------ */ @@ -53,6 +54,8 @@ void draw_markers_time(const struct bContext *C, int flag); ListBase *ED_context_get_markers(const struct bContext *C); ListBase *ED_animcontext_get_markers(const struct bAnimContext *ac); +int ED_markers_post_apply_transform(ListBase *markers, struct Scene *scene, int mode, float value, char side); + struct TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x); int ED_markers_find_nearest_marker_time(ListBase *markers, float x); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 12dbf7f5c71..05bf96461a8 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4707,10 +4707,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if(t->mode == TFM_SEQ_SLIDE) { if(t->frame_side == 'B') - scene_marker_tfm_translate(t->scene, floor(t->values[0] + 0.5f), SELECT); + ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->vec[0], t->frame_side); } else if (ELEM(t->frame_side, 'L', 'R')) { - scene_marker_tfm_extend(t->scene, floor(t->vec[0] + 0.5f), SELECT, t->scene->r.cfra, t->frame_side); + ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_EXTEND, t->vec[0], t->frame_side); } } @@ -4783,22 +4783,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_action_clean(&ac, (bAction *)ac.data); } } - - /* marker transform, not especially nice but we may want to move markers - * at the same time as keyframes in the dope sheet. */ - // FIXME: this only does scene markers, but fails when action editor is displaying local markers only... - if ((saction->flag & SACTION_MARKERS_MOVE) && (cancelled == 0)) { - if (t->mode == TFM_TIME_TRANSLATE) { - if (ELEM(t->frame_side, 'L', 'R')) /* TFM_TIME_EXTEND */ - scene_marker_tfm_extend(t->scene, floor(t->vec[0] + 0.5f), SELECT, t->scene->r.cfra, t->frame_side); - else /* TFM_TIME_TRANSLATE */ - scene_marker_tfm_translate(t->scene, floor(t->vec[0] + 0.5f), SELECT); - } - else if (t->mode == TFM_TIME_SCALE) { - scene_marker_tfm_scale(t->scene, t->vec[0], SELECT); - } - } - else if (ac.datatype == ANIMCONT_GPENCIL) { /* remove duplicate frames and also make sure points are in order! */ /* 3 cases here for curve cleanups: @@ -4820,6 +4804,21 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } + /* marker transform, not especially nice but we may want to move markers + * at the same time as keyframes in the dope sheet. + */ + if ((saction->flag & SACTION_MARKERS_MOVE) && (cancelled == 0)) { + if (t->mode == TFM_TIME_TRANSLATE) { + if (ELEM(t->frame_side, 'L', 'R')) /* TFM_TIME_EXTEND */ + ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side); + else /* TFM_TIME_TRANSLATE */ + ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side); + } + else if (t->mode == TFM_TIME_SCALE) { + ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side); + } + } + /* make sure all F-Curves are set correctly */ ANIM_editkeyframes_refresh(&ac); |