diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-02-22 11:32:20 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-02-22 12:14:32 +0000 |
commit | 4afd6d3485a097000ad63f94b47886ee8bc9d17d (patch) | |
tree | b26298012a49e53ef05710a91a9ff6faf4136fa8 /src/runtime/q3dsanimationmanager.cpp | |
parent | 533a8b4e278204bb0b6bc3c0c29797eab9c383cf (diff) |
Avoid asserting for incomplete animation channels
The .uip always specifies all components but let's play nice with
programmatically created animations that fail to do this. Forcing the
values for the non-specified channels to 0 is better than getting an
assert.
Change-Id: I8a1f14229c056d50effacfc82eaee977d40ccb3e
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/runtime/q3dsanimationmanager.cpp')
-rw-r--r-- | src/runtime/q3dsanimationmanager.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime/q3dsanimationmanager.cpp b/src/runtime/q3dsanimationmanager.cpp index 9dac47c..8e4f287 100644 --- a/src/runtime/q3dsanimationmanager.cpp +++ b/src/runtime/q3dsanimationmanager.cpp @@ -361,14 +361,23 @@ void Q3DSAnimationManager::updateAnimationHelper(const AnimationTrackListMap<T * // Now a QChannel can be created. chIt->channel.setName(channelName); - // Channels must be fully specified. Fortunately the uip - // documents seem to fulfill this criteria and all 3 - // components are present always. for (int i = 0; i < chIt->meta.componentCount; ++i) { // Leave the component name unset. This way Qt3D will not waste // time on string comparisons for figuring out the right index // (e.g. 1) for e.g. QChannelComponent("BlahBlah Y"), but uses // the component's index (which is already correct) as-is. + + // Channels must be fully specified. The uip documents fulfill + // this criteria and all (1 or 3) components are present + // always, but programmatically created animations may lack + // this. Add a keyframe at 0 with value 0 since this is still + // better than asserting in Qt3D. + if (chIt->comps[i].keyFrameCount() == 0) { + if (animSetupDebug) + qDebug() << " channel component" << i << "has no keyframes; adding dummy one"; + chIt->comps[i].appendKeyFrame(Qt3DAnimation::QKeyFrame(QVector2D(0, 0))); + } + chIt->channel.appendChannelComponent(chIt->comps[i]); if (animSetupDebug) { |