Commit: 63ec900af9a15443b74458462b55ce563bba721a
Author: Joshua Leung
Date: Sun Nov 16 23:02:31 2014 +1300
Branches: master
https://developer.blender.org/rB63ec900af9a15443b74458462b55ce563bba721a
[T40792] Optimisations for FCurve Drawing - Lower sampling precision when "High
Quality" drawing disabled
When the "High Quality Line Drawing" option (View menu) is disabled,
the sampling rate (i.e. the size of timesteps to use when sampling
the FCurve for drawing it in most cases now) is set to be quite low
(i.e. at 0.1 frame increments). This amounts to at most 10 sub-steps.
In one test file (with a wide window), this had the effect of improving
the performance by over 3x. It's still not as good as a sampling-free
approach, but for this functionality is still needed for FModifiers,
so it's better that we can optimise this.
===================================================================
M source/blender/editors/space_graph/graph_draw.c
===================================================================
diff --git a/source/blender/editors/space_graph/graph_draw.c
b/source/blender/editors/space_graph/graph_draw.c
index 466fe79..5eec5c2 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -475,6 +475,7 @@ 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)
{
+ SpaceIpo *sipo = (SpaceIpo *)ac->sl;
ChannelDriver *driver;
float samplefreq;
float stime, etime;
@@ -512,7 +513,25 @@ 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? */
samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize);
- if (samplefreq < 0.00001f) samplefreq = 0.00001f;
+
+ if (sipo->flag & SIPO_BEAUTYDRAW_OFF) {
+ /* Low Precision = coarse lower-bound clamping
+ *
+ * Although the "Beauty Draw" flag was originally for AA'd
+ * line drawing, the sampling rate here has a much greater
+ * impact on performance (e.g. for T40372)!
+ *
+ * This one still amounts to 10 sample-frames for each 1-frame
interval
+ * which should be quite a decent approximation in many
situations.
+ */
+ if (samplefreq < 0.1f)
+ samplefreq = 0.1f;
+ }
+ else {
+ /* "Higher Precision" but slower - especially on larger windows
(e.g. T40372) */
+ if (samplefreq < 0.00001f)
+ samplefreq = 0.00001f;
+ }
/* the start/end times are simply the horizontal extents of the 'cur'
rect */
@@ -527,7 +546,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id,
FCurve *fcu, View2D *v2d
glBegin(GL_LINE_STRIP);
n = (etime - stime) / samplefreq + 0.5f;
- for (i = 0; i < n; i++) {
+ for (i = 0; i <= n; i++) {
float ctime = stime + i * samplefreq;
glVertex2f(ctime, evaluate_fcurve(fcu, ctime) * unitFac);
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs