]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slur-configuration.cc
Run grand-replace for 2012
[lilypond.git] / lily / slur-configuration.cc
index 8fdea86edb73b0a1fb4829e0a4fcf39932828a8f..32597210e1d1057e3bc7c675e2019bda646c171a 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -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));
 
@@ -266,18 +277,6 @@ Slur_configuration::score_encompass (Slur_score_state const &state)
 
           demerit += stem_dem;
         }
-      else if (!edge)
-        {
-          Interval ext;
-          ext.add_point (state.encompass_infos_[j].stem_);
-          ext.add_point (state.encompass_infos_[j].head_);
-
-          // ?
-          demerit += -state.parameters_.closeness_factor_
-                     * min (state.dir_
-                            * (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_)), 0.0)
-                     / state.encompass_infos_.size ();
-        }
     }
   add_score (demerit, "encompass");