Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r--source/blender/editors/transform/transform.c110
1 files changed, 32 insertions, 78 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 55af5677a17..e0abe2606e7 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -7201,55 +7201,15 @@ static short getAnimEdit_SnapMode(TransInfo *t)
return autosnap;
}
-/* This function is used for testing if an Animation Editor is displaying
- * its data in frames or seconds (and the data needing to be edited as such).
- * Returns 1 if in seconds, 0 if in frames
- */
-static bool getAnimEdit_DrawTime(TransInfo *t)
-{
- bool drawtime;
-
- if (t->spacetype == SPACE_ACTION) {
- SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
-
- drawtime = (saction->flag & SACTION_DRAWTIME) != 0;
- }
- else if (t->spacetype == SPACE_NLA) {
- SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
-
- drawtime = (snla->flag & SNLA_DRAWTIME) != 0;
- }
- else if (t->spacetype == SPACE_IPO) {
- SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first;
-
- drawtime = (sipo->flag & SIPO_DRAWTIME) != 0;
- }
- else {
- drawtime = false;
- }
-
- return drawtime;
-}
-
-
/* 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, TransData2D *td2d, AnimData *adt, short autosnap)
{
- /* snap key to nearest frame? */
- if (autosnap == SACTSNAP_FRAME) {
-
-#if 0 /* 'do_time' disabled for now */
-
+ /* snap key to nearest frame or second? */
+ if (ELEM(autosnap, SACTSNAP_FRAME, SACTSNAP_SECOND)) {
const Scene *scene = t->scene;
-#if 0 /* NOTE: this works, but may be confusing behavior given the option's label, hence disabled */
- const bool do_time = getAnimEdit_DrawTime(t);
-#else
- const bool do_time = false;
-#endif
const double secf = FPS;
-#endif
double val;
/* convert frame to nla-action time (if needed) */
@@ -7258,16 +7218,12 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
else
val = *(td->val);
-#if 0 /* 'do_time' disabled for now */
-
/* do the snapping to nearest frame/second */
- if (do_time) {
- val = (float)(floor((val / secf) + 0.5f) * secf);
+ if (autosnap == SACTSNAP_FRAME) {
+ val = floorf(val + 0.5);
}
- else
-#endif
- {
- val = floor(val + 0.5);
+ else if (autosnap == SACTSNAP_SECOND) {
+ val = (float)(floor((val / secf) + 0.5f) * secf);
}
/* convert frame out of nla-action time */
@@ -7355,20 +7311,21 @@ static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN])
else {
const Scene *scene = t->scene;
const short autosnap = getAnimEdit_SnapMode(t);
- const bool do_time = getAnimEdit_DrawTime(t);
const double secf = FPS;
float val = t->values[0];
/* apply snapping + frame->seconds conversions */
if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- val = floorf((double)val / secf + 0.5);
- else
- val = floorf(val + 0.5f);
+ /* frame step */
+ val = floorf(val + 0.5f);
+ }
+ else if (autosnap == SACTSNAP_TSTEP) {
+ /* second step */
+ val = floorf((double)val / secf + 0.5);
}
else {
- if (do_time)
- val = (float)((double)val / secf);
+ /* nearest frame/second/marker */
+ val = (float)((double)val / secf);
}
if (autosnap == SACTSNAP_FRAME)
@@ -7386,11 +7343,9 @@ static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
TransData2D *td2d = t->data2d;
Scene *scene = t->scene;
int i;
-
- const bool do_time = getAnimEdit_DrawTime(t);
- const double secf = FPS;
-
+
const short autosnap = getAnimEdit_SnapMode(t);
+ const double secf = FPS;
float deltax, val /* , valprev */;
@@ -7405,14 +7360,14 @@ static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
/* valprev = *td->val; */ /* UNUSED */
/* check if any need to apply nla-mapping */
- if (adt && t->spacetype != SPACE_SEQ) {
+ if (adt && (t->spacetype != SPACE_SEQ)) {
deltax = t->values[0];
- if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
- else
- deltax = (float)(floor(deltax + 0.5f));
+ if (autosnap == SACTSNAP_TSTEP) {
+ deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ deltax = (float)(floor(deltax + 0.5f));
}
val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP);
@@ -7422,11 +7377,11 @@ static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
else {
deltax = val = t->values[0];
- if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- val = (float)(floor(((double)deltax / secf) + 0.5) * secf);
- else
- val = (float)(floor(val + 0.5f));
+ if (autosnap == SACTSNAP_TSTEP) {
+ val = (float)(floor(((double)deltax / secf) + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ val = (float)(floor(val + 0.5f));
}
*(td->val) = td->ival + val;
@@ -7674,7 +7629,6 @@ static void applyTimeScaleValue(TransInfo *t)
int i;
const short autosnap = getAnimEdit_SnapMode(t);
- const bool do_time = getAnimEdit_DrawTime(t);
const double secf = FPS;
@@ -7687,11 +7641,11 @@ static void applyTimeScaleValue(TransInfo *t)
float startx = CFRA;
float fac = t->values[0];
- if (autosnap == SACTSNAP_STEP) {
- if (do_time)
- fac = (float)(floor((double)fac / secf + 0.5) * secf);
- else
- fac = (float)(floor(fac + 0.5f));
+ if (autosnap == SACTSNAP_TSTEP) {
+ fac = (float)(floor((double)fac / secf + 0.5) * secf);
+ }
+ else if (autosnap == SACTSNAP_STEP) {
+ fac = (float)(floor(fac + 0.5f));
}
/* check if any need to apply nla-mapping */