From b3bc9a7a3688aeac53d75befae2a6552d8bc5846 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 18 Dec 2013 07:11:11 +0000 Subject: FDGL performance improvements. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5179 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/Canvas.cpp') 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; } -- cgit v1.2.1