summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ffdffb6)
When stretchability is changed,
leave inverse_compression_strength alone.
\context {
\Score
\override VerticalAxisGroup #'staff-staff-spacing =
\context {
\Score
\override VerticalAxisGroup #'staff-staff-spacing =
- #'((basic-distance . 20)
- (stretchability . 0))
+ #'((minimum-distance . 20))
if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance")))
dy = max (dy, min_distance);
if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance")))
dy = max (dy, min_distance);
- if (include_fixed_spacing)
- dy = max (dy, Page_layout_problem::get_fixed_spacing (elems[j-1], elems[j], spaceable_count, pure, start, end));
-
if (include_fixed_spacing && Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element)
{
// Spaceable staves may have
if (include_fixed_spacing && Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element)
{
// Spaceable staves may have
return robust_scm2double (cached, 0.0);
}
return robust_scm2double (cached, 0.0);
}
- SCM spec = Page_layout_problem::get_spacing_spec (before, after, pure, start, end);
- Real stretchability = 0;
- if (Page_layout_problem::read_spacing_spec (spec, &stretchability, ly_symbol2scm ("stretchability"))
- && stretchability == 0)
- Page_layout_problem::read_spacing_spec (spec, &ret, ly_symbol2scm ("basic-distance"));
// If we're pure, then paper-columns have not had their systems set,
// and so elts[i]->get_system () is unreliable.
// If we're pure, then paper-columns have not had their systems set,
// and so elts[i]->get_system () is unreliable.
spring->set_default_strength ();
if (read_spacing_spec (spec, &stretch, ly_symbol2scm ("stretchability")))
spring->set_default_strength ();
if (read_spacing_spec (spec, &stretch, ly_symbol2scm ("stretchability")))
- {
- spring->set_inverse_stretch_strength (stretch);
- spring->set_inverse_compress_strength (stretch);
- }
+ spring->set_inverse_stretch_strength (stretch);
Real
Simple_spacer::compress_line ()
{
Real
Simple_spacer::compress_line ()
{
double cur_len = configuration_length (force_);
double cur_force = force_;
bool compressed = false;
double cur_len = configuration_length (force_);
double cur_force = force_;
bool compressed = false;
- for (vsize i=0; i < springs_.size (); i++)
- inv_hooke += compressed
- ? springs_[i].inverse_compress_strength ()
- : springs_[i].inverse_stretch_strength ();
assert (line_len_ <= cur_len);
vector<Spring> sorted_springs = springs_;
sort (sorted_springs.begin (), sorted_springs.end (), greater<Spring> ());
assert (line_len_ <= cur_len);
vector<Spring> sorted_springs = springs_;
sort (sorted_springs.begin (), sorted_springs.end (), greater<Spring> ());
- for (vsize i = 0; i < sorted_springs.size (); i++)
+ /* inv_hooke is the total flexibility of currently-active springs */
+ double inv_hooke = 0;
+ vsize i = sorted_springs.size ();
+ for ( ; i && sorted_springs[i - 1].blocking_force () < cur_force; i--)
+ inv_hooke += compressed
+ ? sorted_springs[i - 1].inverse_compress_strength ()
+ : sorted_springs[i - 1].inverse_stretch_strength ();
+ /* i now indexes the first active spring, so */
+ for ( ; i < sorted_springs.size (); i++)
{
Spring sp = sorted_springs[i];
{
Spring sp = sorted_springs[i];
- if (sp.blocking_force () > cur_force)
- continue;
-
if (isinf (sp.blocking_force ()))
break;
if (isinf (sp.blocking_force ()))
break;
void
Spring::update_blocking_force ()
{
void
Spring::update_blocking_force ()
{
+ // blocking_force_ is the value of force
+ // below which length(force) is constant, and
+ // above which length(force) varies according to inverse_*_strength.
+ // Simple_spacer::compress_line() depends on the condition above.
+ // We assume inverse_*_strength are non-negative.
if (min_distance_ > distance_)
if (min_distance_ > distance_)
- blocking_force_ = (min_distance_ - distance_) / inverse_stretch_strength_;
+ if (inverse_stretch_strength_ > 0.0)
+ blocking_force_ = (min_distance_ - distance_) / inverse_stretch_strength_;
+ else
+ // Conceptually, this should be +inf, but 0.0 meets the requirements
+ // of Simple_spacer and creates fewer cases of 0.0*inf to handle.
+ blocking_force_ = 0.0;
- 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 (because it always blocks).
- // -infinity_f works fine for now.
- // If inverse_stretch_strength > 0, the spring is not fixed (because it can stretch).
- if (isnan (blocking_force_) || blocking_force_ == infinity_f)
- blocking_force_ = (inverse_stretch_strength_ > 0) ? 0.0 : -infinity_f;
-
- if (blocking_force_ >= 0)
- inverse_compress_strength_ = 0;
+ if (inverse_compress_strength_ > 0.0)
+ blocking_force_ = (min_distance_ - distance_) / inverse_compress_strength_;
+ else
+ blocking_force_ = 0.0;
}
/* scale a spring, but in a way that doesn't violate min_distance */
}
/* scale a spring, but in a way that doesn't violate min_distance */
Real force = max (f, blocking_force_);
Real inv_k = force < 0.0 ? inverse_compress_strength_ : inverse_stretch_strength_;
Real force = max (f, blocking_force_);
Real inv_k = force < 0.0 ? inverse_compress_strength_ : inverse_stretch_strength_;
- if (force == infinity_f)
{
programming_error ("cruelty to springs");
force = 0.0;
{
programming_error ("cruelty to springs");
force = 0.0;