mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
build 200731. empty vehicle load visualization support, basic inverter diagnostics, draw range limits bug fixes
This commit is contained in:
59
DynObj.cpp
59
DynObj.cpp
@@ -2758,7 +2758,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) {
|
|||||||
if( ( m_exchange.unload_count < 0.01 )
|
if( ( m_exchange.unload_count < 0.01 )
|
||||||
&& ( m_exchange.load_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 the exchange is completed (or canceled) close the door, if applicable
|
||||||
if( ( MoverParameters->Doors.close_control == control_t::passenger )
|
if( ( MoverParameters->Doors.close_control == control_t::passenger )
|
||||||
|| ( MoverParameters->Doors.close_control == control_t::mixed ) ) {
|
|| ( 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 );
|
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() {
|
void TDynamicObject::LoadUpdate() {
|
||||||
|
|
||||||
|
MoverParameters->LoadStatus &= ( 1 | 2 ); // po zakończeniu będzie równe zero
|
||||||
// przeładowanie modelu ładunku
|
// przeładowanie modelu ładunku
|
||||||
// Ra: nie próbujemy wczytywać modeli miliony razy podczas renderowania!!!
|
if( MoverParameters->LoadTypeChange ) {
|
||||||
if( ( mdLoad == nullptr )
|
// whether we succeed or not don't try more than once
|
||||||
&& ( MoverParameters->LoadAmount > 0 ) ) {
|
MoverParameters->LoadTypeChange = false;
|
||||||
|
// bieżąca ścieżka do tekstur to dynamic/...
|
||||||
if( false == MoverParameters->LoadType.name.empty() ) {
|
Global.asCurrentTexturePath = asBaseDir;
|
||||||
// bieżąca ścieżka do tekstur to dynamic/...
|
mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name );
|
||||||
Global.asCurrentTexturePath = asBaseDir;
|
// 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
|
||||||
mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name );
|
if( mdLoad != nullptr ) {
|
||||||
// TODO: discern from vehicle component which merely uses vehicle directory and has no animations, so it can be initialized outright
|
mdLoad->Init();
|
||||||
// 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 );
|
|
||||||
}
|
}
|
||||||
// Ra: w MMD można by zapisać położenie modelu ładunku (np. węgiel) w zależności od załadowania
|
// update bindings between lowpoly sections and potential load chunks placed inside them
|
||||||
}
|
|
||||||
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_load_sections();
|
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
|
void
|
||||||
@@ -6463,13 +6456,12 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
TModel3d *
|
TModel3d *
|
||||||
TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const {
|
TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const {
|
||||||
|
|
||||||
if( Name.empty() ) { return nullptr; }
|
auto const loadname { ( Name.empty() ? "none" : Name ) };
|
||||||
|
|
||||||
TModel3d *loadmodel { nullptr };
|
TModel3d *loadmodel { nullptr };
|
||||||
|
|
||||||
// check if we don't have model override for this load type
|
// 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() ) {
|
if( lookup != LoadModelOverrides.end() ) {
|
||||||
loadmodel = TModelsManager::GetModel( asBaseDir + lookup->second, true );
|
loadmodel = TModelsManager::GetModel( asBaseDir + lookup->second, true );
|
||||||
// if the override was succesfully loaded call it a day
|
// 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
|
// regular routine if there's no override or it couldn't be loaded
|
||||||
// try first specialized version of the load model, vehiclename_loadname
|
// 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 );
|
loadmodel = TModelsManager::GetModel( specializedloadfilename, true, false );
|
||||||
if( loadmodel != nullptr ) { return loadmodel; }
|
if( loadmodel != nullptr ) { return loadmodel; }
|
||||||
}
|
}
|
||||||
// try generic version of the load model next, loadname
|
// 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 );
|
loadmodel = TModelsManager::GetModel( genericloadfilename, true, false );
|
||||||
if( loadmodel != nullptr ) { return loadmodel; }
|
if( loadmodel != nullptr ) { return loadmodel; }
|
||||||
}
|
}
|
||||||
@@ -7622,10 +7614,9 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inverter sounds
|
// inverter sounds
|
||||||
if( Vehicle.EngineType == TEngineType::ElectricInductionMotor ) {
|
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) );
|
volume = inverter.m_amplitudeoffset + inverter.m_amplitudefactor * std::sqrt( std::abs( Vehicle.eimv_pr) );
|
||||||
|
|
||||||
|
|||||||
@@ -78,12 +78,6 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
|
|
||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> iWindowHeight;
|
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")
|
else if (token == "targetfps")
|
||||||
{
|
{
|
||||||
@@ -94,6 +88,7 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
{
|
{
|
||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
Parser >> BaseDrawRange;
|
Parser >> BaseDrawRange;
|
||||||
|
BaseDrawRange = clamp( BaseDrawRange, 500.f, 5000.f ); // arbitrary limits to keep users from hurting themselves
|
||||||
}
|
}
|
||||||
else if (token == "fullscreen")
|
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, "fieldofview", FieldOfView );
|
||||||
export_as_text( Output, "width", iWindowWidth );
|
export_as_text( Output, "width", iWindowWidth );
|
||||||
export_as_text( Output, "height", iWindowHeight );
|
export_as_text( Output, "height", iWindowHeight );
|
||||||
export_as_text( Output, "heightbase", fDistanceFactor );
|
|
||||||
export_as_text( Output, "targetfps", targetfps );
|
export_as_text( Output, "targetfps", targetfps );
|
||||||
export_as_text( Output, "basedrawrange", BaseDrawRange );
|
export_as_text( Output, "basedrawrange", BaseDrawRange );
|
||||||
export_as_text( Output, "fullscreen", bFullScreen );
|
export_as_text( Output, "fullscreen", bFullScreen );
|
||||||
|
|||||||
@@ -1569,6 +1569,7 @@ public:
|
|||||||
load_attributes LoadType;
|
load_attributes LoadType;
|
||||||
std::string LoadQuantity; // jednostki miary
|
std::string LoadQuantity; // jednostki miary
|
||||||
int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model
|
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
|
double LastLoadChangeTime = 0.0; //raz (roz)ładowania
|
||||||
#ifdef EU07_USEOLDDOORCODE
|
#ifdef EU07_USEOLDDOORCODE
|
||||||
bool DoorBlocked = false; //Czy jest blokada drzwi
|
bool DoorBlocked = false; //Czy jest blokada drzwi
|
||||||
|
|||||||
@@ -7988,6 +7988,7 @@ TMoverParameters::AssignLoad( std::string const &Name, float const Amount ) {
|
|||||||
|
|
||||||
if( Name.empty() ) {
|
if( Name.empty() ) {
|
||||||
// empty the vehicle if requested
|
// empty the vehicle if requested
|
||||||
|
LoadTypeChange = ( LoadType.name != Name );
|
||||||
LoadType = load_attributes();
|
LoadType = load_attributes();
|
||||||
LoadAmount = 0.f;
|
LoadAmount = 0.f;
|
||||||
return true;
|
return true;
|
||||||
@@ -7997,6 +7998,7 @@ TMoverParameters::AssignLoad( std::string const &Name, float const Amount ) {
|
|||||||
|
|
||||||
for( auto const &loadattributes : LoadAttributes ) {
|
for( auto const &loadattributes : LoadAttributes ) {
|
||||||
if( Name == loadattributes.name ) {
|
if( Name == loadattributes.name ) {
|
||||||
|
LoadTypeChange = ( LoadType.name != Name );
|
||||||
LoadType = loadattributes;
|
LoadType = loadattributes;
|
||||||
LoadAmount = clamp( Amount, 0.f, MaxLoad ) ;
|
LoadAmount = clamp( Amount, 0.f, MaxLoad ) ;
|
||||||
ComputeMass();
|
ComputeMass();
|
||||||
|
|||||||
@@ -907,6 +907,7 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) {
|
|||||||
|
|
||||||
Output.emplace_back( parameters, Global.UITextColor );
|
Output.emplace_back( parameters, Global.UITextColor );
|
||||||
}
|
}
|
||||||
|
Output.emplace_back( "Inverter:\n frequency: " + to_string( mover.InverterFrequency, 2 ), Global.UITextColor );
|
||||||
}
|
}
|
||||||
// diesel engine data
|
// diesel engine data
|
||||||
if( mover.EngineType == TEngineType::DieselEngine ) {
|
if( mover.EngineType == TEngineType::DieselEngine ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user