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

build 170508. fixes for local brake use and 3-way crossroad setup

This commit is contained in:
tmj-fstate
2017-05-08 22:41:56 +02:00
parent 3203ad1f6c
commit 54fc93f6e5
8 changed files with 87 additions and 42 deletions

View File

@@ -2232,8 +2232,9 @@ bool TController::IncBrake()
OK = mvOccupied->IncLocalBrakeLevel( std::floor( 1.5 + std::abs( AccDesired ) ) );
break;
case Pneumatic:
if ((mvOccupied->Couplers[0].Connected == NULL) &&
(mvOccupied->Couplers[1].Connected == NULL))
// NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles
if ((mvOccupied->Couplers[0].CouplingFlag == 0) &&
(mvOccupied->Couplers[1].CouplingFlag == 0))
OK = mvOccupied->IncLocalBrakeLevel(
1 + static_cast<int>( std::floor( 0.5 + std::fabs(AccDesired))) ); // hamowanie lokalnym bo luzem jedzie
else

View File

@@ -304,7 +304,7 @@ void TGroundNode::RenderVBO() { // renderowanie obiektu z VBO - faza nieprzezroc
double distancesquared = SquareMagnitude( pCenter - Global::pCameraPosition ) / Global::ZoomFactor;
if( ( distancesquared > ( fSquareRadius * Global::fDistanceFactor ) )
|| ( distancesquared < ( fSquareMinRadius / Global::fDistanceFactor ) ) ) {
|| ( distancesquared < ( fSquareMinRadius / Global::fDistanceFactor ) ) ) {
return;
}
@@ -318,6 +318,10 @@ void TGroundNode::RenderVBO() { // renderowanie obiektu z VBO - faza nieprzezroc
Model->Render( &pCenter );
return;
}
case TP_MEMCELL: {
GfxRenderer.Render( MemCell );
return;
}
}
if( ( iFlags & 0x10 ) || ( fLineThickness < 0 ) ) {
@@ -577,6 +581,10 @@ void TGroundNode::RenderDL()
Model->Render( &pCenter );
return;
}
case TP_MEMCELL: {
GfxRenderer.Render( MemCell );
return;
}
}
// TODO: sprawdzic czy jest potrzebny warunek fLineThickness < 0
@@ -847,7 +855,12 @@ void TSubRect::NodeAdd(TGroundNode *Node)
// Node->nNext3=nMeshed; //dopisanie do listy sortowania
// nMeshed=Node;
break;
case TP_MEMCELL:
#ifdef EU07_SCENERY_EDITOR
case TP_MEMCELL: {
m_memcells.emplace_back( Node );
break;
}
#endif
case TP_TRACTIONPOWERSOURCE: // a te w ogóle pomijamy
// case TP_ISOLATED: //lista torów w obwodzie izolowanym - na razie ignorowana
break;
@@ -1173,7 +1186,14 @@ void TSubRect::RenderDL()
node->RenderDL(); // nieprzezroczyste z mieszanych modeli
for (int j = 0; j < iTracks; ++j)
tTracks[j]->RenderDyn(); // nieprzezroczyste fragmenty pojazdów na torach
#ifdef EU07_SCENERY_EDITOR
// memcells
if( DebugModeFlag ) {
for( auto const memcell : m_memcells ) {
memcell->RenderDL();
}
}
#endif
/*
float width = 100.0f;
float height = 25.0f;
@@ -1246,6 +1266,14 @@ void TSubRect::RenderVBO()
node->RenderVBO(); // nieprzezroczyste z mieszanych modeli
for (int j = 0; j < iTracks; ++j)
tTracks[j]->RenderDyn(); // nieprzezroczyste fragmenty pojazdów na torach
#ifdef EU07_SCENERY_EDITOR
// memcells
if( DebugModeFlag ) {
for( auto const memcell : m_memcells ) {
memcell->RenderVBO();
}
}
#endif
};
void TSubRect::RenderAlphaVBO()

View File

@@ -172,7 +172,6 @@ class TGroundNode : public Resource
void Compile(bool many = false);
void Release();
bool GetTraction();
void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń
void RenderDL(); // renderowanie nieprzezroczystych w Display Lists
@@ -201,16 +200,17 @@ class TSubRect : public Resource, public CMesh
TGroundNode *nRootMesh = nullptr; // obiekty renderujące wg tekstury (wtórne, lista po nNext2)
TGroundNode *nMeshed = nullptr; // lista obiektów dla których istnieją obiekty renderujące grupowo
public:
TGroundNode *
nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2)
TGroundNode *
nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3)
TGroundNode * nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2)
TGroundNode * nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3)
TGroundNode *nRenderRect = nullptr; // z poziomu sektora - nieprzezroczyste (nNext3)
TGroundNode *nRenderRectAlpha = nullptr; // z poziomu sektora - przezroczyste (nNext3)
TGroundNode *nRenderWires = nullptr; // z poziomu sektora - druty i inne linie (nNext3)
TGroundNode *nRender = nullptr; // indywidualnie - nieprzezroczyste (nNext3)
TGroundNode *nRenderMixed = nullptr; // indywidualnie - nieprzezroczyste i przezroczyste (nNext3)
TGroundNode *nRenderAlpha = nullptr; // indywidualnie - przezroczyste (nNext3)
#ifdef EU07_SCENERY_EDITOR
std::deque< TGroundNode* > m_memcells; // collection of memcells present in the sector
#endif
int iNodeCount = 0; // licznik obiektów, do pomijania pustych sektorów
public:
void LoadNodes(); // utworzenie VBO sektora

View File

@@ -176,7 +176,7 @@ void TTrack::Init()
break;
case tt_Cross: // tylko dla skrzyżowania dróg
SwitchExtension = std::make_shared<TSwitchExtension>( this, 6 ); // 6 po³¹czeñ
SwitchExtension->vPoints = NULL; // brak tablicy punktów
SwitchExtension->vPoints = nullptr; // brak tablicy punktów
SwitchExtension->iPoints = 0;
SwitchExtension->bPoints = false; // tablica punktów nie wypełniona
SwitchExtension->iRoads = 4; // domyślnie 4
@@ -647,31 +647,26 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
if (eType != tt_Cross)
SwitchExtension->Segments[1]->Init(p3, p3 + cp3, p4 + cp4, p4, segsize, r3, r4);
else
SwitchExtension->Segments[1]->Init(p4, p4 + cp4, p3 + cp3, p3, segsize, r4,
r3); // odwrócony
SwitchExtension->Segments[1]->Init(p4, p4 + cp4, p3 + cp3, p3, segsize, r4, r3); // odwrócony
}
else
SwitchExtension->Segments[1]->Init(p3, p4, segsize, r3, r4);
if (eType == tt_Cross)
{ // 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
if (LengthSquared3(p3 - p1) <
0.01) // gdy mniej niż 10cm, to mamy skrzyżowanie trzech dróg
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
SwitchExtension->iRoads = 3;
else // dla 4 dróg będą dodatkowe 3 segmenty
{
SwitchExtension->Segments[3]->Init(p4, p4 + cp4, p1 + cp1, p1, segsize, r4,
r1); // z punktu 4 do 1
SwitchExtension->Segments[4]->Init(p1, p1 + cp1, p3 + cp3, p3, segsize, r1,
r3); // z punktu 1 do 3
SwitchExtension->Segments[5]->Init(p3, p3 + cp3, p2 + cp2, p2, segsize, r3,
r2); // z punktu 3 do 2
SwitchExtension->Segments[3]->Init(p4, p4 + cp4, p1 + cp1, p1, segsize, r4, r1); // z punktu 4 do 1
SwitchExtension->Segments[4]->Init(p1, p1 + cp1, p3 + cp3, p3, segsize, r1, r3); // z punktu 1 do 3
SwitchExtension->Segments[5]->Init(p3, p3 + cp3, p2 + cp2, p2, segsize, r3, r2); // z punktu 3 do 2
}
}
Switch(0); // na stałe w położeniu 0 - nie ma początkowego stanu zwrotnicy we wpisie
if( eType == tt_Switch )
// Ra: zamienić później na iloczyn wektorowy
{
vector3 v1, v2;
@@ -1673,24 +1668,15 @@ void TTrack::Compile(GLuint tex)
SwitchExtension->Segments[5]->RenderLoft(
rpts2, -3, fTexLength, 0, 1, &b, render); // tylko jeśli jest z lewej
}
else // to będzie ewentualnie dla prostego na skrzyżowaniu trzech dróg
{ // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być
// prostoliniowe
else
// to będzie ewentualnie dla prostego na skrzyżowaniu trzech dróg
{ // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK
SwitchExtension->Segments[2]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b,
render); // z P2 do P4
SwitchExtension->Segments[2]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b, render); // z P2 do P4
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK
SwitchExtension->Segments[1]->RenderLoft(
rpts2, -3, fTexLength, 0, 1, &b, render); // z P4 do P3=P1 (odwrócony)
SwitchExtension->Segments[1]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b, render); // z P4 do P3=P1 (odwrócony)
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0)) // OK
SwitchExtension->Segments[0]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b,
render); // z P1 do P2
/*
if ((fTexHeight1>=0.0)?true:(slop!=0.0))
Segment->RenderLoft(rpts1,3,fTexLength);
if ((fTexHeight1>=0.0)?true:(side!=0.0))
Segment->RenderLoft(rpts2,3,fTexLength);
*/
SwitchExtension->Segments[0]->RenderLoft(rpts2, -3, fTexLength, 0, 1, &b, render); // z P1 do P2
}
}
// renderowanie nawierzchni na końcu

