diff options
author | David Robillard <d@drobilla.net> | 2014-04-27 15:56:26 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-04-27 15:56:26 +0000 |
commit | 177ef9fea33e2f8904cd6d06ec4404bfb60ed7f5 (patch) | |
tree | d59c9426736663778c6909eb1987c048ffea9ba1 /src/Canvas.cpp | |
parent | 3ea1f08931981dde2a823e0e733090af168eaf39 (diff) | |
download | ganv-177ef9fea33e2f8904cd6d06ec4404bfb60ed7f5.tar.gz ganv-177ef9fea33e2f8904cd6d06ec4404bfb60ed7f5.tar.bz2 ganv-177ef9fea33e2f8904cd6d06ec4404bfb60ed7f5.zip |
Fix layout of nodes with partners.
Reduce oscillation by adding force noise.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5378 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Canvas.cpp')
-rw-r--r-- | src/Canvas.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 5e0605b..7694954 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -883,6 +883,11 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) node->impl->force, tide_force(mouth, reg.pos, 4000000000000.0)); + // Add slight noise to force to limit oscillation + const Vector noise = { rand() / (float)RAND_MAX * 128.0, + rand() / (float)RAND_MAX * 128.0 }; + node->impl->force = vec_add(noise, node->impl->force); + FOREACH_ITEM(_items, j) { if (i == j || (!GANV_IS_MODULE(*i) && !GANV_IS_CIRCLE(*i))) { continue; @@ -902,7 +907,8 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) static const float damp = 0.3; // Velocity damping - if (node->impl->grabbed || !node->impl->connected) { + if (node->impl->grabbed || + (!node->impl->connected && !ganv_node_get_partner(node))) { node->impl->vel.x = 0.0; node->impl->vel.y = 0.0; } else { |