From: hanwen Date: Fri, 17 May 2002 22:13:15 +0000 (+0000) Subject: knee kludge X-Git-Tag: release/1.5.59~42 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e7b61fb6da254290f88ce4c855b02d333fb3b562;p=lilypond.git knee kludge --- diff --git a/ChangeLog b/ChangeLog index f99147987e..2c935ac275 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-05-18 Han-Wen + + * lily/stem.cc (calc_stem_info): bugfix for less ugly knees. + 2002-05-17 Han-Wen * scripts/lilypond-book.py (re_dict): fix regexps; don't combine ? diff --git a/VERSION b/VERSION index 5f243dd067..b8a48f6f7d 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=56 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=hwn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lily/beam.cc b/lily/beam.cc index da17fd4d0b..ac715ee9f2 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -428,7 +428,7 @@ Beam::quanting (SCM smob) */ - const int REGION_SIZE = 3; + const int REGION_SIZE = 2; for (int i = -REGION_SIZE ; i < REGION_SIZE; i++) for (int j = 0; j < num_quants; j++) { @@ -492,6 +492,9 @@ Beam::quanting (SCM smob) Array rbase_lengths; Array directions; + + Drul_array dirs_found(0,0); + for (int i= 0; i < stems.size(); i++) { Grob*s = stems[i]; @@ -502,16 +505,20 @@ Beam::quanting (SCM smob) b = calc_stem_y (me, s, Interval (0,1)); rbase_lengths.push (b); - directions.push( Directional_element_interface::get( s)); + + Direction d = Directional_element_interface::get( s); + directions.push( d); + dirs_found [d] = true; } + bool knee_b = dirs_found[LEFT] && dirs_found[RIGHT]; for (int i = qscores.size (); i--;) if (qscores[i].demerits < 100) { qscores[i].demerits += score_stem_lengths (stems, stem_infos, lbase_lengths, rbase_lengths, - directions, + directions, knee_b, me, qscores[i].yl, qscores[i].yr); } @@ -550,6 +557,7 @@ Beam::score_stem_lengths (Link_arraystems, Array left_factor, Array right_factor, Array directions, + bool knee, Grob*me, Real yl, Real yr) { Real demerit_score = 0.0 ; @@ -565,9 +573,13 @@ Beam::score_stem_lengths (Link_arraystems, Stem_info info = stem_infos[i]; Direction d = Direction (directions[i]); + + Real pen = STEM_LENGTH_LIMIT_PENALTY; + if (knee) + pen = sqrt(pen); - demerit_score += STEM_LENGTH_LIMIT_PENALTY * ( 0 >? (info.min_y - d * current_y)); - demerit_score += STEM_LENGTH_LIMIT_PENALTY * ( 0 >? (d * current_y - info.max_y)); + demerit_score += pen * ( 0 >? (info.min_y - d * current_y)); + demerit_score += pen * ( 0 >? (d * current_y - info.max_y)); demerit_score += STEM_LENGTH_DEMERIT_FACTOR * shrink_extra_weight (d * current_y - info.ideal_y); } diff --git a/lily/include/beam.hh b/lily/include/beam.hh index e8ace6dcce..bbbfbda325 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -40,7 +40,7 @@ public: static Real score_stem_lengths (Link_array, Array, Array, Array, Array, - Grob*,Real , Real); + bool,Grob*,Real , Real); static Real score_forbidden_quants (Grob*, Real, Real, Real, Real, Real, Real, int); diff --git a/lily/stem.cc b/lily/stem.cc index 600092f8b4..7b8db24062 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -9,7 +9,7 @@ TODO: This is way too hairy */ -#include // m_pi +#include // rint #include "lookup.hh" #include "directional-element-interface.hh" @@ -753,6 +753,10 @@ Stem::calc_stem_info (Grob*me) info.ideal_y = chord_start_f (me); // for simplicity, we calculate as if dir == UP + + /* + UGH. This confuses issues more. fixme. --hwn + */ info.ideal_y *= beam_dir; SCM grace_prop = me->get_grob_property ("grace"); @@ -776,6 +780,10 @@ Stem::calc_stem_info (Grob*me) Real stem_length = a[multiplicity ? info.min_y;