18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 07:22:42 +01:00

fix(model): EU07M review of #543: channel names keep their case, the joint moves from its rest value

- The channel event reads the name of the channel as written (getTokens lowercased it), and set_channel() finds it
  regardless of case: a channel named doorLeft couldn't be set from a scenery.
- JOIN.rest is read: the node is modelled at the rest value of its joint, which moves it by the value less rest (the
  limits stay values of the joint). A part modelled half open no longer jumps when its channel is set. Files without it
  (rest 0) move as before.
- The spec says so, and that no vehicle sets channels yet.

Test: a slider modelled half out.
This commit is contained in:
maj00r
2026-11-29 18:20:09 +01:00
parent c6ece72d6a
commit ce40e11b94
7 changed files with 24 additions and 5 deletions
+8 -1
View File
@@ -15,6 +15,9 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "model/AnimModel.h"
#include <algorithm>
#include <cctype>
#include "rendering/renderer.h"
#include "model/MdlMngr.h"
#include "simulation/simulation.h"
@@ -825,7 +828,11 @@ bool TAnimModel::set_channel( std::string_view const Name, float const Value ) {
if( pModel == nullptr ) { return false; }
auto const &channels { pModel->channels() };
auto const found { std::ranges::find( channels, Name, &animation::channel::name ) };
// the name regardless of case, as the submodels are found by theirs
auto const same { [ Name ]( animation::channel const &Channel ) {
return std::ranges::equal( Channel.name, Name, []( char const Left, char const Right ) {
return std::tolower( static_cast<unsigned char>( Left ) ) == std::tolower( static_cast<unsigned char>( Right ) ); } ); } };
auto const found { std::ranges::find_if( channels, same ) };
if( found == channels.end() ) { return false; }
if( m_channels.size() != channels.size() ) {
m_channels.resize( channels.size() );