[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Limits slurs to a maximum height. (issue4843043)
From: |
mtsolo |
Subject: |
Limits slurs to a maximum height. (issue4843043) |
Date: |
Tue, 02 Aug 2011 23:27:47 +0000 |
Reviewers: ,
Message:
This patch is the one with which I found the problem in the build
system. While its introduction of a +nan.0 somewhere in the works does
not bode well for it, all of the snippets in input/regression compile
cleanly before the build system crashes (see issue 1799), and I only see
slight visual output changes on the manual tests I ran. It fixes huge
slurs from a different angle (acting on the height used in
generate_curve).
Cheers,
MS
Description:
Limits slurs to a maximum height.
Please review this at http://codereview.appspot.com/4843043/
Affected files:
M lily/include/slur-configuration.hh
M lily/include/slur-score-parameters.hh
M lily/slur-configuration.cc
M lily/slur-score-parameters.cc
M lily/slur-scoring.cc
M scm/layout-slur.scm
Index: lily/include/slur-configuration.hh
diff --git a/lily/include/slur-configuration.hh
b/lily/include/slur-configuration.hh
index
acf2b1fdc6f21abc08870e59b414a1d737719af6..7e6d0be3677d2d6915725987f9da9556793a8562
100644
--- a/lily/include/slur-configuration.hh
+++ b/lily/include/slur-configuration.hh
@@ -53,6 +53,7 @@ public:
string card () const { return score_card_; }
void add_score (Real, string);
+ Real generate_max_height (Slur_score_state const &state);
void generate_curve (Slur_score_state const &state, Real r0, Real h_inf,
vector<Offset> const &);
void run_next_scorer (Slur_score_state const &);
Index: lily/include/slur-score-parameters.hh
diff --git a/lily/include/slur-score-parameters.hh
b/lily/include/slur-score-parameters.hh
index
49d159b9390da0a2aebb9589e62d1947b1ea1bd2..9fc591a2828ffbd8d47295bff49771d93bd496e2
100644
--- a/lily/include/slur-score-parameters.hh
+++ b/lily/include/slur-score-parameters.hh
@@ -33,6 +33,7 @@ struct Slur_score_parameters
Real same_slope_penalty_;
Real steeper_slope_factor_;
Real non_horizontal_penalty_;
+ Real max_head_room_;
Real max_slope_;
Real max_slope_factor_;
Real extra_object_collision_penalty_;
Index: lily/slur-configuration.cc
diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc
index
8fdea86edb73b0a1fb4829e0a4fcf39932828a8f..4afb09372d8f07755ffbd52d2bffbfa4577bbf4e
100644
--- a/lily/slur-configuration.cc
+++ b/lily/slur-configuration.cc
@@ -105,6 +105,43 @@ fit_factor (Offset dz_unit, Offset dz_perp,
return fit_factor;
}
+Real
+Slur_configuration::generate_max_height (Slur_score_state const &state)
+{
+ Real max_height = -state.dir_ * infinity_f;
+ vector<Offset> testables;
+ for (vsize i = 0; i < state.encompass_infos_.size (); i++)
+ testables.push_back (Offset (state.encompass_infos_[i].x_, minmax
(state.dir_, state.encompass_infos_[i].head_,
state.encompass_infos_[i].stem_)));
+ for (vsize i = 0; i < state.extra_encompass_infos_.size (); i++)
+ testables.push_back (Offset
(state.extra_encompass_infos_[i].extents_[X_AXIS].center
(),state.extra_encompass_infos_[i].extents_[Y_AXIS][state.dir_]));
+
+ Offset ba_dif = attachment_[RIGHT] - attachment_[LEFT];
+ Real ba_slope = ba_dif[Y_AXIS] / ba_dif[X_AXIS];
+ Real ba_offset = attachment_[RIGHT][Y_AXIS] - ba_slope *
attachment_[RIGHT][X_AXIS];
+ // will fail for slurs with no X-extent, but that never happens...
+ Real ba_perp = 0.0;
+ if (ba_slope != 0.0)
+ ba_perp = -1.0 / ba_slope;
+ for (vsize i = 0; i < testables.size (); i++)
+ {
+ Offset distance_offset;
+ if (ba_perp != 0.0)
+ {
+ Real offset = testables[i][Y_AXIS] - ba_perp *
testables[i][X_AXIS];
+ Real x = (offset - ba_offset) / (ba_slope - ba_perp);
+ Offset point_on_ba_line (x, ba_slope * x + ba_offset);
+ distance_offset = testables[i] - point_on_ba_line;
+ }
+ else
+ distance_offset = Offset (0.0, testables[i][Y_AXIS] -
attachment_[LEFT][Y_AXIS]);
+ Real distance = 0.0;
+ if (distance_offset.length () != 0.0)
+ distance = distance_offset.length () * fabs
(distance_offset[Y_AXIS]) / distance_offset[Y_AXIS];
+ max_height = minmax (state.dir_, distance, max_height);
+ }
+ return state.dir_ * (max_height + state.dir_ *
state.parameters_.max_head_room_);
+}
+
void
Slur_configuration::generate_curve (Slur_score_state const &state,
Real r_0, Real h_inf,
@@ -162,6 +199,8 @@ Slur_configuration::generate_curve (Slur_score_state
const &state,
Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
height = max (height, min (height * ff, max_h));
+ if (!to_boolean (state.slur_->get_property ("cross-staff")))
+ height = min (generate_max_height (state), height);
curve.control_[0] = attachment_[LEFT];
curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
Index: lily/slur-score-parameters.cc
diff --git a/lily/slur-score-parameters.cc b/lily/slur-score-parameters.cc
index
00f2d60312e2c2b74439164b4e064e9dad7615fa..4b5abb055db4bb1f22b92a65c1d88589bad031d3
100644
--- a/lily/slur-score-parameters.cc
+++ b/lily/slur-score-parameters.cc
@@ -58,6 +58,8 @@ Slur_score_parameters::fill (Grob *me)
= get_detail (details, ly_symbol2scm ("max-slope-factor"));
free_head_distance_
= get_detail (details, ly_symbol2scm ("free-head-distance"));
+ max_head_room_
+ = get_detail (details, ly_symbol2scm ("max-head-room"));
absolute_closeness_measure_
= get_detail (details, ly_symbol2scm ("absolute-closeness-measure"));
extra_object_collision_penalty_
Index: lily/slur-scoring.cc
diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc
index
5413c047c2cc219f71773a211aa426d0385d4198..2adf5c913baba52ce8a63b46e0a01c284e8b3fac
100644
--- a/lily/slur-scoring.cc
+++ b/lily/slur-scoring.cc
@@ -571,6 +571,7 @@ Slur_score_state::move_away_from_staffline (Real y,
return y;
}
+
vector<Offset>
Slur_score_state::generate_avoid_offsets () const
{
Index: scm/layout-slur.scm
diff --git a/scm/layout-slur.scm b/scm/layout-slur.scm
index
8626e0114690e832872b4aaff9cf23ce797a5e30..e3b006b45f8c6b4ff52e4101ab30e4a6f1b8e2d4
100644
--- a/scm/layout-slur.scm
+++ b/scm/layout-slur.scm
@@ -25,6 +25,7 @@
(same-slope-penalty . 20)
(steeper-slope-factor . 50)
(non-horizontal-penalty . 15)
+ (max-head-room . 1.6)
(max-slope . 1.1)
(max-slope-factor . 10)
(free-head-distance . 0.3)
- Limits slurs to a maximum height. (issue4843043),
mtsolo <=