mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 16:19:13 +01:00
Merge remote-tracking branch 'origin/feat/switch-blades' into feat/gl46-migration
This commit is contained in:
@@ -19,6 +19,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "utilities/Classes.h"
|
||||
#include "world/Segment.h"
|
||||
#include "world/RailLayout.h"
|
||||
#include "world/TrackSleepers.h"
|
||||
#include "model/material.h"
|
||||
#include "scene/scenenode.h"
|
||||
#include "utilities/Names.h"
|
||||
@@ -54,6 +56,14 @@ class TGroundNode;
|
||||
class TSubRect;
|
||||
class TTraction;
|
||||
|
||||
// a chunk of the geometry of a track kept to be laid again in, for the rails changing with the state of a switch
|
||||
struct pooled_chunk {
|
||||
int type { 0 };
|
||||
gfx::geometry_handle handle;
|
||||
bool used { false };
|
||||
};
|
||||
using chunk_pool = std::vector<pooled_chunk>;
|
||||
|
||||
class TSwitchExtension
|
||||
{ // dodatkowe dane do toru, który jest zwrotnicą
|
||||
public:
|
||||
@@ -99,6 +109,12 @@ class TSwitchExtension
|
||||
glm::dvec3 vTrans; // docelowa translacja przesuwnicy
|
||||
material_handle m_material3 = 0; // texture of auto generated switch trackbed
|
||||
gfx::geometry_handle Geometry3; // geometry of auto generated switch trackbed
|
||||
bool m_frogs { false }; // the frog and check rails are made from the rails, for switches with no model of them in their includes
|
||||
bool m_movablenose { false }; // the nose of the frog moves over to the rail of the track set, closing its flangeway; no check rails
|
||||
double m_bladeheel { 0.0 }; // where the moving blades end along the paths, as the template of the switch gives it; 0: as long as the flangeway needs
|
||||
double m_bladethrow { 0.0 }; // how far the tips of the blades move over; 0: the usual throw
|
||||
double m_nosethrow { -1.0 }; // how far over to the second path the movable nose was laid, -1: no geometry yet
|
||||
chunk_pool m_nosechunks; // the geometry of the switch, laid again in the same chunks as the nose moves over
|
||||
|
||||
gfx::geometrybank_handle map_geometry[6]; // geometry for map visualisation
|
||||
};
|
||||
@@ -180,12 +196,26 @@ public:
|
||||
material_handle m_material1 = 0; // tekstura szyn albo nawierzchni
|
||||
material_handle m_material2 = 0; // tekstura automatycznej podsypki albo pobocza
|
||||
std::pair<std::string, int> m_profile1 {}; // profile of geometry chunks textured with texture 1
|
||||
// sets the rail profile by its name, as railprofile does; empty: none, the default shape
|
||||
void rail_profile( std::string const &Name );
|
||||
using geometryhandle_sequence = std::vector<gfx::geometry_handle>;
|
||||
geometryhandle_sequence Geometry1; // geometry chunks textured with texture 1
|
||||
geometryhandle_sequence Geometry2; // geometry chunks textured with texture 2
|
||||
material_handle m_materialcut1 = 0; // matte variant of texture 1, for the cut faces of rails
|
||||
material_handle m_materialcut2 = 0; // matte variant of texture 2, for the cut faces of rails of the other switch path
|
||||
geometryhandle_sequence GeometryCut1; // cut faces of rails textured with texture 1, the blade tip first for a switch
|
||||
geometryhandle_sequence GeometryCut2; // cut faces of rails textured with texture 2, the blade tip first
|
||||
struct tread_geometry {
|
||||
material_handle material { 0 };
|
||||
material_handle matte { 0 };
|
||||
geometryhandle_sequence geometry;
|
||||
geometryhandle_sequence cuts;
|
||||
};
|
||||
std::vector<tread_geometry> GeometryTreads;
|
||||
|
||||
std::vector<segment_data> m_paths; // source data for owned paths
|
||||
bool m_editorremoved { false };
|
||||
std::vector<TTrack *> m_crossings; // tracks whose rails cross the rails of this one, found when its geometry was made
|
||||
scene::basic_node *m_road { nullptr }; // road or road junction which generated this path. such path is one-way, and isn't saved nor edited on its own
|
||||
std::array<float, 3> m_routeweights { 0.f, 0.f, 0.f }; // odds of each route through a crossroads being picked by a driver, by the number of the route. all zero: even odds
|
||||
int iterate_stamp = 0;
|
||||
@@ -202,12 +232,19 @@ public:
|
||||
std::string m_sleeper_skin_name; // replacable skin path, or "none" for default
|
||||
glm::vec3 m_sleeper_offset { 0.f, 0.f, 0.f }; // local offset from track centerline (x: left/right, y: forward/back, z: up/down)
|
||||
float m_sleeper_ballast_z { 0.f }; // vertical offset applied to the trackbed (ballast) profile
|
||||
// timbermodel optional parameter: the model of the timbers laid under the track where it's part of a switch or a crossing,
|
||||
// in place of the one set with sleepers3d in eu07.ini. Defined in scenery file as:
|
||||
// timbermodel <model> <skin>
|
||||
std::string m_timber_model_name;
|
||||
std::string m_timber_skin_name; // replacable skin, empty for the textures of the model
|
||||
TModel3d *m_sleeper_model { nullptr }; // resolved on init; nullptr means no model / failed to load
|
||||
material_handle m_sleeper_skin { 0 }; // resolved replacable skin handle, 0 = use model defaults
|
||||
// precomputed local-space transforms (relative to m_origin) for every sleeper instance along the path.
|
||||
// Each matrix is translate(world_pos - m_origin) * rotate(direction, roll) * translate(local_offset).
|
||||
// The renderer composes this with (view * translate(m_origin - camera_pos)) per draw.
|
||||
std::vector<glm::mat4> m_sleeper_local_transforms;
|
||||
// sleepers and switch timbers made of the model set with sleepers3d in eu07.ini, laid where the simulator makes the ballast
|
||||
track_sleepers::laid m_sleepers3d;
|
||||
|
||||
public:
|
||||
using dynamics_sequence = std::deque<TDynamicObject *>;
|
||||
@@ -262,13 +299,20 @@ public:
|
||||
material_handle copy_adjacent_trackbed_material( TTrack const *Exclude = nullptr );
|
||||
inline double Length() const {
|
||||
return Segment->GetLength(); };
|
||||
// how far below the top of the rails their feet are, by the rail profile of the track
|
||||
float rail_height() const;
|
||||
inline std::shared_ptr<TSegment> CurrentSegment() const {
|
||||
return Segment; };
|
||||
inline TTrack *CurrentNext() const {
|
||||
return trNext; };
|
||||
inline TTrack *CurrentPrev() const {
|
||||
return trPrev; };
|
||||
TTrack *Connected(int s, double &d) const;
|
||||
TTrack *Connected(int s, double &d, int const Path = -1) const; // Path: of a switch, the one to leave by whichever way it is set
|
||||
double trailing_point( int const Path ) const; // where along the path the wheels coming from the frog end push the blades over
|
||||
int nose_set() const; // the path the movable nose of the frog lies for, following the blades
|
||||
double nose_throw() const; // how far the movable nose of the frog went over to the second path, following the blades
|
||||
material_handle rail_material( int const Path ) const;
|
||||
glm::vec2 tread_band() const;
|
||||
bool SetConnections(int i);
|
||||
bool Switch(int i, float const t = -1.f, float const d = -1.f);
|
||||
bool SwitchForced(int i, TDynamicObject *o);
|
||||
@@ -285,6 +329,15 @@ public:
|
||||
int RouteDraw() const;
|
||||
void Load(cParser *parser, glm::dvec3 const &pOrigin);
|
||||
void init_segments( bool const Initial );
|
||||
track_rails::switch_frog frog() const;
|
||||
track_rails::switch_blade const &blade( int const Path ) const;
|
||||
double blades_throw() const; // how far the tips of the blades move over between the two paths
|
||||
std::vector<track_rails::rail_crossing> rail_crossings( bool const Joined = true );
|
||||
track_rails::rail_size rail_dimensions() const;
|
||||
// the check rails beside the rails of each path, kept clear of the blades and the rails of other paths running inside them
|
||||
track_rails::check_rail_set check_rails( std::vector<track_rails::rail_crossing> const &Crossings );
|
||||
// Carve: the parts of the rails at crossings carved out of what lies around them, false: only their design
|
||||
track_rails::rail_layout plan_rails( bool const Crossings, bool const Carve = true );
|
||||
void update_location();
|
||||
bool AssignEvents();
|
||||
bool AssignForcedEvents(basic_event *NewEventPlus, basic_event *NewEventMinus);
|
||||
@@ -366,8 +419,10 @@ private:
|
||||
float texture_length( material_handle const Material );
|
||||
// creates profile for a part of current path
|
||||
void create_switch_trackbed( gfx::vertex_array &Output );
|
||||
void create_track_rail_profile( gfx::vertex_array &Right, gfx::vertex_array &Left );
|
||||
void create_track_rail_profile( gfx::vertex_array &Right, gfx::vertex_array &Left, gfx::vertex_array const *Shape = nullptr );
|
||||
void create_track_blade_profile( gfx::vertex_array &Right, gfx::vertex_array &Left );
|
||||
void profile_rolls( float &Roll1, float &Roll2 ) const;
|
||||
void share_joints();
|
||||
void create_track_bed_profile( gfx::vertex_array &Output, TTrack const *Previous, TTrack const *Next );
|
||||
void create_road_profile( gfx::vertex_array &Output, bool const Forcetransition = false );
|
||||
void create_road_side_profile( gfx::vertex_array &Right, gfx::vertex_array &Left, gfx::vertex_array const &Road, bool const Forcetransition = false );
|
||||
@@ -377,6 +432,23 @@ private:
|
||||
/// Safe to call multiple times; clears any previously cached transforms first.
|
||||
/// </summary>
|
||||
void build_sleeper_transforms();
|
||||
struct rail_drawing {
|
||||
gfx::geometrybank_handle bank;
|
||||
track_rails::rail_size size;
|
||||
float halfwidth { 0.f };
|
||||
gfx::vertex_array checkshapes[ 2 ];
|
||||
gfx::vertex_array plates[ 2 ];
|
||||
gfx::vertex_array fillers[ 2 ];
|
||||
float platetexture { 0.f };
|
||||
};
|
||||
rail_drawing make_rail_drawing( gfx::geometrybank_handle const &Bank );
|
||||
// a rail along a path from a distance on, in parts where other rails cross it, and the check rails beside it. false: no crossing, the rail is laid whole as before
|
||||
bool lay_rail( track_rails::rail_layout const &Layout, rail_drawing const &Drawing, int const Path, gfx::vertex_array const &Profile, int const Side, float const Texturelength, double const From, bool const Openstart, bool const Openend, geometryhandle_sequence &Geometry, geometryhandle_sequence &Cuts );
|
||||
class rail_layer;
|
||||
class rail_planner;
|
||||
int blade_side( int const Path ) const;
|
||||
material_handle shared_tread( int const Path, TTrack const &Other, int const Otherpath ) const;
|
||||
void loft_blade( int const Path, gfx::vertex_array const &Rail, gfx::vertex_array const &Blade, float const Texturelength, gfx::vertex_array &Vertices ) const;
|
||||
// members
|
||||
static profiles_array m_profiles; // shared database of path element profiles
|
||||
static profiles_map m_profilesmap;
|
||||
|
||||
Reference in New Issue
Block a user