diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-01-19 23:30:04 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-01-19 23:30:04 +0300 |
commit | a8a5defc0caac44b1fa6fcd330ca8fb262b55547 (patch) | |
tree | 82a0fbf31a068ccffcc9d3ec1e36d5ac087b9e60 | |
parent | 21004122847fb2570fd61de6677d2b0c8f96444a (diff) |
Preview Range Tweak:
Made preview range be turned on/off using a proper flag instead of just relying on checking for start-frame = 0. It is no longer satisfactory to do that since we can have negative frame numbers, and also having it as a proper flag means that the range can be toggled on/off non-destructively.
-rw-r--r-- | source/blender/editors/animation/anim_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_graph/space_graph.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_time/time_ops.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 34 |
10 files changed, 33 insertions, 30 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index f8a5a9daa06..6b1933a791f 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -215,7 +215,7 @@ void ANIM_draw_previewrange (const bContext *C, View2D *v2d) Scene *scene= CTX_data_scene(C); /* only draw this if preview range is set */ - if (scene->r.psfra) { + if (PRVRANGEON) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0.0f, 0.0f, 0.0f, 0.4f); diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 9544bb70855..82a2b615681 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -205,6 +205,7 @@ static int previewrange_define_exec(bContext *C, wmOperator *op) if (efra < 1) efra = 1.0f; if (efra < sfra) efra= sfra; + scene->r.flag |= SCER_PRV_RANGE; scene->r.psfra= (int)floor(sfra + 0.5f); scene->r.pefra= (int)floor(efra + 0.5f); @@ -251,6 +252,7 @@ static int previewrange_clear_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* simply clear values */ + scene->r.flag &= ~SCER_PRV_RANGE; scene->r.psfra= 0; scene->r.pefra= 0; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f1e0f9c6bf1..87b61d2df27 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2429,7 +2429,7 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) if (sad->flag & ANIMPLAY_FLAG_REVERSE) { /* jump back to end? */ - if (scene->r.psfra) { + if (PRVRANGEON) { if (scene->r.cfra < scene->r.psfra) { scene->r.cfra= scene->r.pefra; sad->flag |= ANIMPLAY_FLAG_JUMPED; @@ -2444,7 +2444,7 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) } else { /* jump back to start? */ - if (scene->r.psfra) { + if (PRVRANGEON) { if (scene->r.cfra > scene->r.pefra) { scene->r.cfra= scene->r.psfra; sad->flag |= ANIMPLAY_FLAG_JUMPED; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index d94d5bec490..1ab4364951d 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -214,6 +214,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *op) /* set the range directly */ get_keyframe_extents(&ac, &min, &max); + scene->r.flag |= SCER_PRV_RANGE; scene->r.psfra= (int)floor(min + 0.5f); scene->r.pefra= (int)floor(max + 0.5f); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index db63499d645..9fda92a5852 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -174,6 +174,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *op) /* set the range directly */ get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL); + scene->r.flag |= SCER_PRV_RANGE; scene->r.psfra= (int)floor(min + 0.5f); scene->r.pefra= (int)floor(max + 0.5f); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index cf99e3602dd..bd37eb996ce 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -151,8 +151,8 @@ static SpaceLink *graph_new(const bContext *C) ar->v2d.cur= ar->v2d.tot; - ar->v2d.min[0]= 0.001f; - ar->v2d.min[1]= 0.001f; + ar->v2d.min[0]= 0.00001f; + ar->v2d.min[1]= 0.00001f; ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= 50000.0f; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9e10feb898d..bd9c56bf8a0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1118,7 +1118,7 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in { bNodeSocket *sock; int socktype, maxtype=0; - int a; + int a = 0; for (sock=node->inputs.first; sock; sock=sock->next) { maxtype = MAX2(sock->type, maxtype); diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index b4eb3231b50..e3ea2ea29ea 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -69,7 +69,7 @@ static int time_set_sfra_exec (bContext *C, wmOperator *op) if (PEFRA < frame) frame= PEFRA; /* if Preview Range is defined, set the 'start' frame for that */ - if (scene->r.psfra) + if (PRVRANGEON) scene->r.psfra= frame; else scene->r.sfra= frame; @@ -109,7 +109,7 @@ static int time_set_efra_exec (bContext *C, wmOperator *op) if (PSFRA > frame) frame= PSFRA; /* if Preview Range is defined, set the 'end' frame for that */ - if (scene->r.psfra) /* start frame 0 is used to check if the preview is used at all */ + if (PRVRANGEON) scene->r.pefra= frame; else scene->r.efra= frame; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 85f75684d85..7ea4bb1b022 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -789,6 +789,10 @@ typedef struct Scene { #define R_FRONTBUF 4 #define R_FRONTBUFANIM 8 +/* flag */ + /* use preview range */ +#define SCER_PRV_RANGE (1<<0) + /* mode (int now) */ #define R_OSA 0x0001 #define R_SHADOW 0x0002 @@ -991,8 +995,9 @@ typedef struct Scene { #define F_CFRA ((float)(scene->r.cfra)) #define SFRA (scene->r.sfra) #define EFRA (scene->r.efra) -#define PSFRA ((scene->r.psfra != 0)? (scene->r.psfra): (scene->r.sfra)) -#define PEFRA ((scene->r.psfra != 0)? (scene->r.pefra): (scene->r.efra)) +#define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) +#define PSFRA ((PRVRANGEON)? (scene->r.psfra): (scene->r.sfra)) +#define PEFRA ((PRVRANGEON)? (scene->r.pefra): (scene->r.efra)) #define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (a)) / scene->r.frs_sec) #define TIME2FRA(a) ((((double) scene->r.frs_sec) * (a)) / scene->r.frs_sec_base) #define FPS (((double) scene->r.frs_sec) / scene->r.frs_sec_base) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d68ac2ce14c..f75f6244fa2 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -227,28 +227,21 @@ static void rna_Scene_end_frame_set(PointerRNA *ptr, int value) data->r.efra= value; } -static int rna_Scene_use_preview_range_get(PointerRNA *ptr) -{ - Scene *data= (Scene*)ptr->data; - - /* this is simply overloaded to assume that preview-range - * start frame cannot be less than 1 when on, - * so psfra=0 means 'off' - */ - return (data->r.psfra != 0); -} - static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value) { Scene *data= (Scene*)ptr->data; - /* if enable, copy range from render-range, otherwise just clear */ if (value) { - data->r.psfra= data->r.sfra; - data->r.pefra= data->r.efra; + /* copy range from scene if not set before */ + if ((data->r.psfra == data->r.pefra) && (data->r.psfra == 0)) { + data->r.psfra= data->r.sfra; + data->r.pefra= data->r.efra; + } + + data->r.flag |= SCER_PRV_RANGE; } else - data->r.psfra= 0; + data->r.flag &= ~SCER_PRV_RANGE; } @@ -257,14 +250,14 @@ static void rna_Scene_preview_range_start_frame_set(PointerRNA *ptr, int value) Scene *data= (Scene*)ptr->data; /* check if enabled already */ - if (data->r.psfra == 0) { + if ((data->r.flag & SCER_PRV_RANGE) == 0) { /* set end of preview range to end frame, then clamp as per normal */ // TODO: or just refuse to set instead? data->r.pefra= data->r.efra; } /* now set normally */ - CLAMP(value, 1, data->r.pefra); + CLAMP(value, MINAFRAME, data->r.pefra); data->r.psfra= value; } @@ -273,7 +266,7 @@ static void rna_Scene_preview_range_end_frame_set(PointerRNA *ptr, int value) Scene *data= (Scene*)ptr->data; /* check if enabled already */ - if (data->r.psfra == 0) { + if ((data->r.flag & SCER_PRV_RANGE) == 0) { /* set start of preview range to start frame, then clamp as per normal */ // TODO: or just refuse to set instead? data->r.psfra= data->r.sfra; @@ -2522,9 +2515,10 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); /* Preview Range (frame-range for UI playback) */ - prop=RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE); /* use_preview_range is not really a separate setting in SDNA */ + prop=RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); - RNA_def_property_boolean_funcs(prop, "rna_Scene_use_preview_range_get", "rna_Scene_use_preview_range_set"); + RNA_def_property_boolean_sdna(prop, NULL, "r.flag", SCER_PRV_RANGE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_use_preview_range_set"); RNA_def_property_ui_text(prop, "Use Preview Range", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); |