mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 18:39:18 +02:00
build 190929. jointctrl cab control animation tweak, vehicle attachment support fixes, axle clatter fix, python module error logging fix
This commit is contained in:
34
DynObj.cpp
34
DynObj.cpp
@@ -3163,12 +3163,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
if( MyTrack->fSoundDistance != dRailLength ) {
|
if( MyTrack->fSoundDistance != dRailLength ) {
|
||||||
if( dRailLength > 0.0 ) {
|
if( dRailLength > 0.0 ) {
|
||||||
for( auto &axle : m_axlesounds ) {
|
for( auto &axle : m_axlesounds ) {
|
||||||
axle.distance =
|
axle.distance = axle.offset;
|
||||||
clamp_circular<double>(
|
|
||||||
axle.distance - dRailLength
|
|
||||||
+ axle.offset
|
|
||||||
/* - 0.5 * MoverParameters->Dim.L */,
|
|
||||||
MyTrack->fSoundDistance );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dRailLength = MyTrack->fSoundDistance;
|
dRailLength = MyTrack->fSoundDistance;
|
||||||
@@ -3197,8 +3192,14 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
}
|
}
|
||||||
if( dRailLength > 0.0 ) {
|
if( dRailLength > 0.0 ) {
|
||||||
auto axleindex { 0 };
|
auto axleindex { 0 };
|
||||||
|
auto const directioninconsist { (
|
||||||
|
ctOwner == nullptr ?
|
||||||
|
1 :
|
||||||
|
( ctOwner->Vehicle()->DirectionGet() == DirectionGet() ?
|
||||||
|
1 :
|
||||||
|
-1 ) ) };
|
||||||
for( auto &axle : m_axlesounds ) {
|
for( auto &axle : m_axlesounds ) {
|
||||||
axle.distance += dDOMoveLen * DirectionGet();
|
axle.distance += dDOMoveLen * directioninconsist;
|
||||||
if( ( axle.distance < 0 )
|
if( ( axle.distance < 0 )
|
||||||
|| ( axle.distance > dRailLength ) ) {
|
|| ( axle.distance > dRailLength ) ) {
|
||||||
axle.distance = clamp_circular( axle.distance, dRailLength );
|
axle.distance = clamp_circular( axle.distance, dRailLength );
|
||||||
@@ -4470,15 +4471,15 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
// each value is a name of additional 3d model
|
// each value is a name of additional 3d model
|
||||||
// value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly
|
// value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly
|
||||||
// TBD: reconsider something more yaml-compliant and/or ability to define offset and rotation
|
// TBD: reconsider something more yaml-compliant and/or ability to define offset and rotation
|
||||||
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
while( ( ( token = deserialize_random_set( parser ) ) != "" )
|
||||||
&& ( token != "}" ) ) {
|
&& ( token != "}" ) ) {
|
||||||
auto attachmentmodelname { deserialize_random_set( parser ) };
|
if( token == "{" ) { continue; }
|
||||||
replace_slashes( attachmentmodelname );
|
replace_slashes( token );
|
||||||
Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/...
|
Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/...
|
||||||
auto *attachmentmodel { TModelsManager::GetModel( asBaseDir + attachmentmodelname, true ) };
|
auto *attachmentmodel { TModelsManager::GetModel( asBaseDir + token, true ) };
|
||||||
if( attachmentmodel != nullptr ) {
|
if( attachmentmodel != nullptr ) {
|
||||||
mdAttachments.emplace_back( attachmentmodel );
|
mdAttachments.emplace_back( attachmentmodel );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5770,6 +5771,9 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
mdLoad->Init();
|
mdLoad->Init();
|
||||||
if (mdLowPolyInt)
|
if (mdLowPolyInt)
|
||||||
mdLowPolyInt->Init();
|
mdLowPolyInt->Init();
|
||||||
|
for( auto *attachment : mdAttachments ) {
|
||||||
|
attachment->Init();
|
||||||
|
}
|
||||||
|
|
||||||
Global.asCurrentTexturePath = szTexturePath; // kiedyś uproszczone wnętrze mieszało tekstury nieba
|
Global.asCurrentTexturePath = szTexturePath; // kiedyś uproszczone wnętrze mieszało tekstury nieba
|
||||||
Global.asCurrentDynamicPath = "";
|
Global.asCurrentDynamicPath = "";
|
||||||
|
|||||||
11
PyInt.cpp
11
PyInt.cpp
@@ -192,8 +192,7 @@ auto python_taskqueue::run_file( std::string const &File, std::string const &Pat
|
|||||||
if( lookup.first.empty() ) { return false; }
|
if( lookup.first.empty() ) { return false; }
|
||||||
|
|
||||||
std::ifstream inputfile { lookup.first + lookup.second };
|
std::ifstream inputfile { lookup.first + lookup.second };
|
||||||
std::string input;
|
std::string const input { std::istreambuf_iterator<char>( inputfile ), std::istreambuf_iterator<char>() };
|
||||||
input.assign( std::istreambuf_iterator<char>( inputfile ), std::istreambuf_iterator<char>() );
|
|
||||||
|
|
||||||
if( PyRun_SimpleString( input.c_str() ) != 0 ) {
|
if( PyRun_SimpleString( input.c_str() ) != 0 ) {
|
||||||
error();
|
error();
|
||||||
@@ -215,7 +214,7 @@ void python_taskqueue::release_lock() {
|
|||||||
PyEval_SaveThread();
|
PyEval_SaveThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto python_taskqueue::fetch_renderer( std::string const Renderer ) ->PyObject * {
|
auto python_taskqueue::fetch_renderer( std::string const Renderer ) -> PyObject * {
|
||||||
|
|
||||||
auto const lookup { m_renderers.find( Renderer ) };
|
auto const lookup { m_renderers.find( Renderer ) };
|
||||||
if( lookup != std::end( m_renderers ) ) {
|
if( lookup != std::end( m_renderers ) ) {
|
||||||
@@ -296,7 +295,9 @@ void python_taskqueue::run( GLFWwindow *Context, rendertask_sequence &Tasks, thr
|
|||||||
{
|
{
|
||||||
// execute python code
|
// execute python code
|
||||||
task->run();
|
task->run();
|
||||||
error();
|
if( PyErr_Occurred() != nullptr ) {
|
||||||
|
error();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// clear the thread state
|
// clear the thread state
|
||||||
PyEval_SaveThread();
|
PyEval_SaveThread();
|
||||||
@@ -318,8 +319,6 @@ void python_taskqueue::run( GLFWwindow *Context, rendertask_sequence &Tasks, thr
|
|||||||
void
|
void
|
||||||
python_taskqueue::error() {
|
python_taskqueue::error() {
|
||||||
|
|
||||||
if( PyErr_Occurred() == nullptr ) { return; }
|
|
||||||
|
|
||||||
if( m_stderr != nullptr ) {
|
if( m_stderr != nullptr ) {
|
||||||
// std err pythona jest buforowane
|
// std err pythona jest buforowane
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
|||||||
@@ -6244,10 +6244,13 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
if( ggJointCtrl.SubModel != nullptr ) {
|
if( ggJointCtrl.SubModel != nullptr ) {
|
||||||
// joint master controller moves forward to adjust power and backward to adjust brakes
|
// joint master controller moves forward to adjust power and backward to adjust brakes
|
||||||
auto const brakerangemultiplier {
|
auto const brakerangemultiplier {
|
||||||
|
/* NOTE: scaling disabled as it was conflicting with associating sounds with control positions
|
||||||
( mvControlled->CoupledCtrl ?
|
( mvControlled->CoupledCtrl ?
|
||||||
mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo :
|
mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo :
|
||||||
mvControlled->MainCtrlPosNo )
|
mvControlled->MainCtrlPosNo )
|
||||||
/ static_cast<double>(LocalBrakePosNo) };
|
/ static_cast<double>(LocalBrakePosNo)
|
||||||
|
*/
|
||||||
|
1 };
|
||||||
ggJointCtrl.UpdateValue(
|
ggJointCtrl.UpdateValue(
|
||||||
( mvOccupied->LocalBrakePosA > 0.0 ? mvOccupied->LocalBrakePosA * LocalBrakePosNo * -1 * brakerangemultiplier :
|
( mvOccupied->LocalBrakePosA > 0.0 ? mvOccupied->LocalBrakePosA * LocalBrakePosNo * -1 * brakerangemultiplier :
|
||||||
mvControlled->CoupledCtrl ? double( mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos ) :
|
mvControlled->CoupledCtrl ? double( mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos ) :
|
||||||
|
|||||||
Reference in New Issue
Block a user