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

use glm instead of Math3D in world

This commit is contained in:
docentYT
2026-04-27 00:36:03 +02:00
parent 1cfcf47788
commit ed28eff066
9 changed files with 101 additions and 113 deletions

View File

@@ -517,7 +517,7 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
std::tuple<TTrack *, int> std::tuple<TTrack *, int>
basic_cell::find( glm::dvec3 const &Point, TTrack const *Exclude ) const { basic_cell::find( glm::dvec3 const &Point, TTrack const *Exclude ) const {
Math3D::vector3 point { Point.x, Point.y, Point.z }; // sad workaround until math classes unification glm::dvec3 point{Point.x, Point.y, Point.z}; // sad workaround until math classes unification // TODO: Is it needed?
int endpointid; int endpointid;
for( auto *path : m_directories.paths ) { for( auto *path : m_directories.paths ) {

View File

@@ -59,12 +59,14 @@ double GetDistanceToEvent(TTrack const *track, basic_event const *event, double
double seg_len = scan_dir > 0 ? 0.0 : 1.0; double seg_len = scan_dir > 0 ? 0.0 : 1.0;
double const dzielnik = 1.0 / segment->GetLength();// rozdzielczosc mniej wiecej 1m double const dzielnik = 1.0 / segment->GetLength();// rozdzielczosc mniej wiecej 1m
int krok = 0; // krok obliczeniowy do sprawdzania czy odwracamy int krok = 0; // krok obliczeniowy do sprawdzania czy odwracamy
len2 = (pos_event - segment->FastGetPoint(seg_len)).LengthSquared(); auto temp = pos_event - segment->FastGetPoint(seg_len);
len2 = glm::dot(temp, temp);
do do
{ {
len1 = len2; len1 = len2;
seg_len += scan_dir > 0 ? dzielnik : -dzielnik; seg_len += scan_dir > 0 ? dzielnik : -dzielnik;
len2 = (pos_event - segment->FastGetPoint(seg_len)).LengthSquared(); temp = pos_event - segment->FastGetPoint(seg_len);
len2 = glm::dot(temp, temp);
++krok; ++krok;
} while ((len1 > len2) && (seg_len >= dzielnik && (seg_len <= (1.0 - dzielnik)))); } while ((len1 > len2) && (seg_len >= dzielnik && (seg_len <= (1.0 - dzielnik))));
//trzeba sprawdzić czy seg_len nie osiągnął skrajnych wartości, bo wtedy //trzeba sprawdzić czy seg_len nie osiągnął skrajnych wartości, bo wtedy

View File

@@ -37,9 +37,9 @@ TSegment::TSegment(TTrack *owner) :
pOwner( owner ) pOwner( owner )
{} {}
bool TSegment::Init(Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2) bool TSegment::Init(glm::dvec3 NewPoint1, glm::dvec3 NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2)
{ // wersja dla prostego - wyliczanie punktów kontrolnych { // wersja dla prostego - wyliczanie punktów kontrolnych
Math3D::vector3 dir; glm::dvec3 dir;
// NOTE: we're enforcing division also for straight track, to ensure dense enough mesh for per-vertex lighting // NOTE: we're enforcing division also for straight track, to ensure dense enough mesh for per-vertex lighting
/* /*
@@ -60,7 +60,7 @@ bool TSegment::Init(Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double
} }
}; };
bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, Math3D::vector3 NewCPointIn, Math3D::vector3 &NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2, bool bIsCurve) bool TSegment::Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 NewCPointIn, glm::dvec3 &NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2, bool bIsCurve)
{ // wersja uniwersalna (dla krzywej i prostego) { // wersja uniwersalna (dla krzywej i prostego)
Point1 = NewPoint1; Point1 = NewPoint1;
CPointOut = NewCPointOut; CPointOut = NewCPointOut;
@@ -107,7 +107,7 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
fLength = ComputeLength(); fLength = ComputeLength();
} }
else { else {
fLength = ( Point1 - Point2 ).Length(); fLength = glm::length(Point1 - Point2);
} }
if (fLength <= 0) { if (fLength <= 0) {
@@ -142,12 +142,12 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
return true; return true;
} }
Math3D::vector3 TSegment::GetFirstDerivative(double const fTime) const glm::dvec3 TSegment::GetFirstDerivative(double const fTime) const
{ {
double fOmTime = 1.0 - fTime; double fOmTime = 1.0 - fTime;
double fPowTime = fTime; double fPowTime = fTime;
Math3D::vector3 kResult = fOmTime * (CPointOut - Point1); glm::dvec3 kResult = fOmTime * (CPointOut - Point1);
// int iDegreeM1 = 3 - 1; // int iDegreeM1 = 3 - 1;
@@ -170,14 +170,14 @@ double TSegment::RombergIntegral(double const fA, double const fB) const
double ms_apfRom[2][ms_iOrder]; double ms_apfRom[2][ms_iOrder];
ms_apfRom[0][0] = ms_apfRom[0][0] =
0.5 * fH * ((GetFirstDerivative(fA).Length()) + (GetFirstDerivative(fB).Length())); 0.5 * fH * ((glm::length(GetFirstDerivative(fA))) + glm::length(GetFirstDerivative(fB)));
for (int i0 = 2, iP0 = 1; i0 <= ms_iOrder; i0++, iP0 *= 2, fH *= 0.5) for (int i0 = 2, iP0 = 1; i0 <= ms_iOrder; i0++, iP0 *= 2, fH *= 0.5)
{ {
// approximations via the trapezoid rule // approximations via the trapezoid rule
double fSum = 0.0; double fSum = 0.0;
int i1; int i1;
for (i1 = 1; i1 <= iP0; i1++) for (i1 = 1; i1 <= iP0; i1++)
fSum += (GetFirstDerivative(fA + fH * (i1 - 0.5)).Length()); fSum += glm::length(GetFirstDerivative(fA + fH * (i1 - 0.5)));
// Richardson extrapolation // Richardson extrapolation
ms_apfRom[1][0] = 0.5 * (ms_apfRom[0][0] + fH * fSum); ms_apfRom[1][0] = 0.5 * (ms_apfRom[0][0] + fH * fSum);
@@ -207,7 +207,7 @@ double TSegment::GetTFromS(double const s) const
if( std::abs( fDifference ) < fTolerance ) { if( std::abs( fDifference ) < fTolerance ) {
return fTime; return fTime;
} }
fTime -= fDifference / GetFirstDerivative(fTime).Length(); fTime -= fDifference / glm::length(GetFirstDerivative(fTime));
++iteration; ++iteration;
} }
while( iteration < 10 ); // arbitrary limit while( iteration < 10 ); // arbitrary limit
@@ -220,12 +220,12 @@ double TSegment::GetTFromS(double const s) const
return fTime; return fTime;
}; };
Math3D::vector3 TSegment::RaInterpolate(double const t) const glm::dvec3 TSegment::RaInterpolate(double const t) const
{ // wyliczenie XYZ na krzywej Beziera z użyciem współczynników { // wyliczenie XYZ na krzywej Beziera z użyciem współczynników
return t * (t * (t * vA + vB) + vC) + Point1; // 9 mnożeń, 9 dodawań return t * (t * (t * vA + vB) + vC) + Point1; // 9 mnożeń, 9 dodawań
}; };
Math3D::vector3 TSegment::RaInterpolate0(double const t) const glm::dvec3 TSegment::RaInterpolate0(double const t) const
{ // wyliczenie XYZ na krzywej Beziera, na użytek liczenia długości nie jest dodawane Point1 { // wyliczenie XYZ na krzywej Beziera, na użytek liczenia długości nie jest dodawane Point1
return t * (t * (t * vA + vB) + vC); // 9 mnożeń, 6 dodawań return t * (t * (t * vA + vB) + vC); // 9 mnożeń, 6 dodawań
}; };
@@ -237,15 +237,15 @@ double TSegment::ComputeLength() const // McZapkie-150503: dlugosc miedzy punkta
// poprzedniej // poprzedniej
// Ra: ewentualnie rozpoznać łuk okręgu płaskiego i liczyć ze wzoru na długość łuku // Ra: ewentualnie rozpoznać łuk okręgu płaskiego i liczyć ze wzoru na długość łuku
double t, l = 0; double t, l = 0;
Math3D::vector3 last = Math3D::vector3(0, 0, 0); // długość liczona po przesunięciu odcinka do początku układu glm::dvec3 last{0, 0, 0}; // długość liczona po przesunięciu odcinka do początku układu
Math3D::vector3 tmp = Point2 - Point1; glm::dvec3 tmp = Point2 - Point1;
int m = 20.0 * tmp.Length(); // było zawsze do 10000, teraz jest liczone odcinkami po około 5cm int m = 20.0 * glm::length(tmp); // było zawsze do 10000, teraz jest liczone odcinkami po około 5cm
for (int i = 1; i <= m; i++) for (int i = 1; i <= m; i++)
{ {
t = double(i) / double(m); // wyznaczenie parametru na krzywej z przedziału (0,1> t = double(i) / double(m); // wyznaczenie parametru na krzywej z przedziału (0,1>
// tmp=Interpolate(t,p1,cp1,cp2,p2); // tmp=Interpolate(t,p1,cp1,cp2,p2);
tmp = RaInterpolate0(t); // obliczenie punktu dla tego parametru tmp = RaInterpolate0(t); // obliczenie punktu dla tego parametru
t = Math3D::vector3(tmp - last).Length(); // obliczenie długości wektora t = glm::length(tmp - last); // obliczenie długości wektora
l += t; // zwiększenie wyliczanej długości l += t; // zwiększenie wyliczanej długości
last = tmp; last = tmp;
} }
@@ -296,7 +296,7 @@ TSegment::find_nearest_point( glm::dvec3 const &Point ) const {
const double fDirectionOffset = 0.1; // długość wektora do wyliczenia kierunku const double fDirectionOffset = 0.1; // długość wektora do wyliczenia kierunku
Math3D::vector3 TSegment::GetDirection(double const fDistance) const glm::dvec3 TSegment::GetDirection(double const fDistance) const
{ // takie toporne liczenie pochodnej dla podanego dystansu od Point1 { // takie toporne liczenie pochodnej dla podanego dystansu od Point1
double t1 = GetTFromS(fDistance - fDirectionOffset); double t1 = GetTFromS(fDistance - fDirectionOffset);
if (t1 <= 0.0) if (t1 <= 0.0)
@@ -307,7 +307,7 @@ Math3D::vector3 TSegment::GetDirection(double const fDistance) const
return (FastGetPoint(t2) - FastGetPoint(t1)); return (FastGetPoint(t2) - FastGetPoint(t1));
} }
Math3D::vector3 TSegment::FastGetDirection(double fDistance, double fOffset) glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset)
{ // takie toporne liczenie pochodnej dla parametru 0.0÷1.0 { // takie toporne liczenie pochodnej dla parametru 0.0÷1.0
double t1 = fDistance - fOffset; double t1 = fDistance - fOffset;
if (t1 <= 0.0) if (t1 <= 0.0)
@@ -338,8 +338,7 @@ Math3D::vector3 TSegment::GetPoint(double const fDistance) const
}; };
*/ */
// ustalenie pozycji osi na torze, przechyłki, pochylenia i kierunku jazdy // ustalenie pozycji osi na torze, przechyłki, pochylenia i kierunku jazdy
void TSegment::RaPositionGet(double const fDistance, Math3D::vector3 &p, Math3D::vector3 &a) const { void TSegment::RaPositionGet(double const fDistance, glm::dvec3 &p, glm::dvec3 &a) const {
if (bCurve) { if (bCurve) {
// można by wprowadzić uproszczony wzór dla okręgów płaskich // można by wprowadzić uproszczony wzór dla okręgów płaskich
auto const t = GetTFromS(fDistance); // aproksymacja dystansu na krzywej Beziera na parametr (t) auto const t = GetTFromS(fDistance); // aproksymacja dystansu na krzywej Beziera na parametr (t)
@@ -364,7 +363,7 @@ void TSegment::RaPositionGet(double const fDistance, Math3D::vector3 &p, Math3D:
} }
}; };
Math3D::vector3 TSegment::FastGetPoint(double const t) const glm::dvec3 TSegment::FastGetPoint(double const t) const
{ {
// return (bCurve?Interpolate(t,Point1,CPointOut,CPointIn,Point2):((1.0-t)*Point1+(t)*Point2)); // return (bCurve?Interpolate(t,Point1,CPointOut,CPointIn,Point2):((1.0-t)*Point1+(t)*Point2));
return ( return (
@@ -373,7 +372,7 @@ Math3D::vector3 TSegment::FastGetPoint(double const t) const
interpolate( Point1, Point2, t ) ); interpolate( Point1, Point2, t ) );
} }
bool TSegment::RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Origin, const gfx::vertex_array &ShapePoints, bool const Transition, double fTextureLength, double Texturescale, int iSkip, int iEnd, std::pair<float, float> fOffsetX, glm::vec3 **p, bool bRender) bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, const gfx::vertex_array &ShapePoints, bool const Transition, double fTextureLength, double Texturescale, int iSkip, int iEnd, std::pair<float, float> fOffsetX, glm::vec3 **p, bool bRender)
{ // generowanie trójkątów dla odcinka trajektorii ruchu { // generowanie trójkątów dla odcinka trajektorii ruchu
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku // standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli podany jest przekrój końcowy // po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli podany jest przekrój końcowy

View File

@@ -10,9 +10,9 @@ http://mozilla.org/MPL/2.0/.
#pragma once #pragma once
#include "utilities/Classes.h" #include "utilities/Classes.h"
#include "utilities/dumb3d.h"
#include "rendering/geometrybank.h" #include "rendering/geometrybank.h"
#include "utilities/utilities.h" #include "utilities/utilities.h"
#include <glm/glm.hpp>
struct map_colored_paths { struct map_colored_paths {
std::vector<gfx::geometrybank_handle> switches; std::vector<gfx::geometrybank_handle> switches;
@@ -42,7 +42,7 @@ struct segment_data {
class TSegment class TSegment
{ // aproksymacja toru (zwrotnica ma dwa takie, jeden z nich jest aktywny) { // aproksymacja toru (zwrotnica ma dwa takie, jeden z nich jest aktywny)
private: private:
Math3D::vector3 Point1, CPointOut, CPointIn, Point2; glm::dvec3 Point1, CPointOut, CPointIn, Point2;
float float
fRoll1 { 0.f }, fRoll1 { 0.f },
fRoll2 { 0.f }; // przechyłka na końcach fRoll2 { 0.f }; // przechyłka na końcach
@@ -52,63 +52,54 @@ class TSegment
int iSegCount = 0; // ilość odcinków do rysowania krzywej int iSegCount = 0; // ilość odcinków do rysowania krzywej
double fDirection = 0.0; // Ra: kąt prostego w planie; dla łuku kąt od Point1 double fDirection = 0.0; // Ra: kąt prostego w planie; dla łuku kąt od Point1
double fStoop = 0.0; // Ra: kąt wzniesienia; dla łuku od Point1 double fStoop = 0.0; // Ra: kąt wzniesienia; dla łuku od Point1
Math3D::vector3 vA, vB, vC; // współczynniki wielomianów trzeciego stopnia vD==Point1 glm::dvec3 vA, vB, vC; // współczynniki wielomianów trzeciego stopnia vD==Point1
TTrack *pOwner = nullptr; // wskaźnik na właściciela TTrack *pOwner = nullptr; // wskaźnik na właściciela
Math3D::vector3 glm::dvec3 GetFirstDerivative(double const fTime) const;
GetFirstDerivative(double const fTime) const; double RombergIntegral(double const fA, double const fB) const;
double double GetTFromS(double const s) const;
RombergIntegral(double const fA, double const fB) const; glm::dvec3 RaInterpolate(double const t) const;
double glm::dvec3 RaInterpolate0(double const t) const;
GetTFromS(double const s) const;
Math3D::vector3
RaInterpolate(double const t) const;
Math3D::vector3
RaInterpolate0(double const t) const;
public: public:
bool bCurve = false; bool bCurve = false;
TSegment(TTrack *owner); TSegment(TTrack *owner);
bool bool Init(glm::dvec3 NewPoint1, glm::dvec3 NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0);
Init( Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0); bool Init(glm::dvec3 &NewPoint1, glm::dvec3 NewCPointOut, glm::dvec3 NewCPointIn, glm::dvec3 &NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true);
bool
Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, Math3D::vector3 NewCPointIn, Math3D::vector3 &NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true);
double double
ComputeLength() const; // McZapkie-150503 ComputeLength() const; // McZapkie-150503
// finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1 // finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1
double double
find_nearest_point( glm::dvec3 const &Point ) const; find_nearest_point( glm::dvec3 const &Point ) const;
inline inline
Math3D::vector3 glm::dvec3
GetDirection1() const { GetDirection1() const {
return bCurve ? CPointOut - Point1 : CPointOut; }; return bCurve ? CPointOut - Point1 : CPointOut; };
inline inline
Math3D::vector3 glm::dvec3
GetDirection2() const { GetDirection2() const {
return bCurve ? CPointIn - Point2 : CPointIn; }; return bCurve ? CPointIn - Point2 : CPointIn; };
Math3D::vector3 glm::dvec3
GetDirection(double const fDistance) const; GetDirection(double const fDistance) const;
inline inline
Math3D::vector3 glm::dvec3
GetDirection() const { GetDirection() const {
return CPointOut; }; return CPointOut; };
Math3D::vector3 glm::dvec3
FastGetDirection(double const fDistance, double const fOffset); FastGetDirection(double const fDistance, double const fOffset);
/* /*
Math3D::vector3 Math3D::vector3
GetPoint(double const fDistance) const; GetPoint(double const fDistance) const;
*/ */
void void RaPositionGet(double const fDistance, glm::dvec3 &p, glm::dvec3 &a) const;
RaPositionGet(double const fDistance, Math3D::vector3 &p, Math3D::vector3 &a) const; glm::dvec3 FastGetPoint(double const t) const;
Math3D::vector3
FastGetPoint(double const t) const;
inline inline
Math3D::vector3 glm::dvec3
FastGetPoint_0() const { FastGetPoint_0() const {
return Point1; }; return Point1; };
inline inline
Math3D::vector3 glm::dvec3
FastGetPoint_1() const { FastGetPoint_1() const {
return Point2; }; return Point2; };
inline inline
@@ -123,7 +114,7 @@ public:
r2 = fRoll2; } r2 = fRoll2; }
bool bool
RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Origin, gfx::vertex_array const &ShapePoints, bool const Transition, double fTextureLength, double Texturescale = 1.0, int iSkip = 0, int iEnd = 0, std::pair<float, float> fOffsetX = {0.f, 0.f}, glm::vec3 **p = nullptr, bool bRender = true ); RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin, gfx::vertex_array const &ShapePoints, bool const Transition, double fTextureLength, double Texturescale = 1.0, int iSkip = 0, int iEnd = 0, std::pair<float, float> fOffsetX = {0.f, 0.f}, glm::vec3 **p = nullptr, bool bRender = true );
/* /*
void void
Render(); Render();

View File

@@ -17,15 +17,14 @@ void TSpring::Init(double nKs, double nKd) {
kd = Kd; kd = Kd;
} }
Math3D::vector3 TSpring::ComputateForces( Math3D::vector3 const &pPosition1, Math3D::vector3 const &pPosition2) { glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) {
glm::vec3 springForce;
Math3D::vector3 springForce;
// p1 = &system[spring->p1]; // p1 = &system[spring->p1];
// p2 = &system[spring->p2]; // p2 = &system[spring->p2];
// VectorDifference(&p1->pos,&p2->pos,&deltaP); // Vector distance // VectorDifference(&p1->pos,&p2->pos,&deltaP); // Vector distance
auto deltaP = pPosition1 - pPosition2; auto deltaP = pPosition1 - pPosition2;
// dist = VectorLength(&deltaP); // Magnitude of deltaP // dist = VectorLength(&deltaP); // Magnitude of deltaP
auto dist = deltaP.Length(); auto dist = glm::length(deltaP);
if( dist > restLen ) { if( dist > restLen ) {
// Hterm = (dist - spring->restLen) * spring->Ks; // Ks * (dist - rest) // Hterm = (dist - spring->restLen) * spring->Ks; // Ks * (dist - rest)
@@ -35,7 +34,7 @@ Math3D::vector3 TSpring::ComputateForces( Math3D::vector3 const &pPosition1, Mat
auto deltaV = pPosition1 - pPosition2; auto deltaV = pPosition1 - pPosition2;
// Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term // Dterm = (DotProduct(&deltaV,&deltaP) * spring->Kd) / dist; // Damping Term
auto Dterm = (DotProduct(deltaV,deltaP) * Kd) / dist; auto Dterm = (glm::dot(deltaV,deltaP) * Kd) / dist;
//Dterm = 0; //Dterm = 0;
// ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector // ScaleVector(&deltaP,1.0f / dist, &springForce); // Normalize Distance Vector

View File

@@ -10,7 +10,6 @@ http://mozilla.org/MPL/2.0/.
#ifndef ParticlesH #ifndef ParticlesH
#define ParticlesH #define ParticlesH
#include "utilities/dumb3d.h"
/* /*
#define STATIC_THRESHOLD 0.17f #define STATIC_THRESHOLD 0.17f
const double m_Kd = 0.02f; // DAMPING FACTOR const double m_Kd = 0.02f; // DAMPING FACTOR
@@ -28,7 +27,7 @@ public:
// void Init(TParticnp1, TParticle *np2, double nKs= 0.5f, double nKd= 0.002f, // void Init(TParticnp1, TParticle *np2, double nKs= 0.5f, double nKd= 0.002f,
// double nrestLen= -1.0f); // double nrestLen= -1.0f);
void Init(double nKs = 0.5f, double nKd = 0.002f); void Init(double nKs = 0.5f, double nKd = 0.002f);
Math3D::vector3 ComputateForces( Math3D::vector3 const &pPosition1, Math3D::vector3 const &pPosition2); glm::dvec3 ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2);
//private: //private:
// members // members
double restLen { 0.01 }; // LENGTH OF SPRING AT REST double restLen { 0.01 }; // LENGTH OF SPRING AT REST

View File

@@ -23,7 +23,6 @@ http://mozilla.org/MPL/2.0/.
#include "vehicle/DynObj.h" #include "vehicle/DynObj.h"
#include "vehicle/Driver.h" #include "vehicle/Driver.h"
#include "model/AnimModel.h" #include "model/AnimModel.h"
#include "world/Track.h"
#include "utilities/Timer.h" #include "utilities/Timer.h"
#include "utilities/Logs.h" #include "utilities/Logs.h"
#include "rendering/renderer.h" #include "rendering/renderer.h"
@@ -218,7 +217,7 @@ TTrack * TTrack::Create400m(int what, double dx)
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
trk->Segment->Init( Math3D::vector3( -dx, 0, 0 ), Math3D::vector3( -dx, 0, 400 ), 10.0, 0, 0 ); // prosty trk->Segment->Init(glm::dvec3(-dx, 0, 0), glm::dvec3(-dx, 0, 400), 10.0, 0, 0); // prosty
trk->location( glm::dvec3{ -dx, 0, 200 } ); //środek, aby się mogło wyświetlić trk->location( glm::dvec3{ -dx, 0, 200 } ); //środek, aby się mogło wyświetlić
simulation::Paths.insert( trk ); simulation::Paths.insert( trk );
simulation::Region->insert( trk ); simulation::Region->insert( trk );
@@ -237,7 +236,7 @@ TTrack * TTrack::NullCreate(int dir)
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;
Segment->GetRolls(r1, r2); // pobranie przechyłek na początku toru Segment->GetRolls(r1, r2); // pobranie przechyłek na początku toru
Math3D::vector3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu glm::dvec3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu
if (iCategoryFlag & 1) if (iCategoryFlag & 1)
{ // tylko dla kolei { // tylko dla kolei
trk->iDamageFlag = 128; // wykolejenie trk->iDamageFlag = 128; // wykolejenie
@@ -247,21 +246,21 @@ TTrack * TTrack::NullCreate(int dir)
{ //łączenie z nowym torem { //łączenie z nowym torem
case 0: case 0:
p1 = Segment->FastGetPoint_0(); p1 = Segment->FastGetPoint_0();
p2 = p1 - 450.0 * Normalize(Segment->GetDirection1()); p2 = p1 - 450.0 * glm::normalize(Segment->GetDirection1());
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
trk->Segment->Init(p1, p2, 5, -RadToDeg(r1), 70.0); trk->Segment->Init(p1, p2, 5, -RadToDeg(r1), 70.0);
ConnectPrevPrev(trk, 0); ConnectPrevPrev(trk, 0);
break; break;
case 1: case 1:
p1 = Segment->FastGetPoint_1(); p1 = Segment->FastGetPoint_1();
p2 = p1 - 450.0 * Normalize(Segment->GetDirection2()); p2 = p1 - 450.0 * glm::normalize(Segment->GetDirection2());
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0); trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0);
ConnectNextPrev(trk, 0); ConnectNextPrev(trk, 0);
break; break;
case 3: // na razie nie możliwe case 3: // na razie nie możliwe
p1 = SwitchExtension->Segments[1]->FastGetPoint_1(); // koniec toru drugiego zwrotnicy p1 = SwitchExtension->Segments[1]->FastGetPoint_1(); // koniec toru drugiego zwrotnicy
p2 = p1 - 450.0 * Normalize( SwitchExtension->Segments[1]->GetDirection2()); // przedłużenie na wprost p2 = p1 - 450.0 * glm::normalize(SwitchExtension->Segments[1]->GetDirection2()); // przedłużenie na wprost
trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0); // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
ConnectNextPrev(trk, 0); ConnectNextPrev(trk, 0);
// trk->ConnectPrevNext(trk,dir); // trk->ConnectPrevNext(trk,dir);
@@ -288,24 +287,24 @@ TTrack * TTrack::NullCreate(int dir)
{ //łączenie z nowym torem { //łączenie z nowym torem
case 0: case 0:
p1 = Segment->FastGetPoint_0(); p1 = Segment->FastGetPoint_0();
cv1 = -20.0 * Normalize(Segment->GetDirection1()); // pierwszy wektor kontrolny cv1 = -20.0 * glm::normalize(Segment->GetDirection1()); // pierwszy wektor kontrolny
p2 = p1 + cv1 + cv1; // 40m p2 = p1 + cv1 + cv1; // 40m
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
trk->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(-cv1.z, cv1.y, cv1.x), p2, 2, -RadToDeg(r1), 0.0); trk->Segment->Init(p1, p1 + cv1, p2 + glm::dvec3(-cv1.z, cv1.y, cv1.x), p2, 2, -RadToDeg(r1), 0.0);
ConnectPrevPrev(trk, 0); ConnectPrevPrev(trk, 0);
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
trk2->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(cv1.z, cv1.y, -cv1.x), p2, 2, -RadToDeg(r1), 0.0); trk2->Segment->Init(p1, p1 + cv1, p2 + glm::dvec3(cv1.z, cv1.y, -cv1.x), p2, 2, -RadToDeg(r1), 0.0);
trk2->iPrevDirection = 0; // zwrotnie do tego samego odcinka trk2->iPrevDirection = 0; // zwrotnie do tego samego odcinka
break; break;
case 1: case 1:
p1 = Segment->FastGetPoint_1(); p1 = Segment->FastGetPoint_1();
cv1 = -20.0 * Normalize(Segment->GetDirection2()); // pierwszy wektor kontrolny cv1 = -20.0 * glm::normalize(Segment->GetDirection2()); // pierwszy wektor kontrolny
p2 = p1 + cv1 + cv1; p2 = p1 + cv1 + cv1;
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
trk->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(-cv1.z, cv1.y, cv1.x), p2, 2, RadToDeg(r2), 0.0); trk->Segment->Init(p1, p1 + cv1, p2 + glm::dvec3(-cv1.z, cv1.y, cv1.x), p2, 2, RadToDeg(r2), 0.0);
ConnectNextPrev(trk, 0); ConnectNextPrev(trk, 0);
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce // bo prosty, kontrolne wyliczane przy zmiennej przechyłce
trk2->Segment->Init(p1, p1 + cv1, p2 + Math3D::vector3(cv1.z, cv1.y, -cv1.x), p2, 2, RadToDeg(r2), 0.0); trk2->Segment->Init(p1, p1 + cv1, p2 + glm::dvec3(cv1.z, cv1.y, -cv1.x), p2, 2, RadToDeg(r2), 0.0);
trk2->iPrevDirection = 1; // zwrotnie do tego samego odcinka trk2->iPrevDirection = 1; // zwrotnie do tego samego odcinka
break; break;
} }
@@ -387,7 +386,7 @@ void TTrack::ConnectNextNext(TTrack *pTrack, int typ)
void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin) void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
{ // pobranie obiektu trajektorii ruchu { // pobranie obiektu trajektorii ruchu
Math3D::vector3 pt, vec, p1, p2, cp1, cp2, p3, p4, cp3, cp4; // dodatkowe punkty potrzebne do skrzyżowań glm::dvec3 pt, vec, p1, p2, cp1, cp2, p3, p4, cp3, cp4; // dodatkowe punkty potrzebne do skrzyżowań
double a1, a2, r1, r2, r3, r4; double a1, a2, r1, r2, r3, r4;
std::string str; std::string str;
size_t i; //,state; //Ra: teraz już nie ma początkowego stanu zwrotnicy we wpisie size_t i; //,state; //Ra: teraz już nie ma początkowego stanu zwrotnicy we wpisie
@@ -560,10 +559,10 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
// na przechyłce doliczyć jeszcze pół przechyłki // na przechyłce doliczyć jeszcze pół przechyłki
} }
if( ( ( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ).Length() < 0.02 ) if( (glm::length(( p1 + p1 + p2 ) / 3.0 - p1 - cp1) < 0.02 )
|| ( ( ( p1 + p2 + p2 ) / 3.0 - p2 + cp1 ).Length() < 0.02 ) ) { || ( glm::length(( p1 + p2 + p2 ) / 3.0 - p2 + cp1) < 0.02 ) ) {
// "prostowanie" prostych z kontrolnymi, dokładność 2cm // "prostowanie" prostych z kontrolnymi, dokładność 2cm
cp1 = cp2 = Math3D::vector3( 0, 0, 0 ); cp1 = cp2 = glm::dvec3(0, 0, 0);
} }
if( fRadius != 0 ) { if( fRadius != 0 ) {
@@ -576,22 +575,22 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
} }
else { else {
// HACK: crude check whether claimed straight is an actual straight piece // HACK: crude check whether claimed straight is an actual straight piece
if( ( cp1 == Math3D::vector3() ) if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
&& ( cp2 == Math3D::vector3() ) ) { {
segsize = 10.0; // for straights, 10m per segment works good enough segsize = 10.0; // for straights, 10m per segment works good enough
} }
else { else {
// HACK: divide roughly in 10 segments. // HACK: divide roughly in 10 segments.
segsize = segsize =
clamp( clamp(
( p1 - p2 ).Length() * 0.1, glm::length( p1 - p2 ) * 0.1,
2.0 / Global.SplineFidelity, 2.0 / Global.SplineFidelity,
10.0 / Global.SplineFidelity ); 10.0 / Global.SplineFidelity );
} }
} }
if( ( cp1 == Math3D::vector3( 0, 0, 0 ) ) if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
&& ( cp2 == Math3D::vector3( 0, 0, 0 ) ) ) { {
// Ra: hm, czasem dla prostego są podane... // Ra: hm, czasem dla prostego są podane...
// gdy prosty, kontrolne wyliczane przy zmiennej przechyłce // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce
Segment->Init( p1, p2, segsize, r1, r2 ); Segment->Init( p1, p2, segsize, r1, r2 );
@@ -656,10 +655,10 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if( eType != tt_Cross ) { if( eType != tt_Cross ) {
// dla skrzyżowań muszą być podane kontrolne // dla skrzyżowań muszą być podane kontrolne
if( ( ( ( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ).Length() < 0.02 ) if( ( glm::length(( p1 + p1 + p2 ) / 3.0 - p1 - cp1 ) < 0.02 )
|| ( ( ( p1 + p2 + p2 ) / 3.0 - p2 + cp1 ).Length() < 0.02 ) ) { || ( glm::length(( p1 + p2 + p2 ) / 3.0 - p2 + cp1 ) < 0.02 ) ) {
// "prostowanie" prostych z kontrolnymi, dokładność 2cm // "prostowanie" prostych z kontrolnymi, dokładność 2cm
cp1 = cp2 = Math3D::vector3( 0, 0, 0 ); cp1 = cp2 = glm::dvec3(0, 0, 0);
} }
} }
@@ -673,22 +672,22 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
} }
else { else {
// HACK: crude check whether claimed straight is an actual straight piece // HACK: crude check whether claimed straight is an actual straight piece
if( ( cp1 == Math3D::vector3() ) if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
&& ( cp2 == Math3D::vector3() ) ) { {
segsize = 10.0; // for straights, 10m per segment works good enough segsize = 10.0; // for straights, 10m per segment works good enough
} }
else { else {
// HACK: divide roughly in 10 segments. // HACK: divide roughly in 10 segments.
segsize = segsize =
clamp( clamp(
( p1 - p2 ).Length() * 0.1, glm::length( p1 - p2 ) * 0.1,
2.0 / Global.SplineFidelity, 2.0 / Global.SplineFidelity,
10.0 / Global.SplineFidelity ); 10.0 / Global.SplineFidelity );
} }
} }
if( ( cp1 == Math3D::vector3( 0, 0, 0 ) ) if ((cp1 == glm::dvec3()) && (cp2 == glm::dvec3()))
&& ( cp2 == Math3D::vector3( 0, 0, 0 ) ) ) { {
// Ra: hm, czasem dla prostego są podane... // Ra: hm, czasem dla prostego są podane...
// gdy prosty, kontrolne wyliczane przy zmiennej przechyłce // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce
SwitchExtension->Segments[ 0 ]->Init( p1, p2, segsize, r1, r2 ); SwitchExtension->Segments[ 0 ]->Init( p1, p2, segsize, r1, r2 );
@@ -720,10 +719,10 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if( eType != tt_Cross ) { if( eType != tt_Cross ) {
// dla skrzyżowań muszą być podane kontrolne // dla skrzyżowań muszą być podane kontrolne
if( ( ( ( p3 + p3 + p4 ) / 3.0 - p3 - cp3 ).Length() < 0.02 ) if( ( glm::length(( p3 + p3 + p4 ) / 3.0 - p3 - cp3) < 0.02 )
|| ( ( ( p3 + p4 + p4 ) / 3.0 - p4 + cp3 ).Length() < 0.02 ) ) { || ( glm::length(( p3 + p4 + p4 ) / 3.0 - p4 + cp3) < 0.02 ) ) {
// "prostowanie" prostych z kontrolnymi, dokładność 2cm // "prostowanie" prostych z kontrolnymi, dokładność 2cm
cp3 = cp4 = Math3D::vector3( 0, 0, 0 ); cp3 = cp4 = glm::dvec3(0, 0, 0);
} }
} }
@@ -737,22 +736,22 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
} }
else { else {
// HACK: crude check whether claimed straight is an actual straight piece // HACK: crude check whether claimed straight is an actual straight piece
if( ( cp3 == Math3D::vector3() ) if ((cp3 == glm::dvec3()) && (cp4 == glm::dvec3()))
&& ( cp4 == Math3D::vector3() ) ) { {
segsize = 10.0; // for straights, 10m per segment works good enough segsize = 10.0; // for straights, 10m per segment works good enough
} }
else { else {
// HACK: divide roughly in 10 segments. // HACK: divide roughly in 10 segments.
segsize = segsize =
clamp( clamp(
( p3 - p4 ).Length() * 0.1, glm::length( p3 - p4 ) * 0.1,
2.0 / Global.SplineFidelity, 2.0 / Global.SplineFidelity,
10.0 / Global.SplineFidelity ); 10.0 / Global.SplineFidelity );
} }
} }
if( ( cp3 == Math3D::vector3( 0, 0, 0 ) ) if ((cp3 == glm::dvec3()) && (cp4 == glm::dvec3()))
&& ( cp4 == Math3D::vector3( 0, 0, 0 ) ) ) { {
// Ra: hm, czasem dla prostego są podane... // Ra: hm, czasem dla prostego są podane...
// gdy prosty, kontrolne wyliczane przy zmiennej przechyłce // gdy prosty, kontrolne wyliczane przy zmiennej przechyłce
SwitchExtension->Segments[ 1 ]->Init( p3, p4, segsize, r3, r4 ); SwitchExtension->Segments[ 1 ]->Init( p3, p4, segsize, r3, r4 );
@@ -770,7 +769,8 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if (eType == tt_Cross) if (eType == tt_Cross)
{ // Ra 2014-07: dla skrzyżowań będą dodatkowe segmenty { // Ra 2014-07: dla skrzyżowań będą dodatkowe segmenty
SwitchExtension->Segments[2]->Init(p2, cp2 + p2, cp4 + p4, p4, segsize, r2, r4); // z punktu 2 do 4 SwitchExtension->Segments[2]->Init(p2, cp2 + p2, cp4 + p4, p4, segsize, r2, r4); // z punktu 2 do 4
if (LengthSquared3(p3 - p1) < 0.01) // gdy mniej niż 10cm, to mamy skrzyżowanie trzech dróg auto p1p3 = p3 - p1;
if (glm::dot(p1p3, p1p3) < 0.01) // gdy mniej niż 10cm, to mamy skrzyżowanie trzech dróg
SwitchExtension->iRoads = 3; SwitchExtension->iRoads = 3;
else // dla 4 dróg będą dodatkowe 3 segmenty else // dla 4 dróg będą dodatkowe 3 segmenty
{ {
@@ -785,7 +785,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
if( eType == tt_Switch ) if( eType == tt_Switch )
// Ra: zamienić później na iloczyn wektorowy // Ra: zamienić później na iloczyn wektorowy
{ {
Math3D::vector3 v1, v2; glm::dvec3 v1, v2;
double a1, a2; double a1, a2;
v1 = SwitchExtension->Segments[0]->FastGetPoint_1() v1 = SwitchExtension->Segments[0]->FastGetPoint_1()
- SwitchExtension->Segments[0]->FastGetPoint_0(); - SwitchExtension->Segments[0]->FastGetPoint_0();
@@ -1517,14 +1517,14 @@ void TTrack::create_geometry( gfx::geometrybank_handle const &Bank ) {
case tt_Cross: // skrzyżowanie dróg rysujemy inaczej case tt_Cross: // skrzyżowanie dróg rysujemy inaczej
{ // ustalenie współrzędnych środka - przecięcie Point1-Point2 z CV4-Point4 { // ustalenie współrzędnych środka - przecięcie Point1-Point2 z CV4-Point4
double a[4]; // kąty osi ulic wchodzących double a[4]; // kąty osi ulic wchodzących
Math3D::vector3 p[4]; // punkty się przydadzą do obliczeń glm::dvec3 p[4]; // punkty się przydadzą do obliczeń
// na razie połowa odległości pomiędzy Point1 i Point2, potem się dopracuje // na razie połowa odległości pomiędzy Point1 i Point2, potem się dopracuje
a[0] = a[1] = 0.5; // parametr do poszukiwania przecięcia łuków a[0] = a[1] = 0.5; // parametr do poszukiwania przecięcia łuków
// modyfikować a[0] i a[1] tak, aby trafić na przecięcie odcinka 34 // modyfikować a[0] i a[1] tak, aby trafić na przecięcie odcinka 34
p[0] = SwitchExtension->Segments[0]->FastGetPoint(a[0]); // współrzędne środka pierwszego odcinka p[0] = SwitchExtension->Segments[0]->FastGetPoint(a[0]); // współrzędne środka pierwszego odcinka
p[1] = SwitchExtension->Segments[1]->FastGetPoint(a[1]); //-//- drugiego p[1] = SwitchExtension->Segments[1]->FastGetPoint(a[1]); //-//- drugiego
// p[2]=p[1]-p[0]; //jeśli różne od zera, przeliczyć a[0] i a[1] i wyznaczyć nowe punkty // p[2]=p[1]-p[0]; //jeśli różne od zera, przeliczyć a[0] i a[1] i wyznaczyć nowe punkty
Math3D::vector3 oxz = p[0]; // punkt mapowania środka tekstury skrzyżowania glm::dvec3 oxz = p[0]; // punkt mapowania środka tekstury skrzyżowania
p[0] = SwitchExtension->Segments[0]->GetDirection1(); // Point1 - pobranie wektorów kontrolnych p[0] = SwitchExtension->Segments[0]->GetDirection1(); // Point1 - pobranie wektorów kontrolnych
p[1] = SwitchExtension->Segments[1]->GetDirection2(); // Point3 (bo zamienione) p[1] = SwitchExtension->Segments[1]->GetDirection2(); // Point3 (bo zamienione)
p[2] = SwitchExtension->Segments[0]->GetDirection2(); // Point2 p[2] = SwitchExtension->Segments[0]->GetDirection2(); // Point2
@@ -2042,9 +2042,7 @@ TTrack * TTrack::RaAnimate()
cosa = -hlen * std::cos( glm::radians( SwitchExtension->fOffset ) ); cosa = -hlen * std::cos( glm::radians( SwitchExtension->fOffset ) );
SwitchExtension->vTrans = ac->TransGet(); SwitchExtension->vTrans = ac->TransGet();
auto middle = location() + SwitchExtension->vTrans; // SwitchExtension->Segments[0]->FastGetPoint(0.5); auto middle = location() + SwitchExtension->vTrans; // SwitchExtension->Segments[0]->FastGetPoint(0.5);
Segment->Init( Segment->Init(middle + glm::dvec3(sina, 0.0, cosa), middle - glm::dvec3(sina, 0.0, cosa),
middle + Math3D::vector3( sina, 0.0, cosa ),
middle - Math3D::vector3( sina, 0.0, cosa ),
10.0 ); // nowy odcinek 10.0 ); // nowy odcinek
for( auto dynamic : Dynamics ) { for( auto dynamic : Dynamics ) {
// minimalny ruch, aby przeliczyć pozycję // minimalny ruch, aby przeliczyć pozycję
@@ -2086,7 +2084,7 @@ bool TTrack::IsGroupable()
return true; return true;
}; };
bool Equal( Math3D::vector3 v1, Math3D::vector3 *v2) bool Equal(glm::dvec3 v1, glm::dvec3 *v2)
{ // sprawdzenie odległości punktów { // sprawdzenie odległości punktów
// Ra: powinno być do 100cm wzdłuż toru i ze 2cm w poprzek (na prostej może nie być długiego // Ra: powinno być do 100cm wzdłuż toru i ze 2cm w poprzek (na prostej może nie być długiego
// kawałka) // kawałka)
@@ -2101,7 +2099,7 @@ bool Equal( Math3D::vector3 v1, Math3D::vector3 *v2)
// return (SquareMagnitude(v1-*v2)<0.00012); //0.011^2=0.00012 // return (SquareMagnitude(v1-*v2)<0.00012); //0.011^2=0.00012
}; };
int TTrack::TestPoint( Math3D::vector3 *Point) int TTrack::TestPoint(glm::dvec3 *Point)
{ // sprawdzanie, czy tory można połączyć { // sprawdzanie, czy tory można połączyć
switch (eType) switch (eType)
{ {

View File

@@ -92,7 +92,7 @@ class TSwitchExtension
basic_event *evPlus = nullptr, basic_event *evPlus = nullptr,
*evMinus = nullptr; // zdarzenia sygnalizacji rozprucia *evMinus = nullptr; // zdarzenia sygnalizacji rozprucia
float fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem) float fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem)
Math3D::vector3 vTrans; // docelowa translacja przesuwnicy glm::dvec3 vTrans; // docelowa translacja przesuwnicy
material_handle m_material3 = 0; // texture of auto generated switch trackbed material_handle m_material3 = 0; // texture of auto generated switch trackbed
gfx::geometry_handle Geometry3; // geometry of auto generated switch trackbed gfx::geometry_handle Geometry3; // geometry of auto generated switch trackbed
@@ -308,7 +308,7 @@ public:
} }
double WidthTotal(); double WidthTotal();
bool IsGroupable(); bool IsGroupable();
int TestPoint( Math3D::vector3 *Point); int TestPoint(glm::dvec3 *Point);
void MovedUp1(float const dh); void MovedUp1(float const dh);
void VelocitySet(float v); void VelocitySet(float v);
double VelocityGet(); double VelocityGet();

View File

@@ -44,8 +44,8 @@ public:
void Render(float fNr); void Render(float fNr);
// members // members
double fOffsetH = 0.0; // Ra: odległość środka osi od osi toru (dla samochodów) - użyć do wężykowania double fOffsetH = 0.0; // Ra: odległość środka osi od osi toru (dla samochodów) - użyć do wężykowania
Math3D::vector3 pPosition; // współrzędne XYZ w układzie scenerii glm::dvec3 pPosition; // współrzędne XYZ w układzie scenerii
Math3D::vector3 vAngles; // x:przechyłka, y:pochylenie, z:kierunek w planie (w radianach) glm::dvec3 vAngles; // x:przechyłka, y:pochylenie, z:kierunek w planie (w radianach)
private: private:
// methods // methods
bool ComputatePosition(); // przeliczenie pozycji na torze bool ComputatePosition(); // przeliczenie pozycji na torze