16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 00:29:19 +02:00

maintenance: minor code cleanup

This commit is contained in:
tmj-fstate
2017-10-30 02:34:54 +01:00
parent ffcd3b40c9
commit 9edf912405
11 changed files with 95 additions and 121 deletions

View File

@@ -413,14 +413,6 @@ TAnimModel::TAnimModel( scene::node_data const &Nodedata ) : basic_node( Nodedat
} }
} }
TAnimModel::TAnimModel() {
// TODO: wrap these in a tuple and move to underlying model
for( int index = 0; index < iMaxNumLights; ++index ) {
LightsOn[index] = LightsOff[index] = nullptr; // normalnie nie ma
lsLights[index] = ls_Off; // a jeśli są, to wyłączone
}
}
TAnimModel::~TAnimModel() TAnimModel::~TAnimModel()
{ {
delete pAdvanced; // nie ma zaawansowanej animacji delete pAdvanced; // nie ma zaawansowanej animacji

View File

@@ -126,7 +126,6 @@ class TAnimModel : public editor::basic_node {
public: public:
// constructors // constructors
TAnimModel( scene::node_data const &Nodedata ); TAnimModel( scene::node_data const &Nodedata );
TAnimModel();
// destructor // destructor
~TAnimModel(); ~TAnimModel();
// methods // methods

View File

@@ -21,16 +21,6 @@ http://mozilla.org/MPL/2.0/.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// legacy constructor
TMemCell::TMemCell(vector3 *p)
{
fValue1 = fValue2 = 0;
location(
p ? *p : glm::dvec3() ); // ustawienie współrzędnych, bo do TGroundNode nie ma dostępu
bCommand = false; // komenda wysłana
OnSent = NULL;
}
TMemCell::TMemCell( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} TMemCell::TMemCell( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ) void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask )

View File

@@ -20,8 +20,6 @@ public:
std::string asTrackName; // McZapkie-100302 - zeby nazwe toru na ktory jest Putcommand wysylane pamietac std::string asTrackName; // McZapkie-100302 - zeby nazwe toru na ktory jest Putcommand wysylane pamietac
TMemCell( scene::node_data const &Nodedata ); TMemCell( scene::node_data const &Nodedata );
// legacy constructor
TMemCell( Math3D::vector3 *p );
void void
UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ); UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask );

View File

