mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 05:02:45 +01:00
fix(model): EU07M review of #540: stopped clips held per instance, events over clips, the rest of a matrix node from its matrix
- stop_clips() holds each clip at the moment it was stopped instead of dropping it: the pose lives in the submodels the instances of a model share, so an instance whose clips were cleared snapped back to rest as soon as another instance of the model played one (two doors of one model). - RaPrepare() applies the clips before the animation events of the scenery, so an event moving a node (rotate, translate...) takes it over from a clip, one ended or stopped included; before, a finished clip overrode the events on its nodes on every draw. - A node with a matrix (XFRM) has its TRS fields only as an approximation: the parts the tracks of a clip don't move are taken from the decomposed matrix, so the node no longer jumps or skews when a clip starts moving another part of it. - The spec says so.
This commit is contained in:
+13
-3
@@ -755,10 +755,12 @@ void TAnimModel::RaPrepare()
|
||||
TSubModel::iVariantSeed = 0;
|
||||
TSubModel::pasText = &asText; // przekazanie tekstu do wyświetlacza (!!!! do przemyślenia)
|
||||
|
||||
// the clips first: an animation event of the scenery on a node (rotate, translate...) takes over from a clip on the same node,
|
||||
// one which ended or was stopped included, as the later one set on the submodel counts
|
||||
apply_clips();
|
||||
for (auto entry : m_animlist) {
|
||||
entry->PrepareModel();
|
||||
}
|
||||
apply_clips();
|
||||
}
|
||||
|
||||
// the state of the lit and the dark part of a numbered light, as RaPrepare() shows them
|
||||
@@ -813,7 +815,15 @@ bool TAnimModel::play_clip( std::string_view const Name, float const Speed ) {
|
||||
|
||||
void TAnimModel::stop_clips() {
|
||||
|
||||
m_clips.clear();
|
||||
// the clips are held where they are, not dropped: the pose lives in the submodels the instances of the model share, so the
|
||||
// nodes of this instance are set again for each of its draws (apply_clips()), or another instance playing a clip would leave
|
||||
// them at rest
|
||||
auto const now { Timer::GetTime() };
|
||||
for( auto &playing : m_clips ) {
|
||||
if( false == playing.held.has_value() ) {
|
||||
playing.held = ( now - playing.start ) * playing.speed;
|
||||
}
|
||||
}
|
||||
m_autoplaystarted = true;
|
||||
}
|
||||
|
||||
@@ -835,7 +845,7 @@ void TAnimModel::apply_clips() {
|
||||
auto const count { pModel->submodel_count() };
|
||||
for( auto const &playing : m_clips ) {
|
||||
auto const &clip { clips[ playing.clip ] };
|
||||
auto const time { animation::clip_time( clip, ( now - playing.start ) * playing.speed ) };
|
||||
auto const time { animation::clip_time( clip, playing.held.value_or( ( now - playing.start ) * playing.speed ) ) };
|
||||
for( auto const &node : clip.nodes ) {
|
||||
if( ( node.node < 0 ) || ( node.node >= count ) ) { continue; }
|
||||
root[ node.node ].SetClipTransform( animation::local_transform( clip, node, time ) );
|
||||
|
||||
Reference in New Issue
Block a user