17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-24 21:27:37 +02:00

fix(track): a blending length of 0 on either side keeps the joint sharp

This commit is contained in:
2026-10-22 00:11:26 +02:00
parent 173fe2ec3c
commit c17d77fe6c
3 changed files with 23 additions and 18 deletions

View File

@@ -520,11 +520,11 @@ std::vector<track_property> make_properties()
int end;
};
blend_field const fields[] = {
{"blendballast1", "Ballast blending at p1 (m)", "How far from the end p1 the ballast fades into that of the track joined there, where their textures differ; 0: not blended", track_blend::kind::ballast, 0},
{"blendballast2", "Ballast blending at p2 (m)", "How far from the end p2 the ballast fades into that of the track joined there, where their textures differ; 0: not blended", track_blend::kind::ballast, 1},
{"blendballast3", "Ballast blending at p4 (m)", "How far from the end p4 of the switch its trackbed fades into the ballast of the track joined there, where their textures differ; 0: not blended", track_blend::kind::ballast, 2},
{"blendrails1", "Rails blending at p1 (m)", "How far from the end p1 the rails fade into those of the track joined there, where their textures differ; 0: not blended", track_blend::kind::rails, 0},
{"blendrails2", "Rails blending at p2 (m)", "How far from the end p2 the rails fade into those of the track joined there, where their textures differ; 0: not blended", track_blend::kind::rails, 1}};
{"blendballast1", "Ballast blending at p1 (m)", "How far from the end p1 the ballast fades into that of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has", track_blend::kind::ballast, 0},
{"blendballast2", "Ballast blending at p2 (m)", "How far from the end p2 the ballast fades into that of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has", track_blend::kind::ballast, 1},
{"blendballast3", "Ballast blending at p4 (m)", "How far from the end p4 of the switch its trackbed fades into the ballast of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has", track_blend::kind::ballast, 2},
{"blendrails1", "Rails blending at p1 (m)", "How far from the end p1 the rails fade into those of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has", track_blend::kind::rails, 0},
{"blendrails2", "Rails blending at p2 (m)", "How far from the end p2 the rails fade into those of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has", track_blend::kind::rails, 1}};
for (auto const &blend : fields)
{
auto &property{add(list, blend.key, field::slider, section::look, group::blending, blend.label, blend.tooltip)};

View File

@@ -10276,17 +10276,17 @@ msgstr "Mieszanie szyn przy p1 (m)"
msgid "Rails blending at p2 (m)"
msgstr "Mieszanie szyn przy p2 (m)"
msgid "How far from the end p1 the ballast fades into that of the track joined there, where their textures differ; 0: not blended"
msgstr "Na jakiej długości od końca p1 podsypka płynnie przechodzi w podsypkę toru tam dołączonego, gdy ich tekstury są różne; 0: bez mieszania"
msgid "How far from the end p1 the ballast fades into that of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has"
msgstr "Na jakiej długości od końca p1 podsypka płynnie przechodzi w podsypkę toru tam dołączonego, gdy ich tekstury są różne; 0: ostra granica na styku, niezależnie od ustawienia toru tam dołączonego"
msgid "How far from the end p2 the ballast fades into that of the track joined there, where their textures differ; 0: not blended"
msgstr "Na jakiej długości od końca p2 podsypka płynnie przechodzi w podsypkę toru tam dołączonego, gdy ich tekstury są różne; 0: bez mieszania"
msgid "How far from the end p2 the ballast fades into that of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has"
msgstr "Na jakiej długości od końca p2 podsypka płynnie przechodzi w podsypkę toru tam dołączonego, gdy ich tekstury są różne; 0: ostra granica na styku, niezależnie od ustawienia toru tam dołączonego"
msgid "How far from the end p4 of the switch its trackbed fades into the ballast of the track joined there, where their textures differ; 0: not blended"
msgstr "Na jakiej długości od końca p4 rozjazdu jego podsypka płynnie przechodzi w podsypkę toru tam dołączonego, gdy ich tekstury są różne; 0: bez mieszania"
msgid "How far from the end p4 of the switch its trackbed fades into the ballast of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has"
msgstr "Na jakiej długości od końca p4 rozjazdu jego podsypka płynnie przechodzi w podsypkę toru tam dołączonego, gdy ich tekstury są różne; 0: ostra granica na styku, niezależnie od ustawienia toru tam dołączonego"
msgid "How far from the end p1 the rails fade into those of the track joined there, where their textures differ; 0: not blended"
msgstr "Na jakiej długości od końca p1 szyny płynnie przechodzą w szyny toru tam dołączonego, gdy ich tekstury są różne; 0: bez mieszania"
msgid "How far from the end p1 the rails fade into those of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has"
msgstr "Na jakiej długości od końca p1 szyny płynnie przechodzą w szyny toru tam dołączonego, gdy ich tekstury są różne; 0: ostra granica na styku, niezależnie od ustawienia toru tam dołączonego"
msgid "How far from the end p2 the rails fade into those of the track joined there, where their textures differ; 0: not blended"
msgstr "Na jakiej długości od końca p2 szyny płynnie przechodzą w szyny toru tam dołączonego, gdy ich tekstury są różne; 0: bez mieszania"
msgid "How far from the end p2 the rails fade into those of the track joined there, where their textures differ; 0: the joint stays sharp, whatever the track joined there has"
msgstr "Na jakiej długości od końca p2 szyny płynnie przechodzą w szyny toru tam dołączonego, gdy ich tekstury są różne; 0: ostra granica na styku, niezależnie od ustawienia toru tam dołączonego"

View File

@@ -140,8 +140,9 @@ material_handle material_of( TTrack const &Track, kind const Kind, int const End
}
}
// whether the track blends its rails or ballast at the end into those of the track joined there, and what with. the answer is
// the same for that track back, but for the lengths and the kinds of tracks which blend: switches don't blend their rails
// whether the track blends its rails or ballast at the end into those of the track joined there, and what with: not where
// either of them has a length of 0 there. the answer is the same for that track back, but for the kinds of tracks which blend:
// switches don't blend their rails, a plain track fades its rails all the way into theirs
bool blends( TTrack const &Track, kind const Kind, int const End, TTrack const **Other = nullptr, int *Otherend = nullptr, material_handle *Othermaterial = nullptr ) {
if( End < 0 || End >= end_count( Track ) ) {
@@ -166,6 +167,10 @@ bool blends( TTrack const &Track, kind const Kind, int const End, TTrack const *
if( otherend < 0 ) {
return false;
}
// a length of 0 at either side leaves the joint sharp
if( other->m_blend[ static_cast<int>( Kind ) ][ otherend ] <= 0.f ) {
return false;
}
auto const theirs { material_of( *other, Kind, otherend ) };
if( theirs == null_handle || theirs == own ) {
return false;
@@ -220,7 +225,7 @@ blending setup( TTrack const &Track, kind const Kind ) {
end_frame( Track, end, blend.point, blend.inward );
blend.point -= Track.m_origin;
blend.length = Track.m_blend[ static_cast<int>( Kind ) ][ end ];
// where both tracks blend they meet half way at the joint, otherwise this one goes all the way to the other one there
// where both tracks blend they meet half way at the joint; a plain track goes all the way into the rails of a switch
blend.peak = ( blends( *other, Kind, otherend ) ? 0.5f : 1.f );
blend.active = true;
others[ end ] = theirs;