mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 06:19:19 +02:00
feat(roads): junctions made by leading a road out of another, width and height set at road points
This commit is contained in:
@@ -107,11 +107,7 @@ class editor_mode : public application_mode
|
||||
std::vector<std::pair<TTrack *, editor_track::state>> tracks;
|
||||
std::vector<TTrack *> created;
|
||||
std::vector<TTrack *> removed;
|
||||
std::vector<std::pair<road_node *, road_node::state>> roads; // road pieces with what they were like before the change
|
||||
std::vector<road_node *> roads_created;
|
||||
std::vector<road_node *> roads_removed;
|
||||
std::vector<junction_node *> junctions_created;
|
||||
std::vector<junction_node *> junctions_removed;
|
||||
editor_road::record roads; // what a change of the roads comes to
|
||||
|
||||
};
|
||||
void push_snapshot(scene::basic_node *node, EditorSnapshot::Action Action = EditorSnapshot::Action::Move, std::string const &Serialized = std::string());
|
||||
@@ -489,13 +485,25 @@ class editor_mode : public application_mode
|
||||
bool m_track_drag_connected{true};
|
||||
|
||||
// roads: a menu and a window of their own, independent from the edit modes of the toolset
|
||||
// what a click of the build tool would make
|
||||
struct road_plan
|
||||
{
|
||||
std::vector<segment_data> pieces; // axes of the pieces, in the order they're laid
|
||||
editor_road::loose_end snap; // loose end of a road or arm of a junction the road is led to
|
||||
editor_road::branch start; // junction made, or given another arm, for a road led out of the side of a road or out of a junction
|
||||
bool hasstart{false};
|
||||
editor_road::branch end; // the same for a road led into the side of a road or into a junction
|
||||
bool hasend{false};
|
||||
std::string error; // why there's nothing to make
|
||||
};
|
||||
struct road_tool
|
||||
{
|
||||
bool window{false}; // the road window is open, the left mouse button belongs to its tools
|
||||
bool lanes{true}; // lanes of the roads are drawn as trajectories
|
||||
int tool{0}; // 0: select, 1: build, 2: junction
|
||||
int tool{0}; // 0: select, 1: build
|
||||
road_node *selected{nullptr};
|
||||
junction_node *junction{nullptr}; // selected junction
|
||||
std::vector<glm::dvec3> points; // selected points where the pieces meet or end
|
||||
road_node::state settings; // layout shown in the window: of the selected piece, or of the pieces about to be built
|
||||
bool whole{true}; // layout changes go to every piece of the road the selected one belongs to
|
||||
bool chain{false}; // the point to build from is set
|
||||
@@ -505,16 +513,17 @@ class editor_mode : public application_mode
|
||||
bool reversed{false}; // the pieces are laid from their ends, to carry on a road from its start
|
||||
double grade{0.0}; // slope the next piece has to start with, to carry on what it's attached to
|
||||
bool hasgrade{false};
|
||||
float offset{0.1f}; // height above the ground the roads and junctions are built at
|
||||
// the road being built leaves the side of a road, or a junction between its roads. the point to build from is the centre
|
||||
// of the junction, which gets made, or gets another arm, along with the first piece
|
||||
road_node *branchroad{nullptr};
|
||||
double branchat{0.0}; // value of the curve parameter of the axis of that road
|
||||
junction_node *branchjunction{nullptr};
|
||||
float offset{0.1f}; // height above the ground the roads are built at
|
||||
bool follow{true}; // built roads are led over the ground between the clicked points
|
||||
int kind{0}; // kind of the junctions being placed, an editor_road::junction_kind
|
||||
float crossingspeed{30.f}; // speed limit on the junctions being placed
|
||||
// what a click would make at the moment, worked out once a frame for display
|
||||
std::vector<segment_data> preview;
|
||||
junction_node::state previewjunction;
|
||||
bool hasjunction{false};
|
||||
editor_road::loose_end previewsnap;
|
||||
std::string previewerror;
|
||||
float crossingspeed{30.f}; // speed limit on the junctions being made
|
||||
road_plan plan; // what a click would make at the moment, worked out once a frame for display
|
||||
glm::dvec3 hover{0.0}; // point of a road or a junction under the cursor a road can be led out of
|
||||
bool hashover{false};
|
||||
glm::dvec3 mouse{0.0};
|
||||
std::string status;
|
||||
char surface[128]{};
|
||||
@@ -529,19 +538,21 @@ class editor_mode : public application_mode
|
||||
void road_click();
|
||||
void road_select(road_node *Road);
|
||||
void junction_select(junction_node *Junction);
|
||||
void junction_click();
|
||||
bool junction_preview(junction_node::state &State, editor_road::loose_end &Snap, std::string &Error) const;
|
||||
void road_apply();
|
||||
bool road_delete();
|
||||
bool road_split();
|
||||
void road_cancel();
|
||||
// sets the width of the road, or its height, at the selected points
|
||||
void road_point_width(float const Width);
|
||||
void road_point_height(double const Height);
|
||||
bool road_points_apply(std::vector<std::pair<road_node *, road_node::state>> const &Changes, std::size_t const Skipped);
|
||||
// Fresh: the ground is looked up anew instead of going by what was gathered for the previous frames
|
||||
std::vector<segment_data> road_preview(editor_road::loose_end &Snap, std::string &Error, bool const Fresh);
|
||||
void road_profile(std::vector<segment_data> &Pieces, editor_road::loose_end const &Snap, bool const Fresh);
|
||||
road_plan road_preview(bool const Fresh);
|
||||
// Firstgrade, Lastgrade: slopes the road has to start and end with, nullptr for none
|
||||
void road_profile(std::vector<segment_data> &Pieces, double const *Firstgrade, double const *Lastgrade, bool const Fresh);
|
||||
// height of the ground under each of the points, with the roads not taken for the ground. a point with nothing under it keeps its height
|
||||
std::vector<double> ground_heights(std::vector<glm::dvec3> const &Points, bool const Fresh);
|
||||
void push_road_snapshot(std::vector<std::pair<road_node *, road_node::state>> States, std::vector<road_node *> Created, std::vector<road_node *> Removed, std::vector<junction_node *> Junctionscreated = {},
|
||||
std::vector<junction_node *> Junctionsremoved = {});
|
||||
void push_road_snapshot(editor_road::record Record);
|
||||
void restore_road_snapshot(EditorSnapshot const &Snapshot, std::vector<EditorSnapshot> &Opposite, bool const Undo);
|
||||
road_tool m_roadtool;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user