View File

@@ -702,8 +702,8 @@ void TWorld::OnKeyDown(int cKey)
Global::iTextMode = GLFW_KEY_F1; // to wyświetlić zegar i informację
}
}
else if( Global::ctrlState && cKey == GLFW_KEY_PAUSE ) //[Ctrl]+[Break]
{ // hamowanie wszystkich pojazdów w okolicy
else if( ( cKey == GLFW_KEY_PAUSE ) && ( Global::ctrlState ) ) {
//[Ctrl]+[Break] hamowanie wszystkich pojazdów w okolicy
if (Controlled->MoverParameters->Radio)
Ground.RadioStop(Camera.Pos);
}

View File

@@ -112,6 +112,10 @@ opengl_renderer::Init( GLFWwindow *Window ) {
m_moontextureid = GetTextureId( "fx\\moon", szTexturePath );
WriteLog( "...gfx data pre-loading done" );
// prepare debug mode objects
m_quadric = gluNewQuadric();
gluQuadricNormals( m_quadric, GLU_FLAT );
return true;
}
@@ -585,7 +589,25 @@ opengl_renderer::Render( TSubModel *Submodel ) {
if( Submodel->Next )
if( Submodel->iAlpha & Submodel->iFlags & 0x1F000000 )
Render( Submodel->Next ); // dalsze rekurencyjnie
};
}
void
opengl_renderer::Render( TMemCell *Memcell ) {
::glPushAttrib( GL_ENABLE_BIT );
// ::glDisable( GL_LIGHTING );
::glDisable( GL_TEXTURE_2D );
// ::glEnable( GL_BLEND );
::glPushMatrix();
auto const position = Memcell->Position();
::glTranslated( position.x, position.y + 0.5, position.z );
::glColor3f( 0.36f, 0.75f, 0.35f );
::gluSphere( m_quadric, 0.35, 4, 2 );
::glPopMatrix();
::glPopAttrib();
}
bool
opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "dumb3d.h"
#include "frustum.h"
#include "world.h"
#include "memcell.h"
struct opengl_light {
@@ -110,6 +111,9 @@ class opengl_renderer {
public:
// types
// destructor
~opengl_renderer() { gluDeleteQuadric( m_quadric ); }
// methods
bool
Init( GLFWwindow *Window );
@@ -128,6 +132,8 @@ public:
Render( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
void
Render( TSubModel *Submodel );
void
Render( TMemCell *Memcell );
bool
Render_Alpha( TDynamicObject *Dynamic );
bool
@@ -196,6 +202,8 @@ private:
texture_manager::size_type m_glaretextureid{ -1 };
texture_manager::size_type m_suntextureid{ -1 };
texture_manager::size_type m_moontextureid{ -1 };
GLUquadricObj *m_quadric; // helper object for drawing debug mode scene elements
};
extern opengl_renderer GfxRenderer;

View File

@@ -140,7 +140,7 @@ ui_layer::render_panels() {
glPushAttrib( GL_ENABLE_BIT );
glDisable( GL_TEXTURE_2D );
float const width = std::min( 4.0f / 3.0f, static_cast<float>(Global::iWindowWidth) / Global::iWindowHeight ) * Global::iWindowHeight;
float const width = std::min( 4.0f / 3.0f, static_cast<float>(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight;
float const height = Global::iWindowHeight / 768.0;
for( auto const &panel : m_panels ) {