18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 16:36:53 +01:00

fix(events): EU07M review of #542: clip names keep their case and match regardless of it, an event without a pace told

- The clip event reads the name of the clip as written (getTokens lowercased it), and play_clip() finds the clip
  regardless of case, as the submodels are found by their names: a clip named Open or Armature|Wave couldn't be started
  from a scenery.
- An event without a pace (clip <name> endevent) plays the clip at its own pace with a line in the log, and leaves the
  keyword it met to the event: before, endevent was read as a pace of 0 (stopping the clips) and the next token was
  swallowed.
- Pace 0 with several instances of one model is held by #540's fix (the clips stopped stay set per instance).
- The spec says so.
This commit is contained in:
maj00r
2026-11-29 18:19:19 +01:00
parent bf8bb0caa0
commit 7b6bdf22bb
3 changed files with 20 additions and 4 deletions
+3 -1
View File
@@ -267,7 +267,9 @@ Części węzła bez ścieżki zostają takie, jak w jego TRS.
instancjonowany. Klip ruszający jointami skóry zgina skinowane części (sekcja „Skinning”).
- **Event scenerii.** `event <nazwa> animation <opóźnienie> <model> clip <klip> <tempo> endevent` startuje klip od
początku w podanym tempie (klip już grający zaczyna od nowa), a tempo 0 zatrzymuje klipy modelu; węzły zostają tam,
gdzie klip je zostawił. Klip, którego model nie ma, daje w logu `Bad event: ... can't find clip`. To nowa forma
gdzie klip je zostawił. Nazwa klipu jest porównywana bez względu na wielkość liter, jak nazwy submodeli. Event bez
tempa (`clip <klip> endevent`) gra klip w jego tempie i daje w logu `Bad event: ... gives no pace for clip`. Klip,
którego model nie ma, daje w logu `Bad event: ... can't find clip`. To nowa forma
eventu `animation`, której obecne wydanie nie czyta; dotychczasowe formy (`rotate`, `translate`, `digital`, `.vmd`)
czytają się jak dotąd.
- **Jeszcze nie:** powiązanie kanałów `CHNL` z czasem klipu. Obecne wydanie nie czyta sekcji klipów, a plik bez nich
+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"
@@ -802,7 +805,11 @@ bool TAnimModel::play_clip( std::string_view const Name, float const Speed ) {
if( pModel == nullptr ) { return false; }
auto const &clips { pModel->clips() };
auto const found { std::ranges::find( clips, Name, &animation::clip::name ) };
// the name regardless of case, as the submodels are found by theirs
auto const same { [ Name ]( animation::clip const &Clip ) {
return std::ranges::equal( Clip.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( clips, same ) };
if( found == clips.end() ) { return false; }
auto const index { static_cast<std::size_t>( std::distance( clips.begin(), found ) ) };
std::erase_if( m_clips, [ index ]( clip_playing const &Playing ) { return Playing.clip == index; } );
+9 -2
View File
@@ -1662,11 +1662,18 @@ animation_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad )
>> m_animationparams[ 3 ];
}
else if( token == "clip" ) {
// an animation clip of the model (EU07M): its name and pace; a pace of 0 stops the clips playing
Input.getTokens();
// an animation clip of the model (EU07M): its name, as written (the parser would lowercase it), and pace; a pace of 0
// stops the clips playing
Input.getTokens( 1, false );
Input >> m_animationsubmodel;
m_animationtype = clip_animation;
Input.getTokens( 1 );
if( is_keyword( Input.peek() ) ) {
// no pace: the clip plays at its own, and the keyword read is the next token of the event, not a number of it
m_animationparams[ 0 ] = 1.0;
ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") gives no pace for clip \"" + m_animationsubmodel + "\", it plays at its own" );
return;
}
Input >> m_animationparams[ 0 ];
}
else if( token.ends_with(".vmd") ) // na razie tu, może będzie inaczej