18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 09:27:10 +01:00

Merge the review fixes of the PRs below from feat/eu07m-skin-compute into feat/eu07m-clip-event

# Conflicts:
#	model/AnimModel.cpp
This commit is contained in:
maj00r
2026-11-29 18:22:25 +01:00
22 changed files with 236 additions and 31 deletions
+16 -3
View File
@@ -572,6 +572,9 @@ void TAnimModel::update_instanceable_flag() {
// gfx.instancedlights: the lights go with the matrix of each instance (instance_light_bits()), and the instanced walk
// animates each instance (RaAnimate) and prepares the model with all the parts of the lights shown (RaPrepareInstanced)
if( ( iNumLights != 0 ) && ( false == Global.gfx_instancedlights ) ) { ++s_rejected_lights; return; }
// light colours of its own (lightcolors of the node) go onto the shared submodels as the instance is prepared (RaPrepare),
// which the instances of a bucket don't each get: such an instance is drawn on its own
if( std::ranges::any_of( m_lightcolors, []( glm::vec3 const &Colour ) { return Colour.r >= 0.f; } ) ) { ++s_rejected_lights; return; }
if( !m_animlist.empty() ) { ++s_rejected_animlist; return; }
if( submodel_tree_blocks_instancing( pModel->Root ) ) { ++s_rejected_animated_submodel; return; }
m_instanceable = true;
@@ -758,10 +761,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
@@ -820,7 +825,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;
}
@@ -842,7 +855,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 ) );