mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 13:39:18 +02:00
continued refacoring: vehicles, events, memcells, tracks, traction, traction power sources; minor readability enhancements and bug fixes
This commit is contained in:
115
scene.h
115
scene.h
@@ -30,6 +30,18 @@ struct scratch_data {
|
||||
|
||||
std::stack<glm::dvec3> location_offset;
|
||||
glm::vec3 location_rotation;
|
||||
|
||||
struct trainset_data {
|
||||
|
||||
std::string name;
|
||||
std::string track;
|
||||
float offset { 0.f };
|
||||
float velocity { 0.f };
|
||||
std::vector<TDynamicObject *> vehicles;
|
||||
std::vector<std::int8_t> couplings;
|
||||
TDynamicObject * driver { nullptr };
|
||||
bool is_open { false };
|
||||
} trainset;
|
||||
};
|
||||
|
||||
// basic element of rudimentary partitioning scheme for the section. fixed size, no further subdivision
|
||||
@@ -40,6 +52,9 @@ class basic_cell {
|
||||
|
||||
public:
|
||||
// methods
|
||||
// legacy method, updates sounds and polls event launchers within radius around specified point
|
||||
void
|
||||
update();
|
||||
// adds provided shape to the cell
|
||||
void
|
||||
insert( shape_node Shape );
|
||||
@@ -52,18 +67,42 @@ public:
|
||||
// adds provided model instance to the cell
|
||||
void
|
||||
insert( TAnimModel *Instance );
|
||||
// registers provided path in the lookup directory of the cell
|
||||
void
|
||||
register_end( TTrack *Path );
|
||||
// registers provided traction piece in the lookup directory of the cell
|
||||
void
|
||||
register_end( TTraction *Traction );
|
||||
// find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance
|
||||
std::tuple<TDynamicObject *, float>
|
||||
find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled );
|
||||
// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint
|
||||
std::tuple<TTrack *, int>
|
||||
find( glm::dvec3 const &Point, TTrack const *Exclude );
|
||||
// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint
|
||||
std::tuple<TTraction *, int>
|
||||
find( glm::dvec3 const &Point, TTraction const *Exclude );
|
||||
// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece
|
||||
std::tuple<TTraction *, int, float>
|
||||
find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection );
|
||||
// sets center point of the cell
|
||||
void
|
||||
center( glm::dvec3 Center );
|
||||
// generates renderable version of held non-instanced geometry in specified geometry bank
|
||||
void
|
||||
create_geometry( geometrybank_handle const &Bank );
|
||||
// sets center point of the cell
|
||||
void
|
||||
center( glm::dvec3 Center );
|
||||
// provides access to bounding area data
|
||||
bounding_area const &
|
||||
area() const {
|
||||
return m_area; }
|
||||
|
||||
private:
|
||||
// types
|
||||
using shapenode_sequence = std::vector<shape_node>;
|
||||
using path_sequence = std::vector<TTrack *>;
|
||||
using path_set = std::set<TTrack *>;
|
||||
using traction_sequence = std::vector<TTraction *>;
|
||||
using traction_set = std::set<TTraction *>;
|
||||
using instance_sequence = std::vector<TAnimModel *>;
|
||||
// members
|
||||
scene::bounding_area m_area { glm::dvec3(), static_cast<float>( 0.5 * M_SQRT2 * EU07_CELLSIZE + 0.25 * EU07_CELLSIZE ) };
|
||||
@@ -75,6 +114,11 @@ private:
|
||||
instance_sequence m_instancesopaque;
|
||||
instance_sequence m_instancetranslucent;
|
||||
traction_sequence m_traction;
|
||||
// search helpers
|
||||
struct lookup_data {
|
||||
path_set paths;
|
||||
traction_set traction;
|
||||
} m_directories;
|
||||
};
|
||||
|
||||
// basic scene partitioning structure, holds terrain geometry and collection of cells
|
||||
@@ -84,6 +128,9 @@ class basic_section {
|
||||
|
||||
public:
|
||||
// methods
|
||||
// legacy method, updates sounds and polls event launchers within radius around specified point
|
||||
void
|
||||
update( glm::dvec3 const &Location, float const Radius );
|
||||
// adds provided shape to the section
|
||||
void
|
||||
insert( shape_node Shape );
|
||||
@@ -96,12 +143,34 @@ public:
|
||||
// adds provided model instance to the section
|
||||
void
|
||||
insert( TAnimModel *Instance );
|
||||
// generates renderable version of held non-instanced geometry
|
||||
// registers specified end point of the provided path in the lookup directory of the region
|
||||
void
|
||||
create_geometry();
|
||||
register_end( TTrack *Path, glm::dvec3 const &Point );
|
||||
// registers specified end point of the provided traction piece in the lookup directory of the region
|
||||
void
|
||||
register_end( TTraction *Traction, glm::dvec3 const &Point );
|
||||
// find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance
|
||||
std::tuple<TDynamicObject *, float>
|
||||
find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled );
|
||||
// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint
|
||||
std::tuple<TTrack *, int>
|
||||
find( glm::dvec3 const &Point, TTrack const *Exclude );
|
||||
// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint
|
||||
std::tuple<TTraction *, int>
|
||||
find( glm::dvec3 const &Point, TTraction const *Exclude );
|
||||
// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece
|
||||
std::tuple<TTraction *, int, float>
|
||||
find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection );
|
||||
// sets center point of the section
|
||||
void
|
||||
center( glm::dvec3 Center );
|
||||
// generates renderable version of held non-instanced geometry
|
||||
void
|
||||
create_geometry();
|
||||
// provides access to bounding area data
|
||||
bounding_area const &
|
||||
area() const {
|
||||
return m_area; }
|
||||
|
||||
private:
|
||||
// types
|
||||
@@ -134,6 +203,9 @@ public:
|
||||
// destructor
|
||||
~basic_region();
|
||||
// methods
|
||||
// legacy method, updates sounds and polls event launchers around camera
|
||||
void
|
||||
update();
|
||||
// inserts provided shape in the region
|
||||
void
|
||||
insert_shape( shape_node Shape, scratch_data &Scratchpad );
|
||||
@@ -146,17 +218,45 @@ public:
|
||||
// inserts provided instance of 3d model in the region
|
||||
void
|
||||
insert_instance( TAnimModel *Instance, scratch_data &Scratchpad );
|
||||
|
||||
// inserts provided sound in the region
|
||||
void
|
||||
insert_sound( TTextSound *Sound, scratch_data &Scratchpad );
|
||||
// find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance
|
||||
std::tuple<TDynamicObject *, float>
|
||||
find_vehicle( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled );
|
||||
// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint
|
||||
std::tuple<TTrack *, int>
|
||||
find_path( glm::dvec3 const &Point, TTrack const *Exclude );
|
||||
// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint
|
||||
std::tuple<TTraction *, int>
|
||||
find_traction( glm::dvec3 const &Point, TTraction const *Exclude );
|
||||
// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece
|
||||
std::tuple<TTraction *, int>
|
||||
find_traction( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection );
|
||||
// finds sections inside specified sphere. returns: list of sections
|
||||
std::vector<basic_section *> const &
|
||||
sections( glm::dvec3 const &Point, float const Radius );
|
||||
|
||||
private:
|
||||
// types
|
||||
using section_array = std::array<basic_section *, EU07_REGIONSIDESECTIONCOUNT * EU07_REGIONSIDESECTIONCOUNT>;
|
||||
|
||||
struct region_scratchpad {
|
||||
|
||||
std::vector<basic_section *> sections;
|
||||
};
|
||||
|
||||
// methods
|
||||
// registers specified end point of the provided path in the lookup directory of the region
|
||||
void
|
||||
register_path( TTrack *Path, glm::dvec3 const &Point );
|
||||
// registers specified end point of the provided traction piece in the lookup directory of the region
|
||||
void
|
||||
register_traction( TTraction *Traction, glm::dvec3 const &Point );
|
||||
// checks whether specified point is within boundaries of the region
|
||||
bool
|
||||
point_inside( glm::dvec3 const &Location );
|
||||
// trims provided shape to fit into a section, adds trimmed part at the end of provided list
|
||||
// legacy method, trims provided shape to fit into a section. adds trimmed part at the end of provided list, returns true if changes were made
|
||||
bool
|
||||
RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shapes );
|
||||
// provides access to section enclosing specified point
|
||||
@@ -165,6 +265,7 @@ private:
|
||||
|
||||
// members
|
||||
section_array m_sections;
|
||||
region_scratchpad m_scratchpad;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user