summaryrefslogtreecommitdiff
path: root/lily/simple-spacer.cc
diff options
context:
space:
mode:
authorValentin Villenave <valentin@villenave.net>2008-01-13 19:00:04 +0100
committerValentin Villenave <valentin@villenave.net>2008-01-13 19:00:04 +0100
commitcc511e8f926ae0f45f742b392577b38dda032db4 (patch)
treebfad72a27d842035ae51bd06e5215ff0339e5264 /lily/simple-spacer.cc
parent04faa1ba634c75c05716b7f49928ebe187862f20 (diff)
third patch from Joe: avoid NaN with springs of zero length
Diffstat (limited to 'lily/simple-spacer.cc')
-rw-r--r--lily/simple-spacer.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc
index 9129361cbd..4da2ac9a87 100644
--- a/lily/simple-spacer.cc
+++ b/lily/simple-spacer.cc
@@ -105,7 +105,12 @@ Simple_spacer::add_rod (int l, int r, Real dist)
Real spring_dist = range_ideal_len (l, r);
if (spring_dist < dist)
for (int i = l; i < r; i++)
- springs_[i].set_distance (springs_[i].distance () * dist / spring_dist);
+ {
+ if (spring_dist)
+ springs_[i].set_distance (springs_[i].distance () * dist / spring_dist);
+ else
+ springs_[i].set_distance (dist / (r - l));
+ }
return;
}