From f2110ced2597666461edf415e4f318d1d7ff702d Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Sun, 2 Aug 2020 18:27:22 +0200 Subject: [PATCH] build 200731. empty vehicle load visualization support, basic inverter diagnostics, draw range limits bug fixes --- DynObj.cpp | 59 ++++++++++++++++++++-------------------------- Globals.cpp | 8 +------ McZapkie/MOVER.h | 1 + McZapkie/Mover.cpp | 2 ++ driveruipanels.cpp | 1 + version.h | 2 +- 6 files changed, 31 insertions(+), 42 deletions(-) diff --git a/DynObj.cpp b/DynObj.cpp index ba3c69b7..3bf127a7 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -2758,7 +2758,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) { if( ( m_exchange.unload_count < 0.01 ) && ( m_exchange.load_count < 0.01 ) ) { - MoverParameters->LoadStatus = 0; + MoverParameters->LoadStatus = 4; // if the exchange is completed (or canceled) close the door, if applicable if( ( MoverParameters->Doors.close_control == control_t::passenger ) || ( MoverParameters->Doors.close_control == control_t::mixed ) ) { @@ -2774,40 +2774,33 @@ void TDynamicObject::update_exchange( double const Deltatime ) { MoverParameters->OperateDoors( side::right, false, range_t::local ); } } + // if the vehicle was emptied potentially switch load visualization model + if( MoverParameters->LoadAmount == 0 ) { + MoverParameters->AssignLoad( "" ); + } } } void TDynamicObject::LoadUpdate() { + + MoverParameters->LoadStatus &= ( 1 | 2 ); // po zakończeniu będzie równe zero // przeładowanie modelu ładunku - // Ra: nie próbujemy wczytywać modeli miliony razy podczas renderowania!!! - if( ( mdLoad == nullptr ) - && ( MoverParameters->LoadAmount > 0 ) ) { - - if( false == MoverParameters->LoadType.name.empty() ) { - // bieżąca ścieżka do tekstur to dynamic/... - Global.asCurrentTexturePath = asBaseDir; - - mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); - // TODO: discern from vehicle component which merely uses vehicle directory and has no animations, so it can be initialized outright - // and actual vehicles which get their initialization after their animations are set up - if( mdLoad != nullptr ) { - mdLoad->Init(); - } - // update bindings between lowpoly sections and potential load chunks placed inside them - update_load_sections(); - // z powrotem defaultowa sciezka do tekstur - Global.asCurrentTexturePath = std::string( szTexturePath ); + if( MoverParameters->LoadTypeChange ) { + // whether we succeed or not don't try more than once + MoverParameters->LoadTypeChange = false; + // bieżąca ścieżka do tekstur to dynamic/... + Global.asCurrentTexturePath = asBaseDir; + mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); + // TODO: discern from vehicle component which merely uses vehicle directory and has no animations, so it can be initialized outright + // and actual vehicles which get their initialization after their animations are set up + if( mdLoad != nullptr ) { + mdLoad->Init(); } - // Ra: w MMD można by zapisać położenie modelu ładunku (np. węgiel) w zależności od załadowania - } - else if( MoverParameters->LoadAmount == 0 ) { - // nie ma ładunku -// MoverParameters->AssignLoad( "" ); - mdLoad = nullptr; - // erase bindings between lowpoly sections and potential load chunks placed inside them + // update bindings between lowpoly sections and potential load chunks placed inside them update_load_sections(); + // z powrotem defaultowa sciezka do tekstur + Global.asCurrentTexturePath = std::string( szTexturePath ); } - MoverParameters->LoadStatus &= 3; // po zakończeniu będzie równe zero } void @@ -6463,13 +6456,12 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co TModel3d * TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const { - if( Name.empty() ) { return nullptr; } - + auto const loadname { ( Name.empty() ? "none" : Name ) }; TModel3d *loadmodel { nullptr }; // check if we don't have model override for this load type { - auto const lookup { LoadModelOverrides.find( Name ) }; + auto const lookup { LoadModelOverrides.find( loadname ) }; if( lookup != LoadModelOverrides.end() ) { loadmodel = TModelsManager::GetModel( asBaseDir + lookup->second, true ); // if the override was succesfully loaded call it a day @@ -6479,13 +6471,13 @@ TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const { // regular routine if there's no override or it couldn't be loaded // try first specialized version of the load model, vehiclename_loadname { - auto const specializedloadfilename { asBaseDir + MoverParameters->TypeName + "_" + Name }; + auto const specializedloadfilename { asBaseDir + MoverParameters->TypeName + "_" + loadname }; loadmodel = TModelsManager::GetModel( specializedloadfilename, true, false ); if( loadmodel != nullptr ) { return loadmodel; } } // try generic version of the load model next, loadname { - auto const genericloadfilename { asBaseDir + Name }; + auto const genericloadfilename { asBaseDir + loadname }; loadmodel = TModelsManager::GetModel( genericloadfilename, true, false ); if( loadmodel != nullptr ) { return loadmodel; } } @@ -7622,10 +7614,9 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } } } - // inverter sounds if( Vehicle.EngineType == TEngineType::ElectricInductionMotor ) { - if( Vehicle.InverterFrequency > 0.1 ) { + if( Vehicle.InverterFrequency > 0.001 ) { volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::abs( Vehicle.eimv_pr) ); diff --git a/Globals.cpp b/Globals.cpp index 3ba864ec..925973eb 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -78,12 +78,6 @@ global_settings::ConfigParse(cParser &Parser) { Parser.getTokens(1, false); Parser >> iWindowHeight; - } - else if (token == "heightbase") - { - Parser.getTokens(1, false); - Parser >> fDistanceFactor; - fDistanceFactor = clamp( fDistanceFactor, 250.f, 10000.f ); // arbitrary limits to keep users from hurting themselves } else if (token == "targetfps") { @@ -94,6 +88,7 @@ global_settings::ConfigParse(cParser &Parser) { { Parser.getTokens(1); Parser >> BaseDrawRange; + BaseDrawRange = clamp( BaseDrawRange, 500.f, 5000.f ); // arbitrary limits to keep users from hurting themselves } else if (token == "fullscreen") { @@ -965,7 +960,6 @@ global_settings::export_as_text( std::ostream &Output ) const { export_as_text( Output, "fieldofview", FieldOfView ); export_as_text( Output, "width", iWindowWidth ); export_as_text( Output, "height", iWindowHeight ); - export_as_text( Output, "heightbase", fDistanceFactor ); export_as_text( Output, "targetfps", targetfps ); export_as_text( Output, "basedrawrange", BaseDrawRange ); export_as_text( Output, "fullscreen", bFullScreen ); diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index b3f5e224..fcac5162 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1569,6 +1569,7 @@ public: load_attributes LoadType; std::string LoadQuantity; // jednostki miary int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model + bool LoadTypeChange{ false }; // indicates load type was changed double LastLoadChangeTime = 0.0; //raz (roz)ładowania #ifdef EU07_USEOLDDOORCODE bool DoorBlocked = false; //Czy jest blokada drzwi diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index a9034ebe..e8387e95 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -7988,6 +7988,7 @@ TMoverParameters::AssignLoad( std::string const &Name, float const Amount ) { if( Name.empty() ) { // empty the vehicle if requested + LoadTypeChange = ( LoadType.name != Name ); LoadType = load_attributes(); LoadAmount = 0.f; return true; @@ -7997,6 +7998,7 @@ TMoverParameters::AssignLoad( std::string const &Name, float const Amount ) { for( auto const &loadattributes : LoadAttributes ) { if( Name == loadattributes.name ) { + LoadTypeChange = ( LoadType.name != Name ); LoadType = loadattributes; LoadAmount = clamp( Amount, 0.f, MaxLoad ) ; ComputeMass(); diff --git a/driveruipanels.cpp b/driveruipanels.cpp index e5756a79..2074d091 100644 --- a/driveruipanels.cpp +++ b/driveruipanels.cpp @@ -907,6 +907,7 @@ debug_panel::update_section_engine( std::vector &Output ) { Output.emplace_back( parameters, Global.UITextColor ); } + Output.emplace_back( "Inverter:\n frequency: " + to_string( mover.InverterFrequency, 2 ), Global.UITextColor ); } // diesel engine data if( mover.EngineType == TEngineType::DieselEngine ) { diff --git a/version.h b/version.h index 1f91f01b..ebc36200 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 20 -#define VERSION_MINOR 728 +#define VERSION_MINOR 731 #define VERSION_REVISION 0