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:
-rw-r--r--source/blender/editors/animation/anim_draw.c18
-rw-r--r--source/blender/editors/animation/anim_markers.c127
-rw-r--r--source/blender/editors/space_clip/clip_utils.c20
-rw-r--r--source/blender/editors/space_graph/graph_draw.c104
4 files changed, 160 insertions, 109 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index f448a281cfc..caa4a6e31f3 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -71,10 +71,15 @@
/* Draw current frame number in a little green box beside the current frame indicator */
static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const bool time)
{
+ const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+ VertexFormat *format = immVertexFormat();
+ unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+ unsigned char col[4];
+ float xscale, x, y;
char numstr[32] = " t"; /* t is the character to start replacing from */
+ int slen;
/* because the frame number text is subject to the same scaling as the contents of the view */
- float xscale;
UI_view2d_scale_get(v2d, &xscale, NULL);
gpuPushMatrix();
gpuScale2f(1.0f / xscale, 1.0f);
@@ -91,15 +96,11 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
BLI_timecode_string_from_time_seconds(&numstr[4], sizeof(numstr) - 4, 1, cfra);
}
- const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
- int slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
+ slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
/* get starting coordinates for drawing */
- float x = cfra * xscale;
- float y = 0.9f * U.widget_unit;
-
- VertexFormat *format = immVertexFormat();
- unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+ x = cfra * xscale;
+ y = 0.9f * U.widget_unit;
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -110,7 +111,6 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
immUnbindProgram();
/* draw current frame number */
- unsigned char col[4];
UI_GetThemeColor4ubv(TH_TEXT, col);
UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr, col);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 9b8dd47e4aa..9d7d1535eb3 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -131,7 +131,8 @@ ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
*/
int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, float value, char side)
{
- const float cfra = (float)CFRA;
+ TimeMarker *marker;
+ float cfra = (float)CFRA;
int changed_tot = 0;
/* sanity check */
@@ -139,7 +140,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f
return changed_tot;
/* affect selected markers - it's unlikely that we will want to affect all in this way? */
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
switch (mode) {
case TFM_TIME_TRANSLATE:
@@ -234,12 +235,13 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
/* Adds a marker to list of cfra elems */
static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel)
{
+ CfraElem *ce, *cen;
+
/* should this one only be considered if it is selected? */
if ((only_sel) && ((marker->flag & SELECT) == 0))
return;
/* insertion sort - try to find a previous cfra elem */
- CfraElem *ce;
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
@@ -252,7 +254,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
}
}
- CfraElem *cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
+ cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
if (ce) BLI_insertlinkbefore(lb, ce, cen);
else BLI_addtail(lb, cen);
@@ -266,6 +268,8 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
*/
void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
{
+ TimeMarker *marker;
+
if (lb) {
/* Clear the list first, since callers have no way of knowing
* whether this terminated early otherwise. This may lead
@@ -281,7 +285,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
return;
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next)
add_marker_to_cfra_elem(lb, marker, only_sel);
}
@@ -290,8 +294,10 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
/* Get the first selected marker */
TimeMarker *ED_markers_get_first_selected(ListBase *markers)
{
+ TimeMarker *marker;
+
if (markers) {
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT)
return marker;
}
@@ -307,6 +313,8 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
*/
void debug_markers_print_list(ListBase *markers)
{
+ TimeMarker *marker;
+
if (markers == NULL) {
printf("No markers list to print debug for\n");
return;
@@ -314,7 +322,7 @@ void debug_markers_print_list(ListBase *markers)
printf("List of markers follows: -----\n");
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
printf("\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag);
}
@@ -383,7 +391,7 @@ static void draw_marker(
float x, y;
/* minimal y coordinate which wouldn't be occluded by scroll */
- const int min_y = 17.0f * UI_DPI_FAC;
+ int min_y = 17.0f * UI_DPI_FAC;
if (marker->flag & SELECT) {
UI_GetThemeColor4ubv(TH_TEXT_HI, text_col);
@@ -419,14 +427,22 @@ void ED_markers_draw(const bContext *C, int flag)
{
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
ListBase *markers = ED_context_get_markers(C);
+ View2D *v2d;
TimeMarker *marker;
+ Scene *scene;
+ int select_pass;
+ int v2d_clip_range_x[2];
+ float font_width_max;
+
+ /* cache values */
+ float ypixels, xscale, yscale;
if (markers == NULL || BLI_listbase_is_empty(markers)) {
return;
}
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
+ scene = CTX_data_scene(C);
+ v2d = UI_view2d_fromcontext(C);
if (flag & DRAW_MARKERS_MARGIN) {
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
@@ -446,21 +462,18 @@ void ED_markers_draw(const bContext *C, int flag)
}
/* no time correction for framelen! space is drawn with old values */
- float ypixels = BLI_rcti_size_y(&v2d->mask);
- float xscale, yscale;
+ ypixels = BLI_rcti_size_y(&v2d->mask);
UI_view2d_scale_get(v2d, &xscale, &yscale);
gpuPushMatrix();
gpuScale2f(1.0f / xscale, 1.0f);
/* x-bounds with offset for text (adjust for long string, avoid checking string width) */
- float font_width_max = (10 * UI_DPI_FAC) / xscale;
- int v2d_clip_range_x[2] = {
- v2d->cur.xmin - (sizeof(marker->name) * font_width_max),
- v2d->cur.xmax + font_width_max
- };
+ font_width_max = (10 * UI_DPI_FAC) / xscale;
+ v2d_clip_range_x[0] = v2d->cur.xmin - (sizeof(marker->name) * font_width_max);
+ v2d_clip_range_x[1] = v2d->cur.xmax + font_width_max;
/* loop [unselected, selected] */
- for (int select_pass = 0; select_pass <= SELECT; select_pass += SELECT) {
+ for (select_pass = 0; select_pass <= SELECT; select_pass += SELECT) {
/* unselected markers are drawn at the first time */
for (marker = markers->first; marker; marker = marker->next) {
if ((marker->flag & SELECT) == select_pass) {
@@ -821,9 +834,9 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op)
#endif
MarkerMove *mm = op->customdata;
TimeMarker *marker;
-
- const int offs = RNA_int_get(op->ptr, "frames");
- int a;
+ int a, offs;
+
+ offs = RNA_int_get(op->ptr, "frames");
for (a = 0, marker = mm->markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
marker->frame = mm->oldframe[a] + offs;
@@ -994,20 +1007,21 @@ static void MARKER_OT_move(wmOperatorType *ot)
static void ed_marker_duplicate_apply(bContext *C)
{
ListBase *markers = ED_context_get_markers(C);
-
- if (markers == NULL)
+ TimeMarker *marker, *newmarker;
+
+ if (markers == NULL)
return;
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the beginning of the list (unselect original markers)
*/
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
/* unselect selected marker */
marker->flag &= ~SELECT;
/* create and set up new marker */
- TimeMarker *newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
+ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
newmarker->flag = SELECT;
newmarker->frame = marker->frame;
BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name));
@@ -1103,20 +1117,25 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
ListBase *markers = ED_context_get_markers(C);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
+ float viewx;
+ int x, cfra;
if (markers == NULL)
return OPERATOR_PASS_THROUGH;
- const int x = event->x - ar->winrct.xmin;
- const float viewx = UI_view2d_region_to_view_x(v2d, x);
- const int cfra = ED_markers_find_nearest_marker_time(markers, viewx);
-
+ x = event->x - ar->winrct.xmin;
+
+ viewx = UI_view2d_region_to_view_x(v2d, x);
+
+ cfra = ED_markers_find_nearest_marker_time(markers, viewx);
+
select_timeline_marker_frame(markers, cfra, extend);
#ifdef DURIAN_CAMERA_SWITCH
if (camera) {
Scene *scene = CTX_data_scene(C);
+ BaseLegacy *base;
TimeMarker *marker;
int sel = 0;
@@ -1133,7 +1152,7 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
for (marker = markers->first; marker; marker = marker->next) {
if (marker->camera) {
if (marker->frame == cfra) {
- BaseLegacy *base = BKE_scene_base_find(scene, marker->camera);
+ base = BKE_scene_base_find(scene, marker->camera);
if (base) {
ED_base_object_select(base, sel);
if (sel)
@@ -1173,6 +1192,8 @@ static int ed_marker_select_invoke_wrapper(bContext *C, wmOperator *op, const wm
static void MARKER_OT_select(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Select Time Marker";
ot->description = "Select time marker(s)";
@@ -1185,7 +1206,7 @@ static void MARKER_OT_select(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- PropertyRNA *prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
#ifdef DURIAN_CAMERA_SWITCH
prop = RNA_def_boolean(ot->srna, "camera", 0, "Camera", "Select the camera");
@@ -1216,11 +1237,9 @@ static void MARKER_OT_select(wmOperatorType *ot)
static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
{
- ListBase *markers = ED_context_get_markers(C);
- if (markers == NULL)
- return 0;
-
View2D *v2d = UI_view2d_fromcontext(C);
+ ListBase *markers = ED_context_get_markers(C);
+ TimeMarker *marker;
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
bool extend = RNA_boolean_get(op->ptr, "extend");
rctf rect;
@@ -1228,8 +1247,11 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
+ if (markers == NULL)
+ return 0;
+
/* XXX marker context */
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (BLI_rctf_isect_x(&rect, marker->frame)) {
switch (gesture_mode) {
case GESTURE_MODAL_SELECT:
@@ -1283,17 +1305,17 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
{
ListBase *markers = ED_context_get_markers(C);
+ TimeMarker *marker;
+ int action = RNA_enum_get(op->ptr, "action");
if (markers == NULL)
return OPERATOR_CANCELLED;
- int action = RNA_enum_get(op->ptr, "action");
-
if (action == SEL_TOGGLE) {
action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT;
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
switch (action) {
case SEL_SELECT:
marker->flag |= SELECT;
@@ -1338,13 +1360,13 @@ static void MARKER_OT_select_all(wmOperatorType *ot)
static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
ListBase *markers = ED_context_get_markers(C);
+ TimeMarker *marker, *nmarker;
+ bool changed = false;
if (markers == NULL)
return OPERATOR_CANCELLED;
- bool changed = false;
- TimeMarker *nmarker;
- for (TimeMarker *marker = markers->first; marker; marker = nmarker) {
+ for (marker = markers->first; marker; marker = nmarker) {
nmarker = marker->next;
if (marker->flag & SELECT) {
BLI_freelinkN(markers, marker);
@@ -1440,6 +1462,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
{
ListBase *markers = ED_context_get_markers(C);
Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
+ TimeMarker *marker, *marker_new;
if (scene_to == NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene not found");
@@ -1457,9 +1480,9 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
}
/* copy markers */
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ for (marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
- TimeMarker *marker_new = MEM_dupallocN(marker);
+ marker_new = MEM_dupallocN(marker);
marker_new->prev = marker_new->next = NULL;
BLI_addtail(&scene_to->markers, marker_new);
@@ -1476,6 +1499,8 @@ static int ed_marker_make_links_scene_invoke_wrapper(bContext *C, wmOperator *op
static void MARKER_OT_make_links_scene(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Make Links to Scene";
ot->description = "Copy selected markers to another scene";
@@ -1490,10 +1515,11 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- PropertyRNA *prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
+ prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_itemf);
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
+
}
#ifdef DURIAN_CAMERA_SWITCH
@@ -1501,14 +1527,15 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op))
{
- ListBase *markers = ED_context_get_markers(C);
- TimeMarker *marker = ED_markers_get_first_selected(markers);
- if (marker == NULL)
- return OPERATOR_CANCELLED;
-
bScreen *sc = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
+ ListBase *markers = ED_context_get_markers(C);
+ TimeMarker *marker;
+
+ marker = ED_markers_get_first_selected(markers);
+ if (marker == NULL)
+ return OPERATOR_CANCELLED;
marker->camera = ob;
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 23a919cf603..cdda8865588 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -66,17 +66,18 @@ void clip_graph_tracking_values_iterate_track(
void (*segment_end)(void *userdata, int coord))
{
MovieClip *clip = ED_space_clip_get_clip(sc);
- int width, height;
+ int width, height, coord;
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
- for (int coord = 0; coord < 2; coord++) {
- int prevfra = 0;
+ for (coord = 0; coord < 2; coord++) {
+ int i, prevfra = 0;
bool open = false;
float prevval = 0.0f;
- for (int i = 0; i < track->markersnr; i++) {
+ for (i = 0; i < track->markersnr; i++) {
MovieTrackingMarker *marker = &track->markers[i];
+ float val;
if (marker->flag & MARKER_DISABLED) {
if (open) {
@@ -104,7 +105,7 @@ void clip_graph_tracking_values_iterate_track(
}
/* value is a pixels per frame speed */
- float val = (marker->pos[coord] - prevval) * ((coord == 0) ? (width) : (height));
+ val = (marker->pos[coord] - prevval) * ((coord == 0) ? (width) : (height));
val /= marker->framenr - prevfra;
if (func) {
@@ -134,8 +135,9 @@ void clip_graph_tracking_values_iterate(
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *track;
- for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) {
+ for (track = tracksbase->first; track; track = track->next) {
if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
continue;
@@ -152,8 +154,10 @@ void clip_graph_tracking_iterate(SpaceClip *sc, bool selected_only, bool include
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
+ MovieTrackingTrack *track;
- for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) {
+ for (track = tracksbase->first; track; track = track->next) {
+ int i;
if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
continue;
@@ -161,7 +165,7 @@ void clip_graph_tracking_iterate(SpaceClip *sc, bool selected_only, bool include
if (selected_only && !TRACK_SELECTED(track))
continue;
- for (int i = 0; i < track->markersnr; i++) {
+ for (i = 0; i < track->markersnr; i++) {
MovieTrackingMarker *marker = &track->markers[i];
if (marker->flag & MARKER_DISABLED)
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index d9104007586..e382c2dbd29 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -462,21 +462,28 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
/* helper func - just draw the F-Curve by sampling the visible region (for drawing curves with modifiers) */
static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid, unsigned int pos)
{
+ SpaceIpo *sipo = (SpaceIpo *)ac->sl;
+ ChannelDriver *driver;
+ float samplefreq;
+ float stime, etime;
+ float unitFac, offset;
+ float dx, dy;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
+ int i, n;
+
/* when opening a blend file on a different sized screen or while dragging the toolbar this can happen
* best just bail out in this case */
- float dx, dy;
UI_view2d_grid_size(grid, &dx, &dy);
if (dx <= 0.0f)
return;
+
/* disable any drivers temporarily */
- ChannelDriver *driver = fcu->driver;
+ driver = fcu->driver;
fcu->driver = NULL;
/* compute unit correction factor */
- float offset;
- const short mapping_flag = ANIM_get_normalization_flags(ac);
- const float unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
+ unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
/* Note about sampling frequency:
* Ideally, this is chosen such that we have 1-2 pixels = 1 segment
@@ -492,9 +499,8 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
*/
/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
/* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */
- float samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
+ samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
- SpaceIpo *sipo = (SpaceIpo *)ac->sl;
if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
/* Low Precision = coarse lower-bound clamping
*
@@ -516,8 +522,8 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
/* the start/end times are simply the horizontal extents of the 'cur' rect */
- const float stime = v2d->cur.xmin;
- const float etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */
+ stime = v2d->cur.xmin;
+ etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */
/* at each sampling interval, add a new vertex
@@ -525,12 +531,12 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d
* the displayed values appear correctly in the viewport
*/
- const int n = (etime - stime) / samplefreq + 0.5f;
+ n = (etime - stime) / samplefreq + 0.5f;
if (n > 0) {
immBegin(PRIM_LINE_STRIP, (n + 1));
- for (int i = 0; i <= n; i++) {
+ for (i = 0; i <= n; i++) {
float ctime = stime + i * samplefreq;
immVertex2f(pos, ctime, (evaluate_fcurve(fcu, ctime) + offset) * unitFac);
}
@@ -548,22 +554,22 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie
FPoint *prevfpt = fcu->fpt;
FPoint *fpt = prevfpt + 1;
float fac, v[2];
+ int b = fcu->totvert;
+ float unit_scale, offset;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
int count = fcu->totvert;
if (prevfpt->vec[0] > v2d->cur.xmin) {
count++;
}
- int b = fcu->totvert;
if ((prevfpt + b - 1)->vec[0] < v2d->cur.xmax) {
count++;
}
/* apply unit mapping */
- float offset;
- const short mapping_flag = ANIM_get_normalization_flags(ac);
- const float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
gpuPushMatrix();
+ unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
gpuScale2f(1.0f, unit_scale);
gpuTranslate2f(0.0f, offset);
@@ -648,20 +654,22 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
BezTriple *prevbezt = fcu->bezt;
BezTriple *bezt = prevbezt + 1;
float v1[2], v2[2], v3[2], v4[2];
+ float *fp, data[120];
float fac = 0.0f;
+ int b = fcu->totvert - 1;
+ int resol;
+ float unit_scale, offset;
+ short mapping_flag = ANIM_get_normalization_flags(ac);
/* apply unit mapping */
- float offset;
- const short mapping_flag = ANIM_get_normalization_flags(ac);
- const float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
gpuPushMatrix();
+ unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
gpuScale2f(1.0f, unit_scale);
gpuTranslate2f(0.0f, offset);
/* For now, this assumes the worst case scenario, where all the keyframes have
* bezier interpolation, and are drawn at full res.
* This is tricky to optimize, but maybe can be improved at some point... */
- int b = fcu->totvert - 1;
immBeginAtMost(PRIM_LINE_STRIP, (b * 32 + 3));
/* extrapolate to left? */
@@ -717,8 +725,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
immVertex2fv(pos, v1);
}
else if (prevbezt->ipo == BEZT_IPO_BEZ) {
- /* Bezier-Interpolation: draw curve as series of segments between keyframes */
- int resol; /* determines number of points to sample in between keyframes */
+ /* Bezier-Interpolation: draw curve as series of segments between keyframes
+ * - resol determines number of points to sample in between keyframes
+ */
+
/* resol depends on distance between points (not just horizontal) OR is a fixed high res */
/* TODO: view scale should factor into this someday too... */
if (fcu->driver) {
@@ -750,13 +760,11 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2
v4[1] = bezt->vec[1][1];
correct_bezpart(v1, v2, v3, v4);
-
- float data[120];
-
+
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
- for (const float *fp = data; resol; resol--, fp += 3) {
+ for (fp = data; resol; resol--, fp += 3) {
immVertex2fv(pos, fp);
}
}
@@ -816,9 +824,9 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
{
ChannelDriver *driver = fcu->driver;
View2D *v2d = &ac->ar->v2d;
- const short mapping_flag = ANIM_get_normalization_flags(ac);
+ short mapping_flag = ANIM_get_normalization_flags(ac);
float offset;
- const float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
+ float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset);
/* for now, only show when debugging driver... */
//if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
@@ -831,6 +839,8 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
* => We still want to show the 1-1 default...
*/
if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) {
+ float t;
+
/* draw with thin dotted lines in style of what curve would have been */
immUniformColor3fv(fcu->color);
@@ -842,7 +852,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
*/
immBegin(PRIM_LINES, 2);
- float t = v2d->cur.xmin;
+ t = v2d->cur.xmin;
immVertex2f(pos, t, (t + offset) * unitfac);
t = v2d->cur.xmax;
@@ -923,6 +933,8 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
*/
void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
{
+ FCurve *fcu;
+
/* draw with thick dotted lines */
setlinestyle(10);
glLineWidth(3.0f);
@@ -935,7 +947,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */
- for (FCurve *fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) {
+ for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) {
/* set whatever color the curve has set
* - this is set by the function which creates these
* - draw with a fixed opacity of 2
@@ -960,16 +972,20 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
*/
void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid *grid, short sel)
{
- /* build list of curves to draw */
ListBase anim_data = {NULL, NULL};
- const int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | (sel ? ANIMFILTER_SEL : ANIMFILTER_UNSEL);
+ bAnimListElem *ale;
+ int filter;
+
+ /* build list of curves to draw */
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
+ filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
+
/* for each curve:
* draw curve, then handle-lines, and finally vertices in this order so that
* the data will be layered correctly
*/
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
FModifier *fcm = find_active_fmodifier(&fcu->modifiers);
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
@@ -1122,12 +1138,18 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
/* left hand part */
void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
View2D *v2d = &ar->v2d;
-
+ float y = 0.0f, height;
+ size_t items;
+ int i = 0;
+
/* build list of channels to draw */
- ListBase anim_data = {NULL, NULL};
- const int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS;
- const size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
+ items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* Update max-extent of channels here (taking into account scrollers):
* - this is done to allow the channel list to be scrollable, but must be done here
@@ -1135,16 +1157,14 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
* - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
* start of list offset, and the second is as a correction for the scrollers.
*/
- const float height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2));
+ height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2));
UI_view2d_totRect_set(v2d, BLI_rcti_size_x(&ar->v2d.mask), height);
/* loop through channels, and set up drawing depending on their type */
- bAnimListElem *ale;
- int i;
{ /* first pass: just the standard GL-drawing for backdrop + text */
size_t channel_index = 0;
- float y = (float)ACHANNEL_FIRST(ac);
+ y = (float)ACHANNEL_FIRST(ac);
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
@@ -1167,7 +1187,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
size_t channel_index = 0;
- float y = (float)ACHANNEL_FIRST(ac);
+ y = (float)ACHANNEL_FIRST(ac);
/* set blending again, as may not be set in previous step */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);