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

build 170725. cab control sound support tweaks, excluded track nodes from casting shadows

This commit is contained in:
tmj-fstate
2017-07-25 18:34:24 +02:00
parent 2f1358422d
commit 000603877c
3 changed files with 18 additions and 12 deletions

View File

@@ -139,8 +139,8 @@ TGauge::Load_mapping( cParser &Input ) {
} }
else if( key.find( "sound" ) == 0 ) { else if( key.find( "sound" ) == 0 ) {
// sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value // sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value
auto const indexstart = key.find_first_of( "1234567890" ); auto const indexstart = key.find_first_of( "-1234567890" );
auto const indexend = key.find_first_not_of( "1234567890", indexstart ); auto const indexend = key.find_first_not_of( "-1234567890", indexstart );
if( indexstart != std::string::npos ) { if( indexstart != std::string::npos ) {
m_soundfxvalues.emplace( m_soundfxvalues.emplace(
std::stoi( key.substr( indexstart, indexend - indexstart ) ), std::stoi( key.substr( indexstart, indexend - indexstart ) ),
@@ -180,17 +180,20 @@ void TGauge::DecValue(double fNewDesired)
void void
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) { TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == static_cast<int>( 100.0 * fNewDesired ) ) { auto const desiredtimes100 = static_cast<int>( 100.0 * fNewDesired );
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == desiredtimes100 ) {
return; return;
} }
fDesiredValue = fNewDesired * fScale + fOffset; fDesiredValue = fNewDesired * fScale + fOffset;
// if there's any sound associated with new requested value, play it // if there's any sound associated with new requested value, play it
// check value-specific table first... // check value-specific table first...
auto const desiredvalue = static_cast<int>( std::round( fNewDesired ) ); if( desiredtimes100 % 100 == 0 ) {
auto const lookup = m_soundfxvalues.find( desiredvalue ); // filter out values other than full integers
if( lookup != m_soundfxvalues.end() ) { auto const lookup = m_soundfxvalues.find( desiredtimes100 / 100 );
play( lookup->second ); if( lookup != m_soundfxvalues.end() ) {
return; play( lookup->second );
return;
}
} }
// ...and if there isn't any, fall back on the basic set... // ...and if there isn't any, fall back on the basic set...
auto const currentvalue = GetValue(); auto const currentvalue = GetValue();

View File

@@ -1258,10 +1258,10 @@ opengl_renderer::Render( TGroundNode *Node ) {
case TP_TRACK: { case TP_TRACK: {
// setup // setup
::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
switch( m_renderpass.draw_mode ) { switch( m_renderpass.draw_mode ) {
case rendermode::shadows: {
return false;
}
case rendermode::pickscenery: { case rendermode::pickscenery: {
// add the node to the pick list // add the node to the pick list
m_picksceneryitems.emplace_back( Node ); m_picksceneryitems.emplace_back( Node );
@@ -1271,6 +1271,9 @@ opengl_renderer::Render( TGroundNode *Node ) {
break; break;
} }
} }
::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
// render // render
Render( Node->pTrack ); Render( Node->pTrack );
// post-render cleanup // post-render cleanup

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 17 #define VERSION_MAJOR 17
#define VERSION_MINOR 724 #define VERSION_MINOR 725
#define VERSION_REVISION 0 #define VERSION_REVISION 0