diff options
author | David Robillard <d@drobilla.net> | 2013-12-18 07:11:11 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-12-18 07:11:11 +0000 |
commit | b3bc9a7a3688aeac53d75befae2a6552d8bc5846 (patch) | |
tree | 0e8b9f84a0ca73746368c120be721aac56e3c8e9 /src/Canvas.cpp | |
parent | 3472b5ee6e691b1c24e20e1f885f260c5513d171 (diff) | |
download | ganv-b3bc9a7a3688aeac53d75befae2a6552d8bc5846.tar.gz ganv-b3bc9a7a3688aeac53d75befae2a6552d8bc5846.tar.bz2 ganv-b3bc9a7a3688aeac53d75befae2a6552d8bc5846.zip |
FDGL performance improvements.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5179 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Canvas.cpp')
-rw-r--r-- | src/Canvas.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp index bcb4dd1..5d4eb55 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -150,7 +150,7 @@ struct GanvCanvasImpl { #ifdef GANV_FDGL g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, - 100, + 40, on_timeout, this, NULL); @@ -785,7 +785,7 @@ GanvCanvasImpl::layout_iteration() GanvNode* const node = GANV_NODE(*i); static const float dur = 0.1; // Time duration - static const float damp = 0.5; // Velocity damping (momentum loss) + static const float damp = 0.7; // Velocity damping (momentum loss) if (node->impl->grabbed) { node->impl->vel.x = 0.0; @@ -797,7 +797,17 @@ GanvCanvasImpl::layout_iteration() // Update position const Vector dpos = vec_mult(node->impl->vel, dur); - ganv_node_move(node, dpos.x, dpos.y); + if (fabs(dpos.x) > 1.0 || fabs(dpos.y) > 1.0) { + GanvItem* item = GANV_ITEM(node); + ganv_item_move(GANV_ITEM(node), dpos.x, dpos.y); + static const float min_coord = 4.0; + if (item->x < min_coord) { + item->x = min_coord; + } + if (item->y < min_coord) { + item->y = min_coord; + } + } } // Reset forces for next time @@ -805,6 +815,12 @@ GanvCanvasImpl::layout_iteration() node->impl->force.y = 0.0; } + // Now update edge positions to reflect new node positions + FOREACH_EDGE(_edges, i) { + GanvEdge* const edge = *i; + ganv_edge_update_location(edge); + } + return TRUE; } |