diff options
author | Joe Neeman <joeneeman@gmail.com> | 2007-12-18 12:15:56 +1100 |
---|---|---|
committer | Joe Neeman <joeneeman@gmail.com> | 2008-01-23 09:37:02 +0100 |
commit | 7802d89e1fbb1310b2801502293ece228b5dda66 (patch) | |
tree | 3c41e1b29c2378a97c71b29f80f86473dbb505e7 /lily/simple-spacer.cc | |
parent | 166cd84b1eeb93a9baa33c607fbbfe7931d58e5a (diff) |
Avoid NaN with springs of zero length.
Diffstat (limited to 'lily/simple-spacer.cc')
-rw-r--r-- | lily/simple-spacer.cc | 7 |
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; } |