+ distance_ = 1.0;
+ min_distance_ = 1.0;
+ inverse_stretch_strength_ = 1.0;
+ inverse_compress_strength_ = 1.0;
+
+ update_blocking_force ();
+}
+
+Spring::Spring (Real dist, Real min_dist)
+{
+ distance_ = 1.0;
+ min_distance_ = 1.0;
+ inverse_stretch_strength_ = 1.0;
+ inverse_compress_strength_ = 1.0;
+
+ set_distance (dist);
+ set_min_distance (min_dist);
+ set_default_strength ();
+ update_blocking_force ();
+}
+
+void
+Spring::update_blocking_force ()
+{
+ if (min_distance_ > distance_)
+ blocking_force_ = (min_distance_ - distance_) / inverse_stretch_strength_;
+ else
+ blocking_force_ = (min_distance_ - distance_) / inverse_compress_strength_;
+
+ // If the spring is fixed, it's not clear what the natural value
+ // of blocking_force_ would be. -infinity_f works fine for now.
+ if (isnan (blocking_force_) || blocking_force_ == infinity_f)
+ blocking_force_ = -infinity_f;
+
+ if (blocking_force_ >= 0)
+ inverse_compress_strength_ = 0;