diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Canvas.cpp | 8 | ||||
-rw-r--r-- | src/fdgl.hpp | 2 |
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; |