summaryrefslogtreecommitdiff
path: root/lily/simple-spacer.cc
diff options
context:
space:
mode:
authorJoe Neeman <joeneeman@gmail.com>2007-12-18 12:15:56 +1100
committerJoe Neeman <joeneeman@gmail.com>2008-01-23 09:37:02 +0100
commit7802d89e1fbb1310b2801502293ece228b5dda66 (patch)
tree3c41e1b29c2378a97c71b29f80f86473dbb505e7 /lily/simple-spacer.cc
parent166cd84b1eeb93a9baa33c607fbbfe7931d58e5a (diff)
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;
}