17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 23:59:12 +01:00

feat(sleepers): the timbers of a switch get the fastenings of the rails from the submodels plate, chair and check of their model: a plate under each rail where it lies on a timber, slide chairs under the stock rails along the blades, a fastening of both where a check rail or another rail of the frog lies close beside, the legs of the nose in one plate where they're joined; the rails sit on the plate, the blades ride on the slide plates of the chairs as high as the model has them, their webs shortened; the fastenings drawn within 120 m; selftest fastenings

This commit is contained in:
maj00r
2026-10-23 16:46:58 +02:00
parent fc714d50ec
commit 5aedbcdc1b
12 changed files with 440 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "world/TrackSleepers.h"
#include "world/SleeperFastenings.h"
#include "world/SleeperGeometry.h"
#include "world/SleeperLayout.h"
#include "world/SleeperPaths.h"
@@ -24,6 +25,7 @@ http://mozilla.org/MPL/2.0/.
#include <algorithm>
#include <map>
#include <optional>
#include <set>
namespace track_sleepers {
@@ -63,6 +65,11 @@ bool lays( TTrack const &Track ) {
return bedded( Track ) && timber_model( Track ) != nullptr;
}
double blade_rise( TTrack const &Track ) {
return ( Track.eType == tt_Switch && lays( Track ) ? timber_model( Track )->slide : 0.0 );
}
std::vector<std::pair<double, double>> shared_zones( TTrack const &Track, int const Path ) {
std::vector<std::pair<double, double>> result;
@@ -134,6 +141,9 @@ void lay( TTrack &Track ) {
// the layout of the cluster isn't needed by this track any more, the instances below are what's drawn
forget_layout( Track );
// the rails around, where they lie on the timbers, for the fastenings of the model
std::optional<fastened_rails> const rails { parts.fastened() ? std::make_optional<fastened_rails>( Track ) : std::nullopt };
auto const partlength = [&]( int const Part ) {
return static_cast<double>( parts.spans[ Part ].y - parts.spans[ Part ].x ); };
auto const beginlength { partlength( part_begin ) };
@@ -232,6 +242,19 @@ void lay( TTrack &Track ) {
put( part_end, scale, parts.spans[ part_end ].x, -half );
put( part_begin, scale, parts.spans[ part_begin ].y, half );
}
if( rails && false == ( beam.plain && laid.plains != nullptr ) ) {
// each square to its rail on the top of the timber, the plate under the foot of the rail
for( auto const &fastening : rails->on( beam, parts ) ) {
auto across { glm::dvec3 { fastening.across.x, 0.0, fastening.across.y } };
across = glm::normalize( across - y * glm::dot( across, y ) );
glm::mat4 place { 1.f };
place[ 0 ] = glm::vec4 { glm::vec3 { across }, 0.f };
place[ 1 ] = glm::vec4 { glm::vec3 { y }, 0.f };
place[ 2 ] = glm::vec4 { glm::vec3 { glm::cross( across, y ) }, 0.f };
place[ 3 ] = glm::vec4 { glm::vec3 { fastening.point - Track.m_origin }, 1.f };
laid.instances[ fastening.part ].emplace_back( glm::translate( place, glm::vec3 { 0.f, -parts.seat, 0.f } ) );
}
}
runbeams.emplace_back( middle, half );
if( runbeams.size() >= chunk_beams ) {
close_run();