summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-04-27 15:56:26 +0000
committerDavid Robillard <d@drobilla.net>2014-04-27 15:56:26 +0000
commit177ef9fea33e2f8904cd6d06ec4404bfb60ed7f5 (patch)
treed59c9426736663778c6909eb1987c048ffea9ba1
parent3ea1f08931981dde2a823e0e733090af168eaf39 (diff)
downloadganv-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
-rw-r--r--src/Canvas.cpp8
-rw-r--r--src/fdgl.hpp2
2 files changed, 8 insertions, 2 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 {
diff --git a/src/fdgl.hpp b/src/fdgl.hpp
index b40f333..224824b 100644
--- a/src/fdgl.hpp
+++ b/src/fdgl.hpp
@@ -16,7 +16,7 @@
#include <float.h>
#include <math.h>
-static const double CHARGE_KE = 1000000.0;
+static const double CHARGE_KE = 4000000.0;
static const double EDGE_K = 16.0;
static const double EDGE_LEN = 0.1;