@@ -130,12 +130,6 @@ void TIsolated::Modify(int i, TDynamicObject *o)
// tworzenie nowego odcinka ruchu // tworzenie nowego odcinka ruchu
TTrack::TTrack( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} TTrack::TTrack( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
// legacy constructor
TTrack::TTrack( std::string Name ) {
m_name = Name;
}
TTrack::~TTrack() TTrack::~TTrack()
{ // likwidacja odcinka { // likwidacja odcinka
if( eType == tt_Cross ) { if( eType == tt_Cross ) {
@@ -175,7 +169,9 @@ TTrack::sort_by_material( TTrack const *Left, TTrack const *Right ) {
TTrack * TTrack::Create400m(int what, double dx) TTrack * TTrack::Create400m(int what, double dx)
{ // tworzenie toru do wstawiania taboru podczas konwersji na E3D { // tworzenie toru do wstawiania taboru podczas konwersji na E3D
auto *trk = new TTrack( "auto_400m" ); scene::node_data nodedata;
nodedata.name = "auto_400m"; // track isn't visible so only name is needed
auto *trk = new TTrack( nodedata );
trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy
trk->Init(); // utworzenie segmentu trk->Init(); // utworzenie segmentu
@@ -191,7 +187,9 @@ TTrack * TTrack::NullCreate(int dir)
TTrack TTrack
*trk { nullptr }, *trk { nullptr },
*trk2 { nullptr }; *trk2 { nullptr };
trk = new TTrack( "auto_null" ); scene::node_data nodedata;
nodedata.name = "auto_null"; // track isn't visible so only name is needed
trk = new TTrack( nodedata );
trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
trk->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy trk->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy
float r1, r2; float r1, r2;
@@ -234,7 +232,7 @@ TTrack * TTrack::NullCreate(int dir)
trk->fVelocity = 20.0; // zawracanie powoli trk->fVelocity = 20.0; // zawracanie powoli
trk->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło narastająco trk->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło narastająco
trk->Init(); // utworzenie segmentu trk->Init(); // utworzenie segmentu
trk2 = new TTrack( "auto_null" ); trk2 = new TTrack( nodedata );
trk2->iCategoryFlag = trk2->iCategoryFlag =
(iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy
trk2->m_visible = false; trk2->m_visible = false;

View File

@@ -185,8 +185,6 @@ public:
TGroundNode *nFouling[ 2 ] = { nullptr, nullptr }; // współrzędne ukresu albo oporu kozła TGroundNode *nFouling[ 2 ] = { nullptr, nullptr }; // współrzędne ukresu albo oporu kozła
TTrack( scene::node_data const &Nodedata ); TTrack( scene::node_data const &Nodedata );
// legacy constructor
TTrack( std::string Name );
virtual ~TTrack(); virtual ~TTrack();
void Init(); void Init();

View File

@@ -91,11 +91,6 @@ sekcji z sąsiedniego przęsła).
*/ */
TTraction::TTraction( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} TTraction::TTraction( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
// legacy constructor
TTraction::TTraction( std::string Name ) {
m_name = Name;
}
glm::dvec3 LoadPoint( cParser &Input ) { glm::dvec3 LoadPoint( cParser &Input ) {
// pobranie współrzędnych punktu // pobranie współrzędnych punktu

View File

@@ -53,8 +53,6 @@ class TTraction : public editor::basic_node {
geometry_handle m_geometry; geometry_handle m_geometry;
TTraction( scene::node_data const &Nodedata ); TTraction( scene::node_data const &Nodedata );
// legacy constructor
TTraction( std::string Name );
void Load( cParser *parser, glm::dvec3 const &pOrigin ); void Load( cParser *parser, glm::dvec3 const &pOrigin );
// set origin point // set origin point

View File

@@ -22,10 +22,6 @@ http://mozilla.org/MPL/2.0/.
TTractionPowerSource::TTractionPowerSource( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} TTractionPowerSource::TTractionPowerSource( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
// legacy constructor // legacy constructor
TTractionPowerSource::TTractionPowerSource( std::string Name ) {
m_name = Name;
}
void TTractionPowerSource::Init(double const u, double const i) void TTractionPowerSource::Init(double const u, double const i)
{ // ustawianie zasilacza przy braku w scenerii { // ustawianie zasilacza przy braku w scenerii

View File

@@ -40,8 +40,6 @@ public:
bool bSection = false; // czy jest sekcją bool bSection = false; // czy jest sekcją
TTractionPowerSource( scene::node_data const &Nodedata ); TTractionPowerSource( scene::node_data const &Nodedata );
// legacy constructor
TTractionPowerSource( std::string Name );
void Init(double const u, double const i); void Init(double const u, double const i);
bool Load(cParser *parser); bool Load(cParser *parser);

View File

@@ -29,12 +29,14 @@ bool
operator==( lighting_data const &Left, lighting_data const &Right ) { operator==( lighting_data const &Left, lighting_data const &Right ) {
return ( ( Left.diffuse == Right.diffuse ) return ( ( Left.diffuse == Right.diffuse )
&& ( Left.ambient == Right.ambient ) && ( Left.ambient == Right.ambient )
&& ( Left.specular == Right.specular ) ); } && ( Left.specular == Right.specular ) );
}
inline inline
bool bool
operator!=( lighting_data const &Left, lighting_data const &Right ) { operator!=( lighting_data const &Left, lighting_data const &Right ) {
return !( Left == Right ); } return !( Left == Right );
}
namespace scene { namespace scene {
@@ -49,26 +51,6 @@ struct bounding_area {
radius( Radius ) radius( Radius )
{} {}
}; };
/*
enum nodetype {
unknown,
model,
triangles,
lines,
dynamic,
track,
traction,
powersource,
sound,
memorycell,
eventlauncher
};
class node_manager {
};
*/
struct node_data { struct node_data {
@@ -119,16 +101,13 @@ public:
compute_radius(); compute_radius();
// set visibility // set visibility
void void
visible( bool State ) { visible( bool State );
m_data.visible = State; }
// set origin point // set origin point
void void
origin( glm::dvec3 Origin ) { origin( glm::dvec3 Origin );
m_data.origin = Origin; }
// data access // data access
shapenode_data const & shapenode_data const &
data() const { data() const;
return m_data; }
private: private:
// members // members
@@ -136,6 +115,27 @@ private:
shapenode_data m_data; shapenode_data m_data;
}; };
// set visibility
inline
void
shape_node::visible( bool State ) {
m_data.visible = State;
}
// set origin point
inline
void
shape_node::origin( glm::dvec3 Origin ) {
m_data.origin = Origin;
}
// data access
inline
shape_node::shapenode_data const &
shape_node::data() const {
return m_data;
}
// holds a group of untextured lines // holds a group of untextured lines
class lines_node { class lines_node {
@@ -173,16 +173,13 @@ public:
compute_radius(); compute_radius();
// set visibility // set visibility
void void
visible( bool State ) { visible( bool State );
m_data.visible = State; }
// set origin point // set origin point
void void
origin( glm::dvec3 Origin ) { origin( glm::dvec3 Origin );
m_data.origin = Origin; }
// data access // data access
linesnode_data const & linesnode_data const &
data() const { data() const;
return m_data; }
private: private:
// members // members
@@ -190,6 +187,26 @@ private:
linesnode_data m_data; linesnode_data m_data;
}; };
// set visibility
inline
void
lines_node::visible( bool State ) {
m_data.visible = State;
}
// set origin point
inline
void
lines_node::origin( glm::dvec3 Origin ) {
m_data.origin = Origin;
}
// data access
inline
lines_node::linesnode_data const &
lines_node::data() const {
return m_data;
}
/* /*
// holds geometry for specific piece of track/road/waterway // holds geometry for specific piece of track/road/waterway
class path_node { class path_node {
@@ -238,39 +255,10 @@ private:
TTrack * m_path; TTrack * m_path;
}; };
*/ */
/*
// holds reference to memory cell
class memorycell_node {
friend class basic_region; // region might want to modify node content when it's being inserted
public:
// types
struct memorynode_data {
// placement and visibility
bounding_area area; // bounding area, in world coordinates
bool visible { false }; // visibility flag
};
// methods
// restores content of the node from provded input stream
// TODO: implement
memory_node &
deserialize( cParser &Input, node_data const &Nodedata );
void
cell( TMemCell *Cell ) {
m_memorycell = Cell; }
TMemCell *
cell() {
return m_memorycell; }
private:
// members
memorynode_data m_data;
TMemCell * m_memorycell;
};
*/
} // scene } // scene
namespace editor { namespace editor {
// base interface for nodes which can be actvated in scenario editor // base interface for nodes which can be actvated in scenario editor
@@ -278,28 +266,22 @@ struct basic_node {
public: public:
// constructor // constructor
basic_node() = default; // TODO: remove after refactor
basic_node( scene::node_data const &Nodedata ); basic_node( scene::node_data const &Nodedata );
// destructor // destructor
virtual ~basic_node() = default; virtual ~basic_node() = default;
// methods // methods
std::string const & std::string const &
name() const { name() const;
return m_name; }
void void
location( glm::dvec3 const Location ) { location( glm::dvec3 const Location );
m_area.center = Location; }
glm::dvec3 const & glm::dvec3 const &
location() const { location() const;
return m_area.center; };
float const & float const &
radius(); radius();
void void
visible( bool const Visible ) { visible( bool const Visible );
m_visible = Visible; }
bool bool
visible() const { visible() const;
return m_visible; }
protected: protected:
// methods // methods
@@ -313,6 +295,36 @@ protected:
std::string m_name; std::string m_name;
}; };
inline
std::string const &
basic_node::name() const {
return m_name;
}
inline
void
basic_node::location( glm::dvec3 const Location ) {
m_area.center = Location;
}
inline
glm::dvec3 const &
basic_node::location() const {
return m_area.center;
}
inline
void
basic_node::visible( bool const Visible ) {
m_visible = Visible;
}
inline
bool
basic_node::visible() const {
return m_visible;
}
} // editor } // editor
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------