17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 02:17:28 +01:00

fix(editor): the track shown while it's laid over the ground no longer holds up the frames: its grade line is fitted on a thread of its own, the line fitted a moment ago stretched over the track meanwhile, and the click takes the line fitted for the same ground instead of fitting it again; the terrain follows the tracks once the laying ends, not after each click of a chain

Fitting the grade line took 3 ms for 250 m of track, 30 ms for 1 km, 65 ms for 2 km and 200 ms for 4 km, and the preview of the lay tool and of the drag from a free end fitted it every frame, twice for the drag; on the terrain model the preview of some 800 m took 10 to 17 ms a frame, the cursor standing or not. Now the frame waits under 1.5 ms for 4 km. The formations of the tracks led into the terrain went through every chunk under them 0.3 s after each click, some 50 ms, while the cursor went on to the next point; they wait for the laying to end. The tracks laid and the terrain are the same as before.

Selftests: perf logs the longest frame and those over 33 ms, fittime the time of the fit by length, terrainhash a hash of the chunks in memory.
This commit is contained in:
maj00r
2026-10-24 18:00:21 +02:00
parent e35487f767
commit e322947300
12 changed files with 354 additions and 43 deletions

View File

@@ -39,6 +39,7 @@ http://mozilla.org/MPL/2.0/.
#include "editor/editorSpeed.hpp"
#include "editor/editorRoad.hpp"
#include "editor/editorProfile.hpp"
#include "editor/editorGroundFollow.hpp"
#include "editor/editorInfra.hpp"
#include "editor/editorGauge.hpp"
#include "editor/editorClips.hpp"
@@ -1512,6 +1513,8 @@ class editor_mode : public application_mode, private editor_track::observer, pri
bool start_extend(editor_track::snap_target const &End);
void finish_extend();
std::vector<segment_data> extend_pieces() const;
// the same for the track shown while it's dragged: its grade line fitted on the thread of the fitter, the frame not waiting for it
std::vector<segment_data> extend_preview() const;
// the free end of the path as the start of a new track; false if it isn't free or has no direction
static bool free_end(TTrack &Track, int const Path, bool const Atend, extend_tool &Tool);
// the free end new pieces are added at: the selected point if it's one, else the end, else the start
@@ -1732,6 +1735,10 @@ class editor_mode : public application_mode, private editor_track::observer, pri
static std::pair<double, double> trackbed(TTrack const *Style);
std::vector<double> bed_heights(std::vector<glm::dvec3> const &Points, std::vector<glm::dvec2> const &Directions, TTrack const *Style) const;
void follow_ground(std::vector<segment_data> &Pieces, double const Height0, double const Grade0, double const Height1, double const Grade1, TTrack const *Style) const;
ground_follow::grading laying_grading(TTrack const *Style) const;
// the grade lines of the tracks shown while they're laid are fitted on a thread of their own, not to hold up the frames
mutable ground_follow::fitter m_fitter;
mutable bool m_follow_preview{false};
glm::dvec3 lay_bed(glm::dvec3 const &Point);
std::optional<glm::dvec3> m_cursor_override;
bool sweep_grabs(glm::dvec3 const &Point);