]> git.donarmstrong.com Git - lilypond.git/commitdiff
Caps slur height by ignoring extremal extra encompasses in fit_factor.
authorMike Solomon <mike@apollinemike.com>
Thu, 11 Aug 2011 23:01:36 +0000 (01:01 +0200)
committerMike Solomon <mike@apollinemike.com>
Thu, 11 Aug 2011 23:01:36 +0000 (01:01 +0200)
These extremal extra encompasses are still, however, taken into account
during slur scoring.

input/regression/slur-height-capping.ly [new file with mode: 0644]
lily/include/slur-score-parameters.hh
lily/slur-configuration.cc
lily/slur-score-parameters.cc
scm/layout-slur.scm

diff --git a/input/regression/slur-height-capping.ly b/input/regression/slur-height-capping.ly
new file mode 100644 (file)
index 0000000..03b2b96
--- /dev/null
@@ -0,0 +1,15 @@
+\version "2.15.9"
+
+\header {
+  texidoc = "Slur shaping is not adapted to accomodate objects
+towards the edges of slur.  Said objects are thus ignored,
+which should make the slur in this regtest flat.  Objects towards
+the edges are not, however, ignored in the slur scoring.
+"
+}
+
+\relative c {
+  \clef bass
+  c8( d' a d c, d' a d)
+  c,( des' as des c, des' as des) |
+}
index 49d159b9390da0a2aebb9589e62d1947b1ea1bd2..cae53a4d8e70cd3742794a784af68860e07df073 100644 (file)
@@ -43,6 +43,7 @@ struct Slur_score_parameters
   Real extra_encompass_free_distance_;
   Real absolute_closeness_measure_;
   Real edge_slope_exponent_;
+  Real close_to_edge_length_;
   Real head_slur_distance_max_ratio_;
   Real head_slur_distance_factor_;
 
index 8fdea86edb73b0a1fb4829e0a4fcf39932828a8f..99577018129afd9dc8187864675e252e50fb6fcb 100644 (file)
@@ -73,7 +73,7 @@ avoid_staff_line (Slur_score_state const &state,
 }
 
 Real
-fit_factor (Offset dz_unit, Offset dz_perp,
+fit_factor (Offset dz_unit, Offset dz_perp, Real close_to_edge_length,
             Bezier curve, Direction d, vector<Offset> const &avoid)
 {
   Real fit_factor = 0.0;
@@ -92,9 +92,19 @@ fit_factor (Offset dz_unit, Offset dz_perp,
       Offset p (dot_product (z, dz_unit),
                 d * dot_product (z, dz_perp));
 
+      bool close_to_edge = false;
+      Direction d = LEFT;
+      do
+        close_to_edge = close_to_edge || -d * (p[X_AXIS] - curve_xext[d]) < close_to_edge_length;
+      while (flip (&d) != LEFT);
+
+      if (close_to_edge)
+        continue;
+
       Real eps = 0.01;
       Interval pext = eps * Interval (-1, 1) + p[X_AXIS];
       pext.intersect (curve_xext);
+
       if (pext.is_empty () || pext.length () <= 1.999 * eps)
         continue;
 
@@ -159,7 +169,8 @@ Slur_configuration::generate_curve (Slur_score_state const &state,
                       + dz_unit * x2;
   curve.control_[3] = attachment_[RIGHT];
 
-  Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
+  Real ff = fit_factor (dz_unit, dz_perp, state.parameters_.close_to_edge_length_,
+                        curve, state.dir_, avoid);
 
   height = max (height, min (height * ff, max_h));
 
index 00f2d60312e2c2b74439164b4e064e9dad7615fa..886799d9818dfd495044008710a901928b9fb942 100644 (file)
@@ -76,4 +76,6 @@ Slur_score_parameters::fill (Grob *me)
     = get_detail (details, ly_symbol2scm ("free-slur-distance"));
   edge_slope_exponent_
     = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
+  close_to_edge_length_
+    = get_detail (details, ly_symbol2scm ("close-to-edge-length"));
 }
index 8626e0114690e832872b4aaff9cf23ce797a5e30..5614dd65c601b0db614ddc25c6a2b214c043d6fc 100644 (file)
@@ -37,4 +37,5 @@
     (head-slur-distance-factor . 10)
     (absolute-closeness-measure . 0.3)
     (edge-slope-exponent . 1.7)
+    (close-to-edge-length . 2.5)
     ))