mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 00:29:19 +02:00
maintenance: removed deprecated ground code
This commit is contained in:
@@ -15,15 +15,12 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "AnimModel.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "usefull.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
#include "Timer.h"
|
||||
#include "MdlMngr.h"
|
||||
// McZapkie:
|
||||
#include "renderer.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#include "simulation.h"
|
||||
#include "Globals.h"
|
||||
#include "Timer.h"
|
||||
#include "Logs.h"
|
||||
|
||||
TAnimContainer *TAnimModel::acAnimList = NULL;
|
||||
|
||||
TAnimAdvanced::TAnimAdvanced(){};
|
||||
@@ -234,11 +231,7 @@ void TAnimContainer::UpdateModel() {
|
||||
iAnim &= ~2; // wyłączyć zmianę pozycji submodelu
|
||||
if( evDone ) {
|
||||
// wykonanie eventu informującego o zakończeniu
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Global::AddToQuery( evDone, NULL );
|
||||
#else
|
||||
simulation::Events.AddToQuery( evDone, nullptr );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,11 +299,7 @@ void TAnimContainer::UpdateModel() {
|
||||
fRotateSpeed = 0.0;
|
||||
if( evDone ) {
|
||||
// wykonanie eventu informującego o zakończeniu
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Global::AddToQuery( evDone, NULL );
|
||||
#else
|
||||
simulation::Events.AddToQuery( evDone, nullptr );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,11 +329,7 @@ void TAnimContainer::PrepareModel()
|
||||
fAngleSpeed = 0.0; // wyłączenie przeliczania wektora
|
||||
if( evDone ) {
|
||||
// wykonanie eventu informującego o zakończeniu
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Global::AddToQuery( evDone, NULL );
|
||||
#else
|
||||
simulation::Events.AddToQuery( evDone, nullptr );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
16
Driver.cpp
16
Driver.cpp
@@ -21,7 +21,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "mtable.h"
|
||||
#include "DynObj.h"
|
||||
#include "Event.h"
|
||||
#include "Ground.h"
|
||||
#include "MemCell.h"
|
||||
#include "World.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
@@ -3002,24 +3001,13 @@ void TController::RecognizeCommand()
|
||||
|
||||
void TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation, TStopReason reason)
|
||||
{ // wysłanie komendy przez event PutValues, jak pojazd ma obsadę, to wysyła tutaj, a nie do pojazdu bezpośrednio
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
vector3 sl;
|
||||
sl.x = -NewLocation.X; // zamiana na współrzędne scenerii
|
||||
sl.z = NewLocation.Y;
|
||||
sl.y = NewLocation.Z;
|
||||
#else
|
||||
// zamiana na współrzędne scenerii
|
||||
glm::dvec3 sl { -NewLocation.X, NewLocation.Z, NewLocation.Y };
|
||||
#endif
|
||||
if (!PutCommand(NewCommand, NewValue1, NewValue2, &sl, reason))
|
||||
mvOccupied->PutCommand(NewCommand, NewValue1, NewValue2, NewLocation);
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
bool TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const vector3 *NewLocation, TStopReason reason)
|
||||
#else
|
||||
bool TController::PutCommand( std::string NewCommand, double NewValue1, double NewValue2, glm::dvec3 const *NewLocation, TStopReason reason )
|
||||
#endif
|
||||
{ // analiza komendy
|
||||
if (NewCommand == "CabSignal")
|
||||
{ // SHP wyzwalane jest przez człon z obsadą, ale obsługiwane przez silnikowy
|
||||
@@ -5339,11 +5327,7 @@ TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection,
|
||||
}
|
||||
|
||||
// sprawdzanie zdarzeń semaforów i ograniczeń szlakowych
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void TController::SetProximityVelocity(double dist, double vel, const vector3 *pos)
|
||||
#else
|
||||
void TController::SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos )
|
||||
#endif
|
||||
{ // Ra:przeslanie do AI prędkości
|
||||
/*
|
||||
//!!!! zastąpić prawidłową reakcją AI na SetProximityVelocity !!!!
|
||||
|
||||
8
Driver.h
8
Driver.h
@@ -314,11 +314,7 @@ private:
|
||||
Mtable::TTrainParameters *Timetable() {
|
||||
return TrainParams; };
|
||||
void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation, TStopReason reason = stopComm);
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
bool PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const vector3 *NewLocation, TStopReason reason = stopComm);
|
||||
#else
|
||||
bool PutCommand( std::string NewCommand, double NewValue1, double NewValue2, glm::dvec3 const *NewLocation, TStopReason reason = stopComm );
|
||||
#endif
|
||||
void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę
|
||||
// procedury dotyczace rozkazow dla maszynisty
|
||||
// uaktualnia informacje o prędkości
|
||||
@@ -378,11 +374,7 @@ private:
|
||||
bool BackwardTrackBusy(TTrack *Track);
|
||||
TEvent *CheckTrackEventBackward(double fDirection, TTrack *Track);
|
||||
TTrack *BackwardTraceRoute(double &fDistance, double &fDirection, TTrack *Track, TEvent *&Event);
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void SetProximityVelocity(double dist, double vel, const vector3 *pos);
|
||||
#else
|
||||
void SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos );
|
||||
#endif
|
||||
TCommandType BackwardScan();
|
||||
|
||||
public:
|
||||
|
||||
26
DynObj.cpp
26
DynObj.cpp
@@ -15,32 +15,18 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "DynObj.h"
|
||||
|
||||
#include "logs.h"
|
||||
#include "MdlMngr.h"
|
||||
#include "Timer.h"
|
||||
#include "Usefull.h"
|
||||
// McZapkie-260202
|
||||
#include "simulation.h"
|
||||
#include "Globals.h"
|
||||
#include "renderer.h"
|
||||
#include "AirCoupler.h"
|
||||
|
||||
#include "TractionPower.h"
|
||||
#include "Event.h"
|
||||
#include "Driver.h"
|
||||
#include "Camera.h" //bo likwidujemy trzęsienie
|
||||
#include "Timer.h"
|
||||
#include "logs.h"
|
||||
#include "Console.h"
|
||||
#include "Traction.h"
|
||||
#include "MdlMngr.h"
|
||||
|
||||
// Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny
|
||||
#define vWorldFront Math3D::vector3(0, 0, 1)
|
||||
#define vWorldUp Math3D::vector3(0, 1, 0)
|
||||
#define vWorldLeft CrossProduct(vWorldUp, vWorldFront)
|
||||
|
||||
// Ra: bo te poniżej to się powielały w każdym module odobno
|
||||
// vector3 vWorldFront=vector3(0,0,1);
|
||||
// vector3 vWorldUp=vector3(0,1,0);
|
||||
// vector3 vWorldLeft=CrossProduct(vWorldUp,vWorldFront);
|
||||
|
||||
#define M_2PI 6.283185307179586476925286766559;
|
||||
const float maxrot = (float)(M_PI / 3.0); // 60°
|
||||
|
||||
@@ -4909,12 +4895,8 @@ void TDynamicObject::RadioStop()
|
||||
if( ( MoverParameters->SecuritySystem.RadioStop )
|
||||
&& ( MoverParameters->Radio ) ) {
|
||||
// jeśli pojazd ma RadioStop i jest on aktywny
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Mechanik->PutCommand( "Emergency_brake", 1.0, 1.0, &vPosition, stopRadio );
|
||||
#else
|
||||
// HAX cast until math types unification
|
||||
Mechanik->PutCommand( "Emergency_brake", 1.0, 1.0, &static_cast<glm::dvec3>(vPosition), stopRadio );
|
||||
#endif
|
||||
// add onscreen notification for human driver
|
||||
// TODO: do it selectively for the 'local' driver once the multiplayer is in
|
||||
if( false == Mechanik->AIControllFlag ) {
|
||||
|
||||
7
EU07.cpp
7
EU07.cpp
@@ -20,17 +20,16 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
#include <png.h>
|
||||
#endif
|
||||
|
||||
#include "World.h"
|
||||
#include "simulation.h"
|
||||
#include "Globals.h"
|
||||
#include "timer.h"
|
||||
#include "Logs.h"
|
||||
#include "keyboardinput.h"
|
||||
#include "mouseinput.h"
|
||||
#include "gamepadinput.h"
|
||||
#include "Console.h"
|
||||
#include "PyInt.h"
|
||||
#include "World.h"
|
||||
#include "Mover.h"
|
||||
#include "usefull.h"
|
||||
#include "timer.h"
|
||||
#include "uilayer.h"
|
||||
|
||||
#ifdef EU07_BUILD_STATIC
|
||||
|
||||
35
Event.cpp
35
Event.cpp
@@ -16,18 +16,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "event.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "parser.h"
|
||||
#include "Timer.h"
|
||||
#include "MemCell.h"
|
||||
#include "Ground.h"
|
||||
#include "McZapkie\mctools.h"
|
||||
#include "animmodel.h"
|
||||
#include "dynobj.h"
|
||||
#include "driver.h"
|
||||
#include "tractionpower.h"
|
||||
#include "simulation.h"
|
||||
#include "globals.h"
|
||||
#include "timer.h"
|
||||
#include "logs.h"
|
||||
|
||||
TEvent::TEvent( std::string const &m ) :
|
||||
asNodeName( m )
|
||||
@@ -745,7 +737,7 @@ event_manager::update() {
|
||||
// NOTE: we're presuming global events aren't going to use event2
|
||||
WriteLog( "Eventlauncher " + launcher->name() );
|
||||
if( launcher->Event1 ) {
|
||||
Global::AddToQuery( launcher->Event1, nullptr );
|
||||
AddToQuery( launcher->Event1, nullptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -850,11 +842,7 @@ event_manager::AddToQuery( TEvent *Event, TDynamicObject *Owner ) {
|
||||
for( auto dynamic : Event->Params[ 6 ].asTrack->Dynamics ) {
|
||||
Event->Params[ 5 ].asMemCell->PutCommand(
|
||||
dynamic->Mechanik,
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
&Event->Params[ 4 ].nGroundNode->pCenter );
|
||||
#else
|
||||
Event->Params[ 4 ].asLocation );
|
||||
#endif
|
||||
}
|
||||
//if (DebugModeFlag)
|
||||
WriteLog(
|
||||
@@ -952,11 +940,7 @@ event_manager::CheckQuery() {
|
||||
for( auto dynamic : m_workevent->Params[ 6 ].asTrack->Dynamics ) {
|
||||
m_workevent->Params[ 5 ].asMemCell->PutCommand(
|
||||
dynamic->Mechanik,
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
&m_workevent->Params[ 4 ].nGroundNode->pCenter );
|
||||
#else
|
||||
m_workevent->Params[ 4 ].asLocation );
|
||||
#endif
|
||||
}
|
||||
//if (DebugModeFlag)
|
||||
WriteLog("Type: UpdateValues & Track command - [" +
|
||||
@@ -980,11 +964,7 @@ event_manager::CheckQuery() {
|
||||
}
|
||||
m_workevent->Params[ 9 ].asMemCell->PutCommand(
|
||||
m_workevent->Activator->Mechanik,
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
&m_workevent->Params[ 8 ].nGroundNode->pCenter );
|
||||
#else
|
||||
m_workevent->Params[ 8 ].asLocation );
|
||||
#endif
|
||||
}
|
||||
WriteLog( "Type: GetValues" );
|
||||
break;
|
||||
@@ -1028,13 +1008,8 @@ event_manager::CheckQuery() {
|
||||
break;
|
||||
}
|
||||
case tp_Visible: {
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
if( m_workevent->Params[ 9 ].nGroundNode )
|
||||
m_workevent->Params[ 9 ].nGroundNode->bVisible = ( m_workevent->Params[ i ].asInt > 0 );
|
||||
#else
|
||||
if( m_workevent->Params[ 9 ].asEditorNode )
|
||||
m_workevent->Params[ 9 ].asEditorNode->visible( m_workevent->Params[ i ].asInt > 0 );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case tp_Velocity: {
|
||||
|
||||
6
Event.h
6
Event.h
@@ -63,9 +63,6 @@ union TParam
|
||||
{
|
||||
void *asPointer;
|
||||
TMemCell *asMemCell;
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode *nGroundNode;
|
||||
#endif
|
||||
editor::basic_node *asEditorNode;
|
||||
glm::dvec3 const *asLocation;
|
||||
TTrack *asTrack;
|
||||
@@ -94,9 +91,6 @@ class TEvent // zmienne: ev*
|
||||
bool bEnabled = false; // false gdy ma nie być dodawany do kolejki (skanowanie sygnałów)
|
||||
int iQueued = 0; // ile razy dodany do kolejki
|
||||
TEvent *evNext = nullptr; // następny w kolejce
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TEvent *evNext2 = nullptr;
|
||||
#endif
|
||||
TEventType Type = tp_Unknown;
|
||||
double fStartTime = 0.0;
|
||||
double fDelay = 0.0;
|
||||
|
||||
34
Globals.cpp
34
Globals.cpp
@@ -12,23 +12,17 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
#include "globals.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "usefull.h"
|
||||
//#include "Mover.h"
|
||||
#include "world.h"
|
||||
#include "simulation.h"
|
||||
#include "logs.h"
|
||||
#include "Console.h"
|
||||
#include "Driver.h"
|
||||
#include "Logs.h"
|
||||
#include "PyInt.h"
|
||||
#include "World.h"
|
||||
#include "parser.h"
|
||||
|
||||
// namespace Global {
|
||||
|
||||
// parametry do użytku wewnętrznego
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGround *Global::pGround = NULL;
|
||||
#endif
|
||||
std::string Global::AppName{ "EU07" };
|
||||
std::string Global::asCurrentSceneryPath = "scenery/";
|
||||
std::string Global::asCurrentTexturePath = std::string(szTexturePath);
|
||||
@@ -987,26 +981,6 @@ void Global::TrainDelete(TDynamicObject *d)
|
||||
pWorld->TrainDelete(d);
|
||||
};
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TDynamicObject *Global::DynamicNearest()
|
||||
{ // ustalenie pojazdu najbliższego kamerze
|
||||
return pGround->DynamicNearest(pCamera->Pos);
|
||||
};
|
||||
|
||||
TDynamicObject *Global::CouplerNearest()
|
||||
{ // ustalenie pojazdu najbliższego kamerze
|
||||
return pGround->CouplerNearest(pCamera->Pos);
|
||||
};
|
||||
#endif
|
||||
bool Global::AddToQuery(TEvent *event, TDynamicObject *who)
|
||||
{
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
return pGround->AddToQuery(event, who);
|
||||
#else
|
||||
return simulation::Events.AddToQuery( event, who );
|
||||
#endif
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool Global::DoEvents()
|
||||
|
||||
@@ -161,11 +161,6 @@ public:
|
||||
static void SetCameraPosition(Math3D::vector3 pNewCameraPosition);
|
||||
static void SetCameraRotation(double Yaw);
|
||||
static void TrainDelete(TDynamicObject *d);
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
static TDynamicObject * DynamicNearest();
|
||||
static TDynamicObject * CouplerNearest();
|
||||
#endif
|
||||
static bool AddToQuery(TEvent *event, TDynamicObject *who);
|
||||
static bool DoEvents();
|
||||
static std::string Bezogonkow(std::string str, bool _ = false);
|
||||
static double Min0RSpeed(double vel1, double vel2);
|
||||
@@ -195,9 +190,6 @@ public:
|
||||
static bool bLiveTraction;
|
||||
static float Global::fMouseXScale;
|
||||
static float Global::fMouseYScale;
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
static TGround *pGround;
|
||||
#endif
|
||||
static std::string szDefaultExt;
|
||||
static std::string SceneryFile;
|
||||
static std::string AppName;
|
||||
|
||||
23
MemCell.cpp
23
MemCell.cpp
@@ -14,14 +14,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MemCell.h"
|
||||
#include "memcell.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "Driver.h"
|
||||
#include "Event.h"
|
||||
#include "parser.h"
|
||||
#include "simulation.h"
|
||||
#include "logs.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -104,16 +100,11 @@ TCommandType TMemCell::CommandCheck()
|
||||
bool TMemCell::Load(cParser *parser)
|
||||
{
|
||||
std::string token;
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
parser->getTokens( 3, false );
|
||||
*parser
|
||||
#else
|
||||
parser->getTokens( 6, false );
|
||||
*parser
|
||||
>> m_area.center.x
|
||||
>> m_area.center.y
|
||||
>> m_area.center.z
|
||||
#endif
|
||||
>> szText
|
||||
>> fValue1
|
||||
>> fValue2;
|
||||
@@ -129,11 +120,7 @@ bool TMemCell::Load(cParser *parser)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void TMemCell::PutCommand(TController *Mech, vector3 *Loc)
|
||||
#else
|
||||
void TMemCell::PutCommand( TController *Mech, glm::dvec3 const *Loc )
|
||||
#endif
|
||||
{ // wysłanie zawartości komórki do AI
|
||||
if (Mech)
|
||||
Mech->PutCommand(szText, fValue1, fValue2, Loc);
|
||||
@@ -178,11 +165,7 @@ void TMemCell::StopCommandSent()
|
||||
bCommand = false;
|
||||
if( OnSent ) {
|
||||
// jeśli jest event
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Global::AddToQuery( OnSent, NULL );
|
||||
#else
|
||||
simulation::Events.AddToQuery( OnSent, nullptr );
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,11 +28,7 @@ public:
|
||||
bool
|
||||
Load(cParser *parser);
|
||||
void
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
PutCommand( TController *Mech, Math3D::vector3 *Loc );
|
||||
#else
|
||||
PutCommand( TController *Mech, glm::dvec3 const *Loc );
|
||||
#endif
|
||||
bool
|
||||
Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask );
|
||||
std::string const &
|
||||
|
||||
60
Model3d.cpp
60
Model3d.cpp
@@ -19,9 +19,6 @@ Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
|
||||
#include "logs.h"
|
||||
#include "mczapkie/mctools.h"
|
||||
#include "Usefull.h"
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
#include "ground.h"
|
||||
#endif
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "mtable.h"
|
||||
@@ -1033,64 +1030,7 @@ TSubModel::create_geometry( std::size_t &Dataoffset, geometrybank_handle const &
|
||||
if( Next )
|
||||
Next->create_geometry( Dataoffset, Bank );
|
||||
}
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
// places contained geometry in provided ground node
|
||||
void
|
||||
TSubModel::convert( TGroundNode &Groundnode ) const {
|
||||
|
||||
Groundnode.asName = pName;
|
||||
Groundnode.Ambient = f4Ambient;
|
||||
Groundnode.Diffuse = f4Diffuse;
|
||||
Groundnode.Specular = f4Specular;
|
||||
Groundnode.m_material = m_material;
|
||||
Groundnode.iFlags = (
|
||||
( true == GfxRenderer.Material( m_material ).has_alpha ) ?
|
||||
0x20 :
|
||||
0x10 );
|
||||
|
||||
if( m_geometry == null_handle ) { return; }
|
||||
|
||||
int vertexcount { 0 };
|
||||
std::vector<TGroundVertex> importedvertices;
|
||||
TGroundVertex vertex, vertex1, vertex2;
|
||||
for( auto const &sourcevertex : GfxRenderer.Vertices( m_geometry ) ) {
|
||||
vertex.position = sourcevertex.position;
|
||||
vertex.normal = sourcevertex.normal;
|
||||
vertex.texture = sourcevertex.texture;
|
||||
if( vertexcount == 0 ) { vertex1 = vertex; }
|
||||
else if( vertexcount == 1 ) { vertex2 = vertex; }
|
||||
else if( vertexcount >= 2 ) {
|
||||
if( false == degenerate( vertex1.position, vertex2.position, vertex.position ) ) {
|
||||
importedvertices.emplace_back( vertex1 );
|
||||
importedvertices.emplace_back( vertex2 );
|
||||
importedvertices.emplace_back( vertex );
|
||||
}
|
||||
// start a new triangle
|
||||
vertexcount = -1;
|
||||
}
|
||||
++vertexcount;
|
||||
}
|
||||
if( Groundnode.Piece == nullptr ) {
|
||||
Groundnode.Piece = new piece_node();
|
||||
}
|
||||
Groundnode.iNumVerts = importedvertices.size();
|
||||
if( Groundnode.iNumVerts > 0 ) {
|
||||
// assign imported geometry to the node...
|
||||
Groundnode.Piece->vertices.swap( importedvertices );
|
||||
// ...and calculate center...
|
||||
for( auto const &vertex : Groundnode.Piece->vertices ) {
|
||||
Groundnode.pCenter += vertex.position;
|
||||
}
|
||||
Groundnode.pCenter /= Groundnode.iNumVerts;
|
||||
// ...and bounding area
|
||||
double squareradius { 0.0 };
|
||||
for( auto const &vertex : Groundnode.Piece->vertices ) {
|
||||
squareradius = std::max( squareradius, glm::length2( vertex.position - glm::dvec3{ Groundnode.pCenter } ) );
|
||||
}
|
||||
Groundnode.fSquareRadius += squareradius;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void TSubModel::ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular )
|
||||
{ // ustawienie kolorów dla modelu terenu
|
||||
f4Ambient = glm::vec4( Ambient, 1.0f );
|
||||
|
||||
@@ -50,9 +50,6 @@ enum TAnimType // rodzaj animacji
|
||||
at_Undefined = 0x800000FF // animacja chwilowo nieokreślona
|
||||
};
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
class TGroundNode;
|
||||
#endif
|
||||
namespace scene {
|
||||
class shape_node;
|
||||
}
|
||||
@@ -216,9 +213,6 @@ public:
|
||||
std::vector<float4x4>&);
|
||||
void serialize_geometry( std::ostream &Output ) const;
|
||||
// places contained geometry in provided ground node
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void convert( TGroundNode &Groundnode ) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
class TModel3d : public CMesh
|
||||
|
||||
56
Names.h
56
Names.h
@@ -12,62 +12,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
template <typename Type_>
|
||||
class TNames {
|
||||
|
||||
public:
|
||||
// types:
|
||||
|
||||
// constructors:
|
||||
TNames() = default;
|
||||
|
||||
// destructor:
|
||||
|
||||
// methods:
|
||||
// dodanie obiektu z wskaźnikiem. updates data field if the object already exists. returns true for insertion, false for update
|
||||
bool
|
||||
Add( int const Type, std::string const &Name, Type_ Data ) {
|
||||
|
||||
auto lookup = find_map( Type ).emplace( Name, Data );
|
||||
if( lookup.second == false ) {
|
||||
// record already exists, update it
|
||||
lookup.first->second = Data;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// new record inserted, bail out
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// returns pointer associated with provided label, or nullptr if there's no match
|
||||
Type_
|
||||
Find( int const Type, std::string const &Name ) {
|
||||
|
||||
auto const &map = find_map( Type );
|
||||
auto const lookup = map.find( Name );
|
||||
if( lookup != map.end() ) { return lookup->second; }
|
||||
else { return nullptr; }
|
||||
}
|
||||
|
||||
private:
|
||||
// types:
|
||||
typedef std::unordered_map<std::string, Type_> type_map;
|
||||
typedef std::unordered_map<int, type_map> typemap_map;
|
||||
|
||||
// methods:
|
||||
// returns database stored with specified type key; creates new database if needed.
|
||||
type_map &
|
||||
find_map( int const Type ) {
|
||||
|
||||
return m_maps.emplace( Type, type_map() ).first->second;
|
||||
}
|
||||
|
||||
// members:
|
||||
typemap_map m_maps; // list of object maps of types specified so far
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename Type_>
|
||||
class basic_table {
|
||||
|
||||
|
||||
186
Track.cpp
186
Track.cpp
@@ -13,20 +13,12 @@ http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Track.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Usefull.h"
|
||||
#include "renderer.h"
|
||||
#include "Timer.h"
|
||||
#include "Ground.h"
|
||||
#include "parser.h"
|
||||
#include "Mover.h"
|
||||
#include "DynObj.h"
|
||||
#include "AnimModel.h"
|
||||
#include "MemCell.h"
|
||||
#include "Event.h"
|
||||
#include "track.h"
|
||||
|
||||
#include "simulation.h"
|
||||
#include "globals.h"
|
||||
#include "timer.h"
|
||||
#include "logs.h"
|
||||
|
||||
// 101206 Ra: trapezoidalne drogi i tory
|
||||
// 110720 Ra: rozprucie zwrotnicy i odcinki izolowane
|
||||
@@ -37,13 +29,11 @@ static float const fMaxOffset = 0.1f; // double(0.1f)==0.100000001490116
|
||||
const int iLewo4[4] = {5, 3, 4, 6}; // segmenty (1..6) do skręcania w lewo
|
||||
const int iPrawo4[4] = {-4, -6, -3, -5}; // segmenty (1..6) do skręcania w prawo
|
||||
const int iProsto4[4] = {1, -1, 2, -2}; // segmenty (1..6) do jazdy prosto
|
||||
const int iEnds4[13] = {3, 0, 2, 1, 2, 0, -1,
|
||||
1, 3, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
|
||||
const int iEnds4[13] = {3, 0, 2, 1, 2, 0, -1, 1, 3, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
|
||||
const int iLewo3[4] = {1, 3, 2, 1}; // segmenty do skręcania w lewo
|
||||
const int iPrawo3[4] = {-2, -1, -3, -2}; // segmenty do skręcania w prawo
|
||||
const int iProsto3[4] = {1, -1, 2, 1}; // segmenty do jazdy prosto
|
||||
const int iEnds3[13] = {3, 0, 2, 1, 2, 0, -1,
|
||||
1, 0, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
|
||||
const int iEnds3[13] = {3, 0, 2, 1, 2, 0, -1, 1, 0, 2, 0, 3, 1}; // numer sąsiedniego toru na końcu segmentu "-1"
|
||||
TIsolated *TIsolated::pRoot = NULL;
|
||||
|
||||
TSwitchExtension::TSwitchExtension(TTrack *owner, int const what)
|
||||
@@ -114,7 +104,7 @@ void TIsolated::Modify(int i, TDynamicObject *o)
|
||||
if (!iAxles)
|
||||
{ // jeśli po zmianie nie ma żadnej osi na odcinku izolowanym
|
||||
if (evFree)
|
||||
Global::AddToQuery(evFree, o); // dodanie zwolnienia do kolejki
|
||||
simulation::Events.AddToQuery(evFree, o); // dodanie zwolnienia do kolejki
|
||||
if (Global::iMultiplayer) // jeśli multiplayer
|
||||
multiplayer::WyslijString(asName, 10); // wysłanie pakietu o zwolnieniu
|
||||
if (pMemCell) // w powiązanej komórce
|
||||
@@ -128,7 +118,7 @@ void TIsolated::Modify(int i, TDynamicObject *o)
|
||||
if (iAxles)
|
||||
{
|
||||
if (evBusy)
|
||||
Global::AddToQuery(evBusy, o); // dodanie zajętości do kolejki
|
||||
simulation::Events.AddToQuery(evBusy, o); // dodanie zajętości do kolejki
|
||||
if (Global::iMultiplayer) // jeśli multiplayer
|
||||
multiplayer::WyslijString(asName, 11); // wysłanie pakietu o zajęciu
|
||||
if (pMemCell) // w powiązanej komórce
|
||||
@@ -185,18 +175,6 @@ TTrack::sort_by_material( TTrack const *Left, TTrack const *Right ) {
|
||||
|
||||
TTrack * TTrack::Create400m(int what, double dx)
|
||||
{ // tworzenie toru do wstawiania taboru podczas konwersji na E3D
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode *tmp = new TGroundNode(TP_TRACK); // node
|
||||
TTrack *trk = tmp->pTrack;
|
||||
trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
|
||||
trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy
|
||||
trk->Init(); // utworzenie segmentu
|
||||
trk->Segment->Init(vector3(-dx, 0, 0), vector3(-dx, 0, 400), 10.0, 0, 0); // prosty
|
||||
tmp->pCenter = vector3(-dx, 0, 200); //środek, aby się mogło wyświetlić
|
||||
TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z);
|
||||
r->NodeAdd(tmp); // dodanie toru do segmentu
|
||||
r->Sort(); //żeby wyświetlał tabor z dodanego toru
|
||||
#else
|
||||
auto *trk = new TTrack( "auto_400m" );
|
||||
trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
|
||||
trk->iCategoryFlag = what; // taki sam typ plus informacja, że dodatkowy
|
||||
@@ -205,112 +183,11 @@ TTrack * TTrack::Create400m(int what, double dx)
|
||||
trk->location( glm::dvec3{ -dx, 0, 200 } ); //środek, aby się mogło wyświetlić
|
||||
simulation::Paths.insert( trk );
|
||||
simulation::Region->insert_path( trk, scene::scratch_data() );
|
||||
#endif
|
||||
return trk;
|
||||
};
|
||||
|
||||
TTrack * TTrack::NullCreate(int dir)
|
||||
{ // tworzenie toru wykolejającego od strony (dir), albo pętli dla samochodów
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode *tmp = new TGroundNode( TP_TRACK );
|
||||
TGroundNode *tmp2 = nullptr; // node
|
||||
TTrack *trk = tmp->pTrack; // tor; UWAGA! obrotnica może generować duże ilości tego
|
||||
trk->m_visible = false; // nie potrzeba pokazywać, zresztą i tak nie ma tekstur
|
||||
// trk->iTrapezoid=1; //są przechyłki do uwzględniania w rysowaniu
|
||||
trk->iCategoryFlag = (iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy
|
||||
float r1, r2;
|
||||
Segment->GetRolls(r1, r2); // pobranie przechyłek na początku toru
|
||||
vector3 p1, cv1, cv2, p2; // będziem tworzyć trajektorię lotu
|
||||
if (iCategoryFlag & 1)
|
||||
{ // tylko dla kolei
|
||||
trk->iDamageFlag = 128; // wykolejenie
|
||||
trk->fVelocity = 0.0; // koniec jazdy
|
||||
trk->Init(); // utworzenie segmentu
|
||||
switch (dir)
|
||||
{ //łączenie z nowym torem
|
||||
case 0:
|
||||
p1 = Segment->FastGetPoint_0();
|
||||
p2 = p1 - 450.0 * Normalize(Segment->GetDirection1());
|
||||
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce
|
||||
trk->Segment->Init(p1, p2, 5, -RadToDeg(r1), 70.0);
|
||||
ConnectPrevPrev(trk, 0);
|
||||
break;
|
||||
case 1:
|
||||
p1 = Segment->FastGetPoint_1();
|
||||
p2 = p1 - 450.0 * Normalize(Segment->GetDirection2());
|
||||
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce
|
||||
trk->Segment->Init(p1, p2, 5, RadToDeg(r2), 70.0);
|
||||
ConnectNextPrev(trk, 0);
|
||||
break;
|
||||
case 3: // na razie nie możliwe
|
||||
p1 = SwitchExtension->Segments[1]->FastGetPoint_1(); // koniec toru drugiego zwrotnicy
|
||||
p2 = p1 - 450.0 * 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
|
||||
ConnectNextPrev(trk, 0);
|
||||
// trk->ConnectPrevNext(trk,dir);
|
||||
SetConnections(1); // skopiowanie połączeń
|
||||
Switch(1); // bo się przełączy na 0, a to coś chce się przecież wykoleić na bok
|
||||
break; // do drugiego zwrotnicy... nie zadziała?
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // tworznie pętelki dla samochodów
|
||||
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->Init(); // utworzenie segmentu
|
||||
tmp2 = new TGroundNode(TP_TRACK); // drugi odcinek do zapętlenia
|
||||
TTrack *trk2 = tmp2->pTrack;
|
||||
trk2->iCategoryFlag =
|
||||
(iCategoryFlag & 15) | 0x80; // taki sam typ plus informacja, że dodatkowy
|
||||
trk2->m_visible = false;
|
||||
trk2->fVelocity = 20.0; // zawracanie powoli
|
||||
trk2->fRadius = 20.0; // promień, aby się dodawało do tabelki prędkości i liczyło
|
||||
// narastająco
|
||||
trk2->Init(); // utworzenie segmentu
|
||||
trk->m_name = m_name + ":loopstart";
|
||||
trk2->m_name = m_name + ":loopfinish";
|
||||
switch (dir)
|
||||
{ //łączenie z nowym torem
|
||||
case 0:
|
||||
p1 = Segment->FastGetPoint_0();
|
||||
cv1 = -20.0 * Normalize(Segment->GetDirection1()); // pierwszy wektor kontrolny
|
||||
p2 = p1 + cv1 + cv1; // 40m
|
||||
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce
|
||||
trk->Segment->Init(p1, p1 + cv1, p2 + vector3(-cv1.z, cv1.y, cv1.x), p2, 2, -RadToDeg(r1), 0.0);
|
||||
ConnectPrevPrev(trk, 0);
|
||||
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce
|
||||
trk2->Segment->Init(p1, p1 + cv1, p2 + vector3(cv1.z, cv1.y, -cv1.x), p2, 2, -RadToDeg(r1), 0.0);
|
||||
trk2->iPrevDirection = 0; // zwrotnie do tego samego odcinka
|
||||
break;
|
||||
case 1:
|
||||
p1 = Segment->FastGetPoint_1();
|
||||
cv1 = -20.0 * Normalize(Segment->GetDirection2()); // pierwszy wektor kontrolny
|
||||
p2 = p1 + cv1 + cv1;
|
||||
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce
|
||||
trk->Segment->Init(p1, p1 + cv1, p2 + vector3(-cv1.z, cv1.y, cv1.x), p2, 2, RadToDeg(r2), 0.0);
|
||||
ConnectNextPrev(trk, 0);
|
||||
// bo prosty, kontrolne wyliczane przy zmiennej przechyłce
|
||||
trk2->Segment->Init(p1, p1 + cv1, p2 + vector3(cv1.z, cv1.y, -cv1.x), p2, 2, RadToDeg(r2), 0.0);
|
||||
trk2->iPrevDirection = 1; // zwrotnie do tego samego odcinka
|
||||
break;
|
||||
}
|
||||
trk2->trPrev = this;
|
||||
trk->ConnectNextNext(trk2, 1); // połączenie dwóch dodatkowych odcinków punktami 2
|
||||
tmp2->pCenter = (0.5 * (p1 + p2)); //środek, aby się mogło wyświetlić
|
||||
}
|
||||
// trzeba jeszcze dodać do odpowiedniego segmentu, aby się renderowały z niego pojazdy
|
||||
tmp->pCenter = (0.5 * (p1 + p2)); //środek, aby się mogło wyświetlić
|
||||
if (tmp2)
|
||||
tmp2->pCenter = tmp->pCenter; // ten sam środek jest
|
||||
// Ra: to poniżej to porażka, ale na razie się nie da inaczej
|
||||
TSubRect *r = Global::pGround->GetSubRect(tmp->pCenter.x, tmp->pCenter.z);
|
||||
if( r != nullptr ) {
|
||||
r->NodeAdd( tmp ); // dodanie toru do segmentu
|
||||
if( tmp2 )
|
||||
r->NodeAdd( tmp2 ); // drugiego też
|
||||
r->Sort(); //żeby wyświetlał tabor z dodanego toru
|
||||
}
|
||||
#else
|
||||
TTrack
|
||||
*trk { nullptr },
|
||||
*trk2 { nullptr };
|
||||
@@ -403,7 +280,6 @@ TTrack * TTrack::NullCreate(int dir)
|
||||
simulation::Paths.insert( trk2 );
|
||||
simulation::Region->insert_path( trk2, scene::scratch_data() );
|
||||
}
|
||||
#endif
|
||||
return trk;
|
||||
};
|
||||
|
||||
@@ -1173,18 +1049,11 @@ bool TTrack::InMovement()
|
||||
return false;
|
||||
};
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void TTrack::RaAssign(TGroundNode *gn, TAnimModel *am, TEvent *done, TEvent *joined)
|
||||
#else
|
||||
void TTrack::RaAssign( TAnimModel *am, TEvent *done, TEvent *joined )
|
||||
#endif
|
||||
{ // Ra: wiązanie toru z modelem obrotnicy
|
||||
if (eType == tt_Table)
|
||||
{
|
||||
SwitchExtension->pModel = am;
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
SwitchExtension->pMyNode = gn;
|
||||
#endif
|
||||
SwitchExtension->evMinus = done; // event zakończenia animacji (zadanie nowej przedłuża)
|
||||
SwitchExtension->evPlus =
|
||||
joined; // event potwierdzenia połączenia (gdy nie znajdzie, to się nie połączy)
|
||||
@@ -1195,12 +1064,7 @@ void TTrack::RaAssign( TAnimModel *am, TEvent *done, TEvent *joined )
|
||||
};
|
||||
|
||||
// wypełnianie tablic VBO
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void TTrack::create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ) {
|
||||
#else
|
||||
void TTrack::create_geometry( geometrybank_handle const &Bank ) {
|
||||
#endif
|
||||
// Ra: trzeba rozdzielić szyny od podsypki, aby móc grupować wg tekstur
|
||||
auto const fHTW = 0.5f * std::abs(fTrackWidth);
|
||||
auto const side = std::abs(fTexWidth); // szerokść podsypki na zewnątrz szyny albo pobocza
|
||||
@@ -1245,12 +1109,6 @@ void TTrack::create_geometry( geometrybank_handle const &Bank ) {
|
||||
normal2 = normal1;
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
if( Bank != 0 ) {
|
||||
m_origin = Origin;
|
||||
}
|
||||
#endif
|
||||
|
||||
float roll1, roll2;
|
||||
switch (iCategoryFlag & 15)
|
||||
{
|
||||
@@ -2287,9 +2145,6 @@ void TTrack::create_geometry( geometrybank_handle const &Bank ) {
|
||||
|
||||
void TTrack::EnvironmentSet()
|
||||
{ // ustawienie zmienionego światła
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
::glColor4f( 1.f, 1.f, 1.f, 1.f );
|
||||
#endif
|
||||
switch( eEnvironment ) {
|
||||
case e_canyon: {
|
||||
Global::DayLight.apply_intensity( 0.4f );
|
||||
@@ -2408,11 +2263,7 @@ bool TTrack::Switch(int i, float const t, float const d)
|
||||
RaAnimate(); // ostatni etap animowania
|
||||
// zablokowanie pozycji i połączenie do sąsiednich torów
|
||||
// TODO: register new position of the path endpoints with the region
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Global::pGround->TrackJoin(SwitchExtension->pMyNode);
|
||||
#else
|
||||
simulation::Region->TrackJoin( this );
|
||||
#endif
|
||||
if (trNext || trPrev)
|
||||
{
|
||||
fVelocity = 6.0; // jazda dozwolona
|
||||
@@ -2427,7 +2278,7 @@ bool TTrack::Switch(int i, float const t, float const d)
|
||||
}
|
||||
if( SwitchExtension->evPlus ) { // w starych sceneriach może nie być
|
||||
// potwierdzenie wykonania (np. odpala WZ)
|
||||
Global::AddToQuery( SwitchExtension->evPlus, nullptr );
|
||||
simulation::Events.AddToQuery( SwitchExtension->evPlus, nullptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2463,11 +2314,11 @@ bool TTrack::SwitchForced(int i, TDynamicObject *o)
|
||||
{
|
||||
case 0:
|
||||
if (SwitchExtension->evPlus)
|
||||
Global::AddToQuery(SwitchExtension->evPlus, o); // dodanie do kolejki
|
||||
simulation::Events.AddToQuery(SwitchExtension->evPlus, o); // dodanie do kolejki
|
||||
break;
|
||||
case 1:
|
||||
if (SwitchExtension->evMinus)
|
||||
Global::AddToQuery(SwitchExtension->evMinus, o); // dodanie do kolejki
|
||||
simulation::Events.AddToQuery(SwitchExtension->evMinus, o); // dodanie do kolejki
|
||||
break;
|
||||
}
|
||||
Switch(i); // jeśli się tu nie przełączy, to każdy pojazd powtórzy event rozrprucia
|
||||
@@ -2662,11 +2513,7 @@ TTrack * TTrack::RaAnimate()
|
||||
cosa = -hlen * std::cos(glm::radians(SwitchExtension->fOffset));
|
||||
SwitchExtension->vTrans = ac->TransGet();
|
||||
vector3 middle =
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
SwitchExtension->pMyNode->pCenter +
|
||||
#else
|
||||
location() +
|
||||
#endif
|
||||
SwitchExtension->vTrans; // SwitchExtension->Segments[0]->FastGetPoint(0.5);
|
||||
Segment->Init(middle + vector3(sina, 0.0, cosa),
|
||||
middle - vector3(sina, 0.0, cosa), 10.0); // nowy odcinek
|
||||
@@ -2675,11 +2522,7 @@ TTrack * TTrack::RaAnimate()
|
||||
dynamic->Move( 0.000001 );
|
||||
}
|
||||
// NOTE: passing empty handle is a bit of a hack here. could be refactored into something more elegant
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
create_geometry( geometrybank_handle(), glm::dvec3() );
|
||||
#else
|
||||
create_geometry( geometrybank_handle() );
|
||||
#endif
|
||||
} // animacja trwa nadal
|
||||
}
|
||||
else
|
||||
@@ -2976,19 +2819,16 @@ path_table::InitTracks() {
|
||||
// szukamy modelu o tej samej nazwie
|
||||
auto *instance = simulation::Instances.find( trackname );
|
||||
// wiązanie toru z modelem obrotnicy
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
#else
|
||||
track->RaAssign(
|
||||
instance,
|
||||
simulation::Events.FindEvent( trackname + ":done" ),
|
||||
simulation::Events.FindEvent( trackname + ":joined" ) );
|
||||
#endif
|
||||
if( instance == nullptr ) {
|
||||
// jak nie ma modelu to pewnie jest wykolejnica, a ta jest domyślnie zamknięta i wykoleja
|
||||
break;
|
||||
}
|
||||
// no break on purpose:
|
||||
// jak coś pójdzie źle, to robimy z tego normalny tor
|
||||
// "jak coś pójdzie źle, to robimy z tego normalny tor"
|
||||
}
|
||||
case tt_Normal: {
|
||||
// tylko proste są podłączane do rozjazdów, stąd dwa rozjazdy się nie połączą ze sobą
|
||||
|
||||
21
Track.h
21
Track.h
@@ -77,9 +77,6 @@ class TSwitchExtension
|
||||
{ // zmienne potrzebne tylko dla obrotnicy/przesuwnicy
|
||||
// TAnimContainer *pAnim; //animator modelu dla obrotnicy
|
||||
TAnimModel *pModel; // na razie model
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode *pMyNode; // dla obrotnicy do wtórnego podłączania torów
|
||||
#endif
|
||||
};
|
||||
struct
|
||||
{ // zmienne dla skrzyżowania
|
||||
@@ -89,11 +86,7 @@ class TSwitchExtension
|
||||
};
|
||||
};
|
||||
bool bMovement = false; // czy w trakcie animacji
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TSubRect *pOwner = nullptr; // sektor, któremu trzeba zgłosić animację
|
||||
#else
|
||||
scene::basic_cell *pOwner = nullptr; // TODO: convert this to observer pattern
|
||||
#endif
|
||||
TTrack *pNextAnim = nullptr; // następny tor do animowania
|
||||
TEvent *evPlus = nullptr,
|
||||
*evMinus = nullptr; // zdarzenia sygnalizacji rozprucia
|
||||
@@ -249,27 +242,13 @@ public:
|
||||
std::vector<glm::dvec3>
|
||||
endpoints() const;
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ); // wypełnianie VBO
|
||||
#else
|
||||
void create_geometry( geometrybank_handle const &Bank ); // wypełnianie VBO
|
||||
#endif
|
||||
void RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void RaOwnerSet(TSubRect *o) {
|
||||
if (SwitchExtension)
|
||||
SwitchExtension->pOwner = o; };
|
||||
#else
|
||||
void RaOwnerSet( scene::basic_cell *o ) {
|
||||
if( SwitchExtension ) { SwitchExtension->pOwner = o; } };
|
||||
#endif
|
||||
bool InMovement(); // czy w trakcie animacji?
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void RaAssign(TGroundNode *gn, TAnimModel *am, TEvent *done, TEvent *joined);
|
||||
#else
|
||||
void RaAssign( TAnimModel *am, TEvent *done, TEvent *joined );
|
||||
#endif
|
||||
void RaAnimListAdd(TTrack *t);
|
||||
TTrack * RaAnimate();
|
||||
|
||||
|
||||
14
Traction.cpp
14
Traction.cpp
@@ -14,10 +14,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Traction.h"
|
||||
|
||||
#include "simulation.h"
|
||||
#include "Globals.h"
|
||||
#include "logs.h"
|
||||
#include "mctools.h"
|
||||
#include "TractionPower.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/*
|
||||
@@ -180,21 +180,11 @@ TTraction::endpoints() const {
|
||||
}
|
||||
|
||||
std::size_t
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TTraction::create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ) {
|
||||
#else
|
||||
TTraction::create_geometry( geometrybank_handle const &Bank ) {
|
||||
#endif
|
||||
if( m_geometry != null_handle ) {
|
||||
return GfxRenderer.Vertices( m_geometry ).size() / 2;
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
if( Bank != 0 ) {
|
||||
m_origin = Origin;
|
||||
}
|
||||
#endif
|
||||
|
||||
vertex_array vertices;
|
||||
|
||||
double ddp = std::hypot( pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z );
|
||||
|
||||
@@ -66,11 +66,7 @@ class TTraction : public editor::basic_node {
|
||||
endpoints() const;
|
||||
// creates geometry data in specified geometry bank. returns: number of created elements, or NULL
|
||||
// NOTE: deleting nodes doesn't currently release geometry data owned by the node. TODO: implement erasing individual geometry chunks and banks
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
std::size_t create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ); // wypełnianie VBO
|
||||
#else
|
||||
std::size_t create_geometry( geometrybank_handle const &Bank );
|
||||
#endif
|
||||
int TestPoint(glm::dvec3 const &Point);
|
||||
void Connect(int my, TTraction *with, int to);
|
||||
void Init();
|
||||
|
||||
@@ -15,8 +15,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TractionPower.h"
|
||||
|
||||
#include "Logs.h"
|
||||
#include "Ground.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -36,16 +36,11 @@ void TTractionPowerSource::Init(double const u, double const i)
|
||||
|
||||
bool TTractionPowerSource::Load(cParser *parser) {
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
parser->getTokens( 7, false );
|
||||
*parser
|
||||
#else
|
||||
parser->getTokens( 10, false );
|
||||
*parser
|
||||
>> m_area.center.x
|
||||
>> m_area.center.y
|
||||
>> m_area.center.z
|
||||
#endif
|
||||
>> NominalVoltage
|
||||
>> VoltageFrequency
|
||||
>> InternalRes
|
||||
|
||||
25
TrkFoll.cpp
25
TrkFoll.cpp
@@ -15,11 +15,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TrkFoll.h"
|
||||
|
||||
#include "simulation.h"
|
||||
#include "Globals.h"
|
||||
#include "Logs.h"
|
||||
#include "Driver.h"
|
||||
#include "DynObj.h"
|
||||
#include "Event.h"
|
||||
|
||||
TTrackFollower::~TTrackFollower()
|
||||
{
|
||||
@@ -116,7 +115,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
&& ( pCurrentTrack->evEvent1 )
|
||||
&& ( !pCurrentTrack->evEvent1->iQueued ) ) {
|
||||
// dodanie do kolejki
|
||||
Global::AddToQuery( pCurrentTrack->evEvent1, Owner );
|
||||
simulation::Events.AddToQuery( pCurrentTrack->evEvent1, Owner );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +126,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
-1)) // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow
|
||||
if (bPrimary && pCurrentTrack->evEventall1 &&
|
||||
(!pCurrentTrack->evEventall1->iQueued))
|
||||
Global::AddToQuery(pCurrentTrack->evEventall1, Owner); // dodanie do kolejki
|
||||
simulation::Events.AddToQuery(pCurrentTrack->evEventall1, Owner); // dodanie do kolejki
|
||||
// Owner->RaAxleEvent(pCurrentTrack->Eventall1); //Ra: dynamic zdecyduje, czy dodać
|
||||
// do kolejki
|
||||
}
|
||||
@@ -142,7 +141,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
if( ( bPrimary )
|
||||
&& ( pCurrentTrack->evEvent2 )
|
||||
&& ( !pCurrentTrack->evEvent2->iQueued ) ) {
|
||||
Global::AddToQuery( pCurrentTrack->evEvent2, Owner );
|
||||
simulation::Events.AddToQuery( pCurrentTrack->evEvent2, Owner );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,7 +153,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
if( ( bPrimary )
|
||||
&& ( pCurrentTrack->evEventall2 )
|
||||
&& ( !pCurrentTrack->evEventall2->iQueued ) ) {
|
||||
Global::AddToQuery( pCurrentTrack->evEventall2, Owner );
|
||||
simulation::Events.AddToQuery( pCurrentTrack->evEventall2, Owner );
|
||||
}
|
||||
}
|
||||
// Owner->RaAxleEvent(pCurrentTrack->Eventall2); //Ra: dynamic zdecyduje, czy dodać
|
||||
@@ -167,13 +166,13 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
// tylko dla jednego członu
|
||||
if( pCurrentTrack->evEvent0 )
|
||||
if( !pCurrentTrack->evEvent0->iQueued )
|
||||
Global::AddToQuery( pCurrentTrack->evEvent0, Owner );
|
||||
simulation::Events.AddToQuery( pCurrentTrack->evEvent0, Owner );
|
||||
}
|
||||
// Owner->RaAxleEvent(pCurrentTrack->Event0); //Ra: dynamic zdecyduje, czy dodać do
|
||||
// kolejki
|
||||
if (pCurrentTrack->evEventall0)
|
||||
if (!pCurrentTrack->evEventall0->iQueued)
|
||||
Global::AddToQuery(pCurrentTrack->evEventall0, Owner);
|
||||
simulation::Events.AddToQuery(pCurrentTrack->evEventall0, Owner);
|
||||
// Owner->RaAxleEvent(pCurrentTrack->Eventall0); //Ra: dynamic zdecyduje, czy dodać
|
||||
// do kolejki
|
||||
}
|
||||
@@ -275,14 +274,14 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
||||
// if (Owner->MoverParameters->CabNo!=0)
|
||||
{
|
||||
if (pCurrentTrack->evEvent1 && pCurrentTrack->evEvent1->fDelay <= -1.0f)
|
||||
Global::AddToQuery(pCurrentTrack->evEvent1, Owner);
|
||||
simulation::Events.AddToQuery(pCurrentTrack->evEvent1, Owner);
|
||||
if (pCurrentTrack->evEvent2 && pCurrentTrack->evEvent2->fDelay <= -1.0f)
|
||||
Global::AddToQuery(pCurrentTrack->evEvent2, Owner);
|
||||
simulation::Events.AddToQuery(pCurrentTrack->evEvent2, Owner);
|
||||
}
|
||||
if (pCurrentTrack->evEventall1 && pCurrentTrack->evEventall1->fDelay <= -1.0f)
|
||||
Global::AddToQuery(pCurrentTrack->evEventall1, Owner);
|
||||
simulation::Events.AddToQuery(pCurrentTrack->evEventall1, Owner);
|
||||
if (pCurrentTrack->evEventall2 && pCurrentTrack->evEventall2->fDelay <= -1.0f)
|
||||
Global::AddToQuery(pCurrentTrack->evEventall2, Owner);
|
||||
simulation::Events.AddToQuery(pCurrentTrack->evEventall2, Owner);
|
||||
}
|
||||
fCurrentDistance = s;
|
||||
// fDistance=0;
|
||||
|
||||
4
World.h
4
World.h
@@ -13,7 +13,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <string>
|
||||
|
||||
#include "Camera.h"
|
||||
#include "Ground.h"
|
||||
#include "scene.h"
|
||||
#include "sky.h"
|
||||
#include "sun.h"
|
||||
@@ -125,9 +124,6 @@ private:
|
||||
|
||||
TCamera Camera;
|
||||
TCamera DebugCamera;
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGround Ground;
|
||||
#endif
|
||||
world_environment Environment;
|
||||
TTrain *Train;
|
||||
TDynamicObject *pDynamicNearest;
|
||||
|
||||
@@ -72,9 +72,6 @@
|
||||
<ClCompile Include="Globals.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Ground.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Logs.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -278,9 +275,6 @@
|
||||
<ClInclude Include="Camera.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Ground.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MdlMngr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -12,7 +12,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "globals.h"
|
||||
#include "simulation.h"
|
||||
#include "ground.h"
|
||||
#include "mtable.h"
|
||||
#include "logs.h"
|
||||
|
||||
@@ -93,84 +92,6 @@ WyslijWolny(const std::string &t)
|
||||
WyslijString(t, 4); // tor wolny
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void
|
||||
WyslijNamiary(TGroundNode *t)
|
||||
{ // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby
|
||||
// WriteLog("Wysylam pojazd");
|
||||
DaneRozkaz r;
|
||||
r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' );
|
||||
r.iComm = 7; // 7 - dane pojazdu
|
||||
int i = 32;
|
||||
size_t j = t->asName.length();
|
||||
r.iPar[0] = i; // ilość danych liczbowych
|
||||
r.fPar[1] = Global::fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba)
|
||||
r.fPar[2] = t->DynamicObject->MoverParameters->Loc.X; // pozycja X
|
||||
r.fPar[3] = t->DynamicObject->MoverParameters->Loc.Y; // pozycja Y
|
||||
r.fPar[4] = t->DynamicObject->MoverParameters->Loc.Z; // pozycja Z
|
||||
r.fPar[5] = t->DynamicObject->MoverParameters->V; // prędkość ruchu X
|
||||
r.fPar[6] = t->DynamicObject->MoverParameters->nrot * M_PI *
|
||||
t->DynamicObject->MoverParameters->WheelDiameter; // prędkość obrotowa kóŁ
|
||||
r.fPar[7] = 0; // prędkość ruchu Z
|
||||
r.fPar[8] = t->DynamicObject->MoverParameters->AccS; // przyspieszenie X
|
||||
r.fPar[9] = t->DynamicObject->MoverParameters->AccN; // przyspieszenie Y //na razie nie
|
||||
r.fPar[10] = t->DynamicObject->MoverParameters->AccV; // przyspieszenie Z
|
||||
r.fPar[11] = t->DynamicObject->MoverParameters->DistCounter; // przejechana odległość w km
|
||||
r.fPar[12] = t->DynamicObject->MoverParameters->PipePress; // ciśnienie w PG
|
||||
r.fPar[13] = t->DynamicObject->MoverParameters->ScndPipePress; // ciśnienie w PZ
|
||||
r.fPar[14] = t->DynamicObject->MoverParameters->BrakePress; // ciśnienie w CH
|
||||
r.fPar[15] = t->DynamicObject->MoverParameters->Compressor; // ciśnienie w ZG
|
||||
r.fPar[16] = t->DynamicObject->MoverParameters->Itot; // Prąd całkowity
|
||||
r.iPar[17] = t->DynamicObject->MoverParameters->MainCtrlPos; // Pozycja NJ
|
||||
r.iPar[18] = t->DynamicObject->MoverParameters->ScndCtrlPos; // Pozycja NB
|
||||
r.iPar[19] = t->DynamicObject->MoverParameters->MainCtrlActualPos; // Pozycja jezdna
|
||||
r.iPar[20] = t->DynamicObject->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania
|
||||
r.iPar[21] = t->DynamicObject->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania
|
||||
r.iPar[22] = t->DynamicObject->MoverParameters->ResistorsFlag * 1 +
|
||||
t->DynamicObject->MoverParameters->ConverterFlag * 2 +
|
||||
+t->DynamicObject->MoverParameters->CompressorFlag * 4 +
|
||||
t->DynamicObject->MoverParameters->Mains * 8 +
|
||||
+t->DynamicObject->MoverParameters->DoorLeftOpened * 16 +
|
||||
t->DynamicObject->MoverParameters->DoorRightOpened * 32 +
|
||||
+t->DynamicObject->MoverParameters->FuseFlag * 64 +
|
||||
t->DynamicObject->MoverParameters->DepartureSignal * 128;
|
||||
// WriteLog("Zapisalem stare");
|
||||
// WriteLog("Mam patykow "+IntToStr(t->DynamicObject->iAnimType[ANIM_PANTS]));
|
||||
for (int p = 0; p < 4; p++)
|
||||
{
|
||||
// WriteLog("Probuje pant "+IntToStr(p));
|
||||
if (p < t->DynamicObject->iAnimType[ANIM_PANTS])
|
||||
{
|
||||
r.fPar[23 + p] = t->DynamicObject->pants[p].fParamPants->PantWys; // stan pantografów 4
|
||||
// WriteLog("Zapisalem pant "+IntToStr(p));
|
||||
}
|
||||
else
|
||||
{
|
||||
r.fPar[23 + p] = -2;
|
||||
// WriteLog("Nie mam pant "+IntToStr(p));
|
||||
}
|
||||
}
|
||||
// WriteLog("Zapisalem pantografy");
|
||||
for (int p = 0; p < 3; p++)
|
||||
r.fPar[27 + p] =
|
||||
t->DynamicObject->MoverParameters->ShowCurrent(p + 1); // amperomierze kolejnych grup
|
||||
// WriteLog("zapisalem prady");
|
||||
r.iPar[30] = t->DynamicObject->MoverParameters->WarningSignal; // trabienie
|
||||
r.fPar[31] = t->DynamicObject->MoverParameters->RunningTraction.TractionVoltage; // napiecie WN
|
||||
// WriteLog("Parametry gotowe");
|
||||
i <<= 2; // ilość bajtów
|
||||
r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować
|
||||
strcpy(r.cString + i + 1, t->asName.c_str()); // zakończony zerem
|
||||
COPYDATASTRUCT cData;
|
||||
cData.dwData = MAKE_ID4( 'E', 'U', '0', '7' ); // sygnatura
|
||||
cData.cbData = (DWORD)(10 + i + j); // 8+licznik i zero kończące
|
||||
cData.lpData = &r;
|
||||
// WriteLog("Ramka gotowa");
|
||||
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||
// WriteLog("Ramka poszla!");
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t->asName + " sent");
|
||||
}
|
||||
#else
|
||||
void
|
||||
WyslijNamiary(TDynamicObject const *Vehicle)
|
||||
{ // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby
|
||||
@@ -247,7 +168,6 @@ WyslijNamiary(TDynamicObject const *Vehicle)
|
||||
// WriteLog("Ramka poszla!");
|
||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + Vehicle->asName + " sent");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
WyslijObsadzone()
|
||||
|
||||
@@ -11,11 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
class TGroundNode;
|
||||
#else
|
||||
class TDynamicObject;
|
||||
#endif
|
||||
|
||||
namespace multiplayer {
|
||||
|
||||
@@ -44,11 +40,7 @@ void Navigate( std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lPa
|
||||
void WyslijEvent( const std::string &e, const std::string &d );
|
||||
void WyslijString( const std::string &t, int n );
|
||||
void WyslijWolny( const std::string &t );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
void WyslijNamiary( TGroundNode *t );
|
||||
#else
|
||||
void WyslijNamiary( TDynamicObject const *Vehicle );
|
||||
#endif
|
||||
void WyslijParam( int nr, int fl );
|
||||
void WyslijUszkodzenia( const std::string &t, char fl );
|
||||
void WyslijObsadzone(); // -> skladanie wielu pojazdow
|
||||
|
||||
704
renderer.cpp
704
renderer.cpp
@@ -440,18 +440,10 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
||||
}
|
||||
#endif
|
||||
switch_units( true, true, true );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Render( &World.Ground );
|
||||
#else
|
||||
Render( simulation::Region );
|
||||
#endif
|
||||
// ...translucent parts
|
||||
setup_drawing( true );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Render_Alpha( &World.Ground );
|
||||
#else
|
||||
Render_Alpha( simulation::Region );
|
||||
#endif
|
||||
if( World.Train != nullptr ) {
|
||||
// cab render is performed without shadows, due to low resolution and number of models without windows :|
|
||||
switch_units( true, false, false );
|
||||
@@ -501,11 +493,7 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
||||
#else
|
||||
setup_units( false, false, false );
|
||||
#endif
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Render( &World.Ground );
|
||||
#else
|
||||
Render( simulation::Region );
|
||||
#endif
|
||||
// post-render restore
|
||||
::glDisable( GL_POLYGON_OFFSET_FILL );
|
||||
::glDisable( GL_SCISSOR_TEST );
|
||||
@@ -534,11 +522,7 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
||||
// opaque parts...
|
||||
setup_drawing( false );
|
||||
setup_units( true, true, true );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Render( &World.Ground );
|
||||
#else
|
||||
Render( simulation::Region );
|
||||
#endif
|
||||
/*
|
||||
// reflections are limited to sky and ground only, the update rate is too low for anything else
|
||||
// ...translucent parts
|
||||
@@ -591,11 +575,7 @@ opengl_renderer::Render_pass( rendermode const Mode ) {
|
||||
// opaque parts...
|
||||
setup_drawing( false );
|
||||
setup_units( false, false, false );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
Render( &World.Ground );
|
||||
#else
|
||||
Render( simulation::Region );
|
||||
#endif
|
||||
// post-render cleanup
|
||||
}
|
||||
break;
|
||||
@@ -1365,450 +1345,6 @@ opengl_renderer::Texture( texture_handle const Texture ) const {
|
||||
return m_textures.texture( Texture );
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
bool
|
||||
opengl_renderer::Render( TGround *Ground ) {
|
||||
|
||||
m_cellqueue.clear();
|
||||
|
||||
glm::vec3 const cameraposition { m_renderpass.camera.position() };
|
||||
int const camerax = static_cast<int>( std::floor( cameraposition.x / 1000.0f ) + iNumRects / 2 );
|
||||
int const cameraz = static_cast<int>( std::floor( cameraposition.z / 1000.0f ) + iNumRects / 2 );
|
||||
int const segmentcount = 2 * static_cast<int>(std::ceil( m_renderpass.draw_range * Global::fDistanceFactor / 1000.0f ));
|
||||
int const originx = std::max( 0, camerax - segmentcount / 2 );
|
||||
int const originz = std::max( 0, cameraz - segmentcount / 2 );
|
||||
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::color: {
|
||||
|
||||
Update_Lights( simulation::Lights );
|
||||
|
||||
for( int column = originx; column <= originx + segmentcount; ++column ) {
|
||||
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
||||
|
||||
auto *cell = &Ground->Rects[ column ][ row ];
|
||||
#ifdef EU07_USE_DEBUG_CULLING
|
||||
if( m_worldcamera.camera.visible( cell->m_area ) ) {
|
||||
#else
|
||||
if( m_renderpass.camera.visible( cell->m_area ) ) {
|
||||
#endif
|
||||
Render( cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw queue was filled while rendering content of ground cells. now sort the nodes based on their distance to viewer...
|
||||
std::sort(
|
||||
std::begin( m_cellqueue ),
|
||||
std::end( m_cellqueue ),
|
||||
[]( distancesubcell_pair const &Left, distancesubcell_pair const &Right ) {
|
||||
return ( Left.first ) < ( Right.first ); } );
|
||||
// ...then render the opaque content of the visible subcells.
|
||||
for( auto subcellpair : m_cellqueue ) {
|
||||
Render( subcellpair.second );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rendermode::reflections: {
|
||||
// reflections render only terrain geometry
|
||||
for( int column = originx; column <= originx + segmentcount; ++column ) {
|
||||
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
||||
|
||||
auto *cell = &Ground->Rects[ column ][ row ];
|
||||
if( m_renderpass.camera.visible( cell->m_area ) ) {
|
||||
Render( cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rendermode::shadows:
|
||||
case rendermode::pickscenery: {
|
||||
// these render modes don't bother with anything non-visual, or lights
|
||||
for( int column = originx; column <= originx + segmentcount; ++column ) {
|
||||
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
||||
|
||||
auto *cell = &Ground->Rects[ column ][ row ];
|
||||
if( m_renderpass.camera.visible( cell->m_area ) ) {
|
||||
Render( cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
// they can also skip queue sorting, as they only deal with opaque geometry
|
||||
// NOTE: there's benefit from rendering front-to-back, but is it significant enough? TODO: investigate
|
||||
for( auto subcellpair : m_cellqueue ) {
|
||||
Render( subcellpair.second );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rendermode::pickcontrols:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
opengl_renderer::Render( TGroundRect *Groundcell ) {
|
||||
|
||||
bool result { false }; // will be true if we do any rendering
|
||||
|
||||
Groundcell->LoadNodes(); // ewentualne tworzenie siatek
|
||||
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::pickscenery: {
|
||||
// non-interactive scenery elements get neutral colour
|
||||
::glColor3fv( glm::value_ptr( colors::none ) );
|
||||
}
|
||||
case rendermode::color:
|
||||
case rendermode::reflections: {
|
||||
if( Groundcell->nRenderRect != nullptr ) {
|
||||
// nieprzezroczyste trójkąty kwadratu kilometrowego
|
||||
for( TGroundNode *node = Groundcell->nRenderRect; node != nullptr; node = node->nNext3 ) {
|
||||
Render( node );
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rendermode::shadows: {
|
||||
if( Groundcell->nRenderRect != nullptr ) {
|
||||
// experimental, for shadows render both back and front faces, to supply back faces of the 'forest strips'
|
||||
::glDisable( GL_CULL_FACE );
|
||||
// nieprzezroczyste trójkąty kwadratu kilometrowego
|
||||
for( TGroundNode *node = Groundcell->nRenderRect; node != nullptr; node = node->nNext3 ) {
|
||||
Render( node );
|
||||
}
|
||||
result = true;
|
||||
::glEnable( GL_CULL_FACE );
|
||||
}
|
||||
}
|
||||
case rendermode::pickcontrols:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// add the subcells of the cell to the draw queue
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::color:
|
||||
case rendermode::shadows:
|
||||
case rendermode::pickscenery: {
|
||||
if( Groundcell->pSubRects != nullptr ) {
|
||||
for( std::size_t subcellindex = 0; subcellindex < iNumSubRects * iNumSubRects; ++subcellindex ) {
|
||||
auto subcell = Groundcell->pSubRects + subcellindex;
|
||||
if( subcell->iNodeCount ) {
|
||||
// o ile są jakieś obiekty, bo po co puste sektory przelatywać
|
||||
m_cellqueue.emplace_back(
|
||||
glm::length2( m_renderpass.camera.position() - glm::dvec3( subcell->m_area.center ) ),
|
||||
subcell );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rendermode::reflections:
|
||||
case rendermode::pickcontrols:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
opengl_renderer::Render( TSubRect *Groundsubcell ) {
|
||||
|
||||
// oznaczanie aktywnych sektorów
|
||||
Groundsubcell->LoadNodes();
|
||||
|
||||
// przeliczenia animacji torów w sektorze
|
||||
Groundsubcell->RaAnimate( m_framestamp );
|
||||
|
||||
TGroundNode *node;
|
||||
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::color:
|
||||
case rendermode::shadows: {
|
||||
// nieprzezroczyste obiekty terenu
|
||||
for( node = Groundsubcell->nRenderRect; node != nullptr; node = node->nNext3 ) {
|
||||
Render( node );
|
||||
}
|
||||
// nieprzezroczyste obiekty (oprócz pojazdów)
|
||||
for( node = Groundsubcell->nRender; node != nullptr; node = node->nNext3 ) {
|
||||
Render( node );
|
||||
}
|
||||
// nieprzezroczyste z mieszanych modeli
|
||||
for( node = Groundsubcell->nRenderMixed; node != nullptr; node = node->nNext3 ) {
|
||||
Render( node );
|
||||
}
|
||||
// nieprzezroczyste fragmenty pojazdów na torach
|
||||
for( int trackidx = 0; trackidx < Groundsubcell->iTracks; ++trackidx ) {
|
||||
for( auto dynamic : Groundsubcell->tTracks[ trackidx ]->Dynamics ) {
|
||||
Render( dynamic );
|
||||
}
|
||||
}
|
||||
#ifdef EU07_SCENERY_EDITOR
|
||||
// memcells
|
||||
if( EditorModeFlag ) {
|
||||
for( auto const memcell : Groundsubcell->m_memcells ) {
|
||||
Render( memcell );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case rendermode::pickscenery: {
|
||||
// same procedure like with regular render, but each node receives custom colour used for picking
|
||||
// nieprzezroczyste obiekty terenu
|
||||
for( node = Groundsubcell->nRenderRect; node != nullptr; node = node->nNext3 ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( node );
|
||||
}
|
||||
// nieprzezroczyste obiekty (oprócz pojazdów)
|
||||
for( node = Groundsubcell->nRender; node != nullptr; node = node->nNext3 ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( node );
|
||||
}
|
||||
// nieprzezroczyste z mieszanych modeli
|
||||
for( node = Groundsubcell->nRenderMixed; node != nullptr; node = node->nNext3 ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( node );
|
||||
}
|
||||
// nieprzezroczyste fragmenty pojazdów na torach
|
||||
for( int trackidx = 0; trackidx < Groundsubcell->iTracks; ++trackidx ) {
|
||||
for( auto dynamic : Groundsubcell->tTracks[ trackidx ]->Dynamics ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( dynamic );
|
||||
}
|
||||
}
|
||||
#ifdef EU07_SCENERY_EDITOR
|
||||
// memcells
|
||||
if( EditorModeFlag ) {
|
||||
for( auto const memcell : Groundsubcell->m_memcells ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( memcell );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case rendermode::pickcontrols:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
opengl_renderer::Render( TGroundNode *Node ) {
|
||||
|
||||
double distancesquared;
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::shadows: {
|
||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||
distancesquared = SquareMagnitude( ( Node->pCenter - Global::pCameraPosition ) / Global::ZoomFactor ) / Global::fDistanceFactor;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
distancesquared = SquareMagnitude( ( Node->pCenter - m_renderpass.camera.position() ) / Global::ZoomFactor ) / Global::fDistanceFactor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ( distancesquared < Node->fSquareMinRadius )
|
||||
|| ( distancesquared >= Node->fSquareRadius ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (Node->iType) {
|
||||
|
||||
case TP_TRACK: {
|
||||
// setup
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::shadows: {
|
||||
return false;
|
||||
}
|
||||
case rendermode::pickscenery: {
|
||||
// add the node to the pick list
|
||||
m_picksceneryitems.emplace_back( Node );
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
// render
|
||||
Render( Node->pTrack );
|
||||
// debug
|
||||
++m_debugstats.paths;
|
||||
++m_debugstats.drawcalls;
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
return true;
|
||||
}
|
||||
|
||||
case TP_MODEL: {
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::pickscenery: {
|
||||
// add the node to the pick list
|
||||
m_picksceneryitems.emplace_back( Node );
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Node->Model->RaAnimate( m_framestamp ); // jednorazowe przeliczenie animacji
|
||||
Node->Model->RaPrepare();
|
||||
if( Node->Model->pModel ) {
|
||||
// renderowanie rekurencyjne submodeli
|
||||
Render(
|
||||
Node->Model->pModel,
|
||||
Node->Model->Material(),
|
||||
distancesquared,
|
||||
Node->pCenter - m_renderpass.camera.position(),
|
||||
Node->Model->vAngle );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case GL_LINES: {
|
||||
if( ( Node->Piece->geometry == null_handle )
|
||||
|| ( Node->fLineThickness > 0.0 ) ) {
|
||||
return false;
|
||||
}
|
||||
// setup
|
||||
auto const distance = std::sqrt( distancesquared );
|
||||
auto const linealpha =
|
||||
10.0 * Node->fLineThickness
|
||||
/ std::max(
|
||||
0.5 * Node->m_radius + 1.0,
|
||||
distance - ( 0.5 * Node->m_radius ) );
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
// wire colouring is disabled for modes other than colour
|
||||
case rendermode::color: {
|
||||
::glColor4fv(
|
||||
glm::value_ptr(
|
||||
glm::vec4(
|
||||
Node->Diffuse * glm::vec3( Global::DayLight.ambient ), // w zaleznosci od koloru swiatla
|
||||
1.0 ) ) ); // if the thickness is defined negative, lines are always drawn opaque
|
||||
break;
|
||||
}
|
||||
case rendermode::shadows:
|
||||
case rendermode::pickcontrols:
|
||||
case rendermode::pickscenery:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto const linewidth = clamp( 0.5 * linealpha + Node->fLineThickness * Node->m_radius / 1000.0, 1.0, 8.0 );
|
||||
if( linewidth > 1.0 ) {
|
||||
::glLineWidth( static_cast<float>( linewidth ) );
|
||||
}
|
||||
|
||||
GfxRenderer.Bind_Material( null_handle );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::pickscenery: {
|
||||
// add the node to the pick list
|
||||
m_picksceneryitems.emplace_back( Node );
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// render
|
||||
m_geometry.draw( Node->Piece->geometry );
|
||||
// debug
|
||||
// ++m_debugstats.lines;
|
||||
// ++m_debugstats.drawcalls;
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
if( linewidth > 1.0 ) { ::glLineWidth( 1.0f ); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case GL_TRIANGLES: {
|
||||
if( ( Node->Piece->geometry == null_handle )
|
||||
|| ( ( Node->iFlags & 0x10 ) == 0 ) ) {
|
||||
return false;
|
||||
}
|
||||
// setup
|
||||
Bind_Material( Node->m_material );
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::color: {
|
||||
::glColor3fv( glm::value_ptr( Node->Diffuse ) );
|
||||
break;
|
||||
}
|
||||
// pick modes get custom colours, and shadow pass doesn't use any
|
||||
case rendermode::shadows:
|
||||
case rendermode::pickcontrols:
|
||||
case rendermode::pickscenery:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::pickscenery: {
|
||||
// add the node to the pick list
|
||||
m_picksceneryitems.emplace_back( Node );
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// render
|
||||
m_geometry.draw( Node->Piece->geometry );
|
||||
// debug
|
||||
++m_debugstats.shapes;
|
||||
++m_debugstats.drawcalls;
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case TP_MEMCELL: {
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::pickscenery: {
|
||||
// add the node to the pick list
|
||||
m_picksceneryitems.emplace_back( Node );
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Render( Node->MemCell );
|
||||
return true;
|
||||
}
|
||||
|
||||
default: { break; }
|
||||
}
|
||||
// in theory we shouldn't ever get here but, eh
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
void
|
||||
opengl_renderer::Render( scene::basic_region *Region ) {
|
||||
|
||||
@@ -2060,7 +1596,15 @@ opengl_renderer::Render( cell_sequence::iterator First, cell_sequence::iterator
|
||||
// tracks
|
||||
// TODO: update after path node refactoring
|
||||
Render( std::begin( cell->m_paths ), std::end( cell->m_paths ) );
|
||||
|
||||
#ifdef EU07_SCENERY_EDITOR
|
||||
// TODO: re-implement
|
||||
// memcells
|
||||
if( EditorModeFlag ) {
|
||||
for( auto const memcell : Groundsubcell->m_memcells ) {
|
||||
Render( memcell );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
@@ -2095,12 +1639,20 @@ opengl_renderer::Render( cell_sequence::iterator First, cell_sequence::iterator
|
||||
::glColor3fv( glm::value_ptr( colors::none ) );
|
||||
for( auto const &shape : cell->m_shapesopaque ) { Render( shape, false ); }
|
||||
// tracks
|
||||
// TODO: add path to the node picking list
|
||||
for( auto *path : cell->m_paths ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( path );
|
||||
}
|
||||
|
||||
#ifdef EU07_SCENERY_EDITOR
|
||||
// memcells
|
||||
// TODO: re-implement
|
||||
if( EditorModeFlag ) {
|
||||
for( auto const memcell : Groundsubcell->m_memcells ) {
|
||||
::glColor3fv( glm::value_ptr( pick_color( m_picksceneryitems.size() + 1 ) ) );
|
||||
Render( memcell );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
@@ -2250,7 +1802,6 @@ opengl_renderer::Render( TAnimModel *Instance ) {
|
||||
Instance->vAngle );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
||||
@@ -2938,213 +2489,6 @@ opengl_renderer::Render( TMemCell *Memcell ) {
|
||||
::glPopMatrix();
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
bool
|
||||
opengl_renderer::Render_Alpha( TGround *Ground ) {
|
||||
|
||||
TGroundNode *node;
|
||||
TSubRect *tmp;
|
||||
// Ra: renderowanie progresywne - zależne od FPS oraz kierunku patrzenia
|
||||
for( auto subcellpair = std::rbegin( m_cellqueue ); subcellpair != std::rend( m_cellqueue ); ++subcellpair ) {
|
||||
// przezroczyste trójkąty w oddzielnym cyklu przed modelami
|
||||
tmp = subcellpair->second;
|
||||
for( node = tmp->nRenderRectAlpha; node; node = node->nNext3 ) {
|
||||
Render_Alpha( node );
|
||||
}
|
||||
}
|
||||
for( auto subcellpair = std::rbegin( m_cellqueue ); subcellpair != std::rend( m_cellqueue ); ++subcellpair )
|
||||
{ // renderowanie przezroczystych modeli oraz pojazdów
|
||||
Render_Alpha( subcellpair->second );
|
||||
}
|
||||
|
||||
::glDisable( GL_LIGHTING ); // linie nie powinny świecić
|
||||
|
||||
for( auto subcellpair = std::rbegin( m_cellqueue ); subcellpair != std::rend( m_cellqueue ); ++subcellpair ) {
|
||||
// druty na końcu, żeby się nie robiły białe plamy na tle lasu
|
||||
tmp = subcellpair->second;
|
||||
for( node = tmp->nRenderWires; node; node = node->nNext3 ) {
|
||||
Render_Alpha( node );
|
||||
}
|
||||
}
|
||||
|
||||
::glEnable( GL_LIGHTING );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
opengl_renderer::Render_Alpha( TSubRect *Groundsubcell ) {
|
||||
|
||||
TGroundNode *node;
|
||||
for( node = Groundsubcell->nRenderMixed; node; node = node->nNext3 )
|
||||
Render_Alpha( node ); // przezroczyste z mieszanych modeli
|
||||
for( node = Groundsubcell->nRenderAlpha; node; node = node->nNext3 )
|
||||
Render_Alpha( node ); // przezroczyste modele
|
||||
for( int trackidx = 0; trackidx < Groundsubcell->iTracks; ++trackidx ) {
|
||||
for( auto dynamic : Groundsubcell->tTracks[ trackidx ]->Dynamics ) {
|
||||
Render_Alpha( dynamic ); // przezroczyste fragmenty pojazdów na torach
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
|
||||
double distancesquared;
|
||||
switch( m_renderpass.draw_mode ) {
|
||||
case rendermode::shadows: {
|
||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||
distancesquared = SquareMagnitude( ( Node->pCenter - Global::pCameraPosition ) / Global::ZoomFactor ) / Global::fDistanceFactor;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
distancesquared = SquareMagnitude( ( Node->pCenter - m_renderpass.camera.position() ) / Global::ZoomFactor ) / Global::fDistanceFactor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ( distancesquared < Node->fSquareMinRadius )
|
||||
|| ( distancesquared >= Node->fSquareRadius ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (Node->iType)
|
||||
{
|
||||
case TP_TRACTION: {
|
||||
if( Node->bVisible ) {
|
||||
// rysuj jesli sa druty i nie zerwana
|
||||
if( ( Node->hvTraction->Wires == 0 )
|
||||
|| ( true == TestFlag( Node->hvTraction->DamageFlag, 128 ) ) ) {
|
||||
return false;
|
||||
}
|
||||
// setup
|
||||
if( !Global::bSmoothTraction ) {
|
||||
// na liniach kiepsko wygląda - robi gradient
|
||||
::glDisable( GL_LINE_SMOOTH );
|
||||
}
|
||||
float const linealpha = static_cast<float>(
|
||||
std::min(
|
||||
1.25,
|
||||
5000 * Node->hvTraction->WireThickness / ( distancesquared + 1.0 ) ) ); // zbyt grube nie są dobre
|
||||
::glLineWidth( linealpha );
|
||||
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
||||
auto const color { Node->hvTraction->wire_color() };
|
||||
::glColor4f( color.r, color.g, color.b, linealpha );
|
||||
|
||||
Bind_Material( null_handle );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->hvTraction->m_geometry );
|
||||
// debug data
|
||||
++m_debugstats.traction;
|
||||
++m_debugstats.drawcalls;
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
::glLineWidth( 1.0 );
|
||||
if( !Global::bSmoothTraction ) {
|
||||
::glEnable( GL_LINE_SMOOTH );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case TP_MODEL: {
|
||||
|
||||
Node->Model->RaPrepare();
|
||||
if( Node->Model->pModel ) {
|
||||
// renderowanie rekurencyjne submodeli
|
||||
Render_Alpha(
|
||||
Node->Model->pModel,
|
||||
Node->Model->Material(),
|
||||
distancesquared,
|
||||
Node->pCenter - m_renderpass.camera.position(),
|
||||
Node->Model->vAngle );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case GL_LINES: {
|
||||
if( ( Node->Piece->geometry == null_handle )
|
||||
|| ( Node->fLineThickness < 0.0 ) ) {
|
||||
return false;
|
||||
}
|
||||
// setup
|
||||
auto const distance = std::sqrt( distancesquared );
|
||||
auto const linealpha =
|
||||
10.0 * Node->fLineThickness
|
||||
/ std::max(
|
||||
0.5 * Node->m_radius + 1.0,
|
||||
distance - ( 0.5 * Node->m_radius ) );
|
||||
::glColor4fv(
|
||||
glm::value_ptr(
|
||||
glm::vec4(
|
||||
Node->Diffuse * glm::vec3( Global::DayLight.ambient ), // w zaleznosci od koloru swiatla
|
||||
std::min( 1.0, linealpha ) ) ) );
|
||||
auto const linewidth = clamp( 0.5 * linealpha + Node->fLineThickness * Node->m_radius / 1000.0, 1.0, 8.0 );
|
||||
if( linewidth > 1.0 ) {
|
||||
::glLineWidth( static_cast<float>(linewidth) );
|
||||
}
|
||||
|
||||
GfxRenderer.Bind_Material( null_handle );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->Piece->geometry );
|
||||
++m_debugstats.lines;
|
||||
++m_debugstats.drawcalls;
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
if( linewidth > 1.0 ) { ::glLineWidth( 1.0f ); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case GL_TRIANGLES: {
|
||||
if( ( Node->Piece->geometry == null_handle )
|
||||
|| ( ( Node->iFlags & 0x20 ) == 0 ) ) {
|
||||
return false;
|
||||
}
|
||||
// setup
|
||||
::glColor3fv( glm::value_ptr( Node->Diffuse ) );
|
||||
|
||||
Bind_Material( Node->m_material );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->Piece->geometry );
|
||||
// debug data
|
||||
++m_debugstats.shapes;
|
||||
++m_debugstats.drawcalls;
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default: { break; }
|
||||
}
|
||||
// in theory we shouldn't ever get here but, eh
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
void
|
||||
opengl_renderer::Render_Alpha( scene::basic_region *Region ) {
|
||||
|
||||
@@ -3377,7 +2721,7 @@ opengl_renderer::Render_Alpha( scene::lines_node const &Lines ) {
|
||||
++m_debugstats.lines;
|
||||
++m_debugstats.drawcalls;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {
|
||||
|
||||
@@ -3748,11 +3092,7 @@ opengl_renderer::Update_Pick_Control() {
|
||||
return control;
|
||||
}
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode const *
|
||||
#else
|
||||
editor::basic_node const *
|
||||
#endif
|
||||
opengl_renderer::Update_Pick_Node() {
|
||||
|
||||
#ifdef EU07_USE_PICKING_FRAMEBUFFER
|
||||
@@ -3787,11 +3127,7 @@ opengl_renderer::Update_Pick_Node() {
|
||||
unsigned char pickreadout[4];
|
||||
::glReadPixels( pickbufferpos.x, pickbufferpos.y, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, pickreadout );
|
||||
auto const nodeindex = pick_index( glm::ivec3{ pickreadout[ 2 ], pickreadout[ 1 ], pickreadout[ 0 ] } );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode const *node { nullptr };
|
||||
#else
|
||||
editor::basic_node const *node { nullptr };
|
||||
#endif
|
||||
if( ( nodeindex > 0 )
|
||||
&& ( nodeindex <= m_picksceneryitems.size() ) ) {
|
||||
node = m_picksceneryitems[ nodeindex - 1 ];
|
||||
|
||||
41
renderer.h
41
renderer.h
@@ -192,22 +192,14 @@ public:
|
||||
// utility methods
|
||||
TSubModel const *
|
||||
Pick_Control() const { return m_pickcontrolitem; }
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode const *
|
||||
#else
|
||||
editor::basic_node const *
|
||||
#endif
|
||||
Pick_Node() const { return m_picksceneryitem; }
|
||||
// maintenance jobs
|
||||
void
|
||||
Update( double const Deltatime );
|
||||
TSubModel const *
|
||||
Update_Pick_Control();
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
TGroundNode const *
|
||||
#else
|
||||
editor::basic_node const *
|
||||
#endif
|
||||
Update_Pick_Node();
|
||||
// debug performance string
|
||||
std::string const &
|
||||
@@ -248,13 +240,9 @@ private:
|
||||
int drawcalls { 0 };
|
||||
};
|
||||
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
using distancesubcell_pair = std::pair< double, TSubRect * >;
|
||||
#else
|
||||
using section_sequence = std::vector<scene::basic_section *>;
|
||||
using distancecell_pair = std::pair<double, scene::basic_cell *>;
|
||||
using cell_sequence = std::vector<distancecell_pair>;
|
||||
#endif
|
||||
|
||||
struct renderpass_config {
|
||||
|
||||
@@ -295,16 +283,6 @@ private:
|
||||
Render_reflections();
|
||||
bool
|
||||
Render( world_environment *Environment );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
bool
|
||||
Render( TGround *Ground );
|
||||
bool
|
||||
Render( TGroundRect *Groundcell );
|
||||
bool
|
||||
Render( TSubRect *Groundsubcell );
|
||||
bool
|
||||
Render( TGroundNode *Node );
|
||||
#else
|
||||
void
|
||||
Render( scene::basic_region *Region );
|
||||
void
|
||||
@@ -315,7 +293,6 @@ private:
|
||||
Render( scene::shape_node const &Shape, bool const Ignorerange );
|
||||
void
|
||||
Render( TAnimModel *Instance );
|
||||
#endif
|
||||
bool
|
||||
Render( TDynamicObject *Dynamic );
|
||||
bool
|
||||
@@ -332,14 +309,6 @@ private:
|
||||
Render_cab( TDynamicObject *Dynamic, bool const Alpha = false );
|
||||
void
|
||||
Render( TMemCell *Memcell );
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
bool
|
||||
Render_Alpha( TGround *Ground );
|
||||
bool
|
||||
Render_Alpha( TSubRect *Groundsubcell );
|
||||
bool
|
||||
Render_Alpha( TGroundNode *Node );
|
||||
#else
|
||||
void
|
||||
Render_Alpha( scene::basic_region *Region );
|
||||
void
|
||||
@@ -350,7 +319,6 @@ private:
|
||||
Render_Alpha( TTraction *Traction );
|
||||
void
|
||||
Render_Alpha( scene::lines_node const &Lines );
|
||||
#endif
|
||||
bool
|
||||
Render_Alpha( TDynamicObject *Dynamic );
|
||||
bool
|
||||
@@ -422,21 +390,12 @@ private:
|
||||
bool m_renderspecular{ false }; // controls whether to include specular component in the calculations
|
||||
|
||||
renderpass_config m_renderpass;
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
std::vector<distancesubcell_pair> m_cellqueue; // list of subcells to be drawn in current render pass
|
||||
#else
|
||||
section_sequence m_sectionqueue; // list of sections in current render pass
|
||||
cell_sequence m_cellqueue;
|
||||
#endif
|
||||
std::vector<TSubModel const *> m_pickcontrolsitems;
|
||||
TSubModel const *m_pickcontrolitem { nullptr };
|
||||
#ifdef EU07_USE_OLD_GROUNDCODE
|
||||
std::vector<TGroundNode const *> m_picksceneryitems;
|
||||
TGroundNode const *m_picksceneryitem { nullptr };
|
||||
#else
|
||||
std::vector<editor::basic_node const *> m_picksceneryitems;
|
||||
editor::basic_node const *m_picksceneryitem { nullptr };
|
||||
#endif
|
||||
#ifdef EU07_USE_DEBUG_CAMERA
|
||||
renderpass_config m_worldcamera; // debug item
|
||||
#endif
|
||||
|
||||
@@ -10,9 +10,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "scene.h"
|
||||
|
||||
#include "simulation.h"
|
||||
#include "globals.h"
|
||||
#include "timer.h"
|
||||
#include "renderer.h"
|
||||
#include "logs.h"
|
||||
|
||||
namespace scene {
|
||||
@@ -238,9 +238,7 @@ basic_cell::insert( TTrack *Path ) {
|
||||
Path->origin( m_area.center );
|
||||
m_paths.emplace_back( Path );
|
||||
// animation hook
|
||||
#ifndef EU07_USE_OLD_GROUNDCODE
|
||||
Path->RaOwnerSet( this );
|
||||
#endif
|
||||
// re-calculate cell radius, in case track extends outside the cell's boundaries
|
||||
m_area.radius = std::max(
|
||||
m_area.radius,
|
||||
@@ -459,10 +457,8 @@ basic_cell::create_geometry( geometrybank_handle const &Bank ) {
|
||||
|
||||
for( auto &shape : m_shapesopaque ) { shape.create_geometry( Bank ); }
|
||||
for( auto &shape : m_shapestranslucent ) { shape.create_geometry( Bank ); }
|
||||
#ifndef EU07_USE_OLD_GROUNDCODE
|
||||
for( auto *path : m_paths ) { path->create_geometry( Bank ); }
|
||||
for( auto *traction : m_traction ) { traction->create_geometry( Bank ); }
|
||||
#endif
|
||||
for( auto &lines : m_lines ) { lines.create_geometry( Bank ); }
|
||||
// arrange content by assigned materials to minimize state switching
|
||||
std::sort(
|
||||
|
||||
Reference in New Issue
Block a user