From: Mike Solomon Date: Thu, 11 Aug 2011 23:01:36 +0000 (+0200) Subject: Caps slur height by ignoring extremal extra encompasses in fit_factor. X-Git-Tag: release/2.15.9-1~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=94ea10f3f341fff503599a9eb947c81f1803290f;p=lilypond.git Caps slur height by ignoring extremal extra encompasses in fit_factor. These extremal extra encompasses are still, however, taken into account during slur scoring. --- diff --git a/input/regression/slur-height-capping.ly b/input/regression/slur-height-capping.ly new file mode 100644 index 0000000000..03b2b96ddd --- /dev/null +++ b/input/regression/slur-height-capping.ly @@ -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) | +} diff --git a/lily/include/slur-score-parameters.hh b/lily/include/slur-score-parameters.hh index 49d159b939..cae53a4d8e 100644 --- a/lily/include/slur-score-parameters.hh +++ b/lily/include/slur-score-parameters.hh @@ -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_; diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index 8fdea86edb..9957701812 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -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 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)); diff --git a/lily/slur-score-parameters.cc b/lily/slur-score-parameters.cc index 00f2d60312..886799d981 100644 --- a/lily/slur-score-parameters.cc +++ b/lily/slur-score-parameters.cc @@ -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")); } diff --git a/scm/layout-slur.scm b/scm/layout-slur.scm index 8626e01146..5614dd65c6 100644 --- a/scm/layout-slur.scm +++ b/scm/layout-slur.scm @@ -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) ))