17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 10:31:01 +01:00

fix(track): what Sonar reports on the unevenness

The blockers are in the EP brake of a vehicle, older than this work: its
arrays made with new[] are vectors now, which also removes the deletes.

- The caches of the unevenness of a track are no longer mutable: what fills
  them isn't const any more.
- TSegment gets back to RaPositionGet in one piece, with what the path has
  to do with the others in one struct.
- Less nesting in the group of switches and in the fields of the editor,
  nested conditionals written out, and the attribute is read from a
  string_view. A test no longer counts in floating point.

No change in behaviour.
This commit is contained in:
maj00r
2026-10-31 20:17:47 +01:00
parent 56d389e2df
commit 9364b03e1a
9 changed files with 223 additions and 207 deletions

View File

@@ -9,7 +9,9 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <array>
#include <optional>
#include <utility>
#include "utilities/Classes.h"
#include "rendering/geometrybank.h"
@@ -50,11 +52,14 @@ class TSegment
glm::dvec3 Point2;
float fRoll1 { 0.f };
float fRoll2 { 0.f }; // przechyłka na końcach
float m_designrolls[ 2 ] { 0.f, 0.f }; // as entered; the two above can differ at a joint
bool m_uneven { false }; // see TrackUneven.h
int m_path { 0 }; // which path of a switch
// where the path meets the next one: the middle of their ends and their common vector across
std::optional<std::pair<glm::dvec3, glm::dvec3>> m_joints[ 2 ];
// how the path sits among the others
struct setting {
std::array<float, 2> designrolls { 0.f, 0.f }; // as entered; fRoll1 and fRoll2 can differ at a joint
bool uneven { false }; // see TrackUneven.h
int path { 0 }; // which path of a switch
// where the path meets the next one: the middle of their ends and their common vector across
std::array<std::optional<std::pair<glm::dvec3, glm::dvec3>>, 2> joints;
} m_setting;
double fLength { -1.0 }; // długość policzona
std::vector<double> fTsBuffer; // wartości parametru krzywej t dla równych odcinków s
std::vector<double> fTsSlope; // nachylenie dt/du (= dt/ds * fStep) w tych samych punktach
@@ -79,9 +84,6 @@ class TSegment
void settle_vertex( gfx::basic_vertex &Vertex, glm::dvec3 const &Origin, glm::vec3 const &Position, glm::vec3 const &Parallel, double const Distance ) const;
// displacement of a point by the unevenness, at a distance along the path
glm::dvec3 stray( glm::dvec3 const &Point, track_uneven::amounts const &Amount, double const Distance ) const;
// a point of the path at a distance, past its ends straight on: the polynomial would run off on a short curved path
glm::dvec3 point_extended( double const Distance ) const;
void design_position( double const fDistance, glm::dvec3 &position, glm::vec3 &rotation ) const;
public:
bool bCurve = false;
@@ -125,20 +127,17 @@ public:
// call before Init, it sets the density of the geometry
void
set_uneven( bool const Uneven, int const Path = 0 ) {
m_uneven = Uneven;
m_path = Path; }
glm::dvec3
end_point( int const End ) const {
return End == 0 ? Point1 : Point2; }
m_setting.uneven = Uneven;
m_setting.path = Path; }
// a point of the path and the unit vector across it in the plan
void
plan_frame( double const Distance, glm::dvec3 &Point, glm::dvec3 &Across ) const;
float
design_roll( int const End ) const {
return m_designrolls[ End ]; }
return m_setting.designrolls[ End ]; }
void
set_joint( int const End, std::optional<std::pair<glm::dvec3, glm::dvec3>> const &Joint, float const Roll ) {
m_joints[ End ] = Joint;
m_setting.joints[ End ] = Joint;
( End == 0 ? fRoll1 : fRoll2 ) = Roll; }
// second derivative of the displacement along the path; times speed squared: acceleration of an axle
glm::dvec3