summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-10-05 14:26:26 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-10-05 14:26:26 +0100
commite743158b0b17335ef321c2c378bacfe2697ba5f1 (patch)
treeaadf16da9ddc60ce0b2e84c1b0777e87f9cd080e /src
parentd4fb24c0871320667640f100b743f34f702db6cf (diff)
parent835db3b72e0f14ef80afb22dd084bfc038383481 (diff)
Merge branch '5.9' into 5.10
Conflicts: src/animation/backend/animationutils.cpp Change-Id: I6bd0d1d15da00537a0bb064fc828b2460584b8e8
Diffstat (limited to 'src')
-rw-r--r--src/animation/backend/animationutils.cpp54
-rw-r--r--src/animation/backend/fcurve_p.h25
2 files changed, 61 insertions, 18 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp
index d05d96f38..3e255308b 100644
--- a/src/animation/backend/animationutils.cpp
+++ b/src/animation/backend/animationutils.cpp
@@ -148,6 +148,17 @@ double phaseFromGlobalTime(double t_global, double t_start_global,
return t_local / duration;
}
+/*!
+ \internal
+
+ Calculates the indices required to map from the component ordering within the
+ provided \a channel, into the standard channel orderings expected by Qt types.
+
+ For example, given a channel representing a rotation with the components ordered
+ as X, Y, Z, Y, this function will return the indices [3, 0, 1, 2] which can then
+ later be used as part of the format vector in the formatClipResults() function to
+ remap the channels into the standard W, X, Y, Z order required by QQuaternion.
+*/
ComponentIndices channelComponentsToIndices(const Channel &channel, int dataType, int offset)
{
#if defined Q_COMPILER_UNIFORM_INIT
@@ -171,9 +182,9 @@ ComponentIndices channelComponentsToIndices(const Channel &channel, int dataType
}
ComponentIndices channelComponentsToIndicesHelper(const Channel &channel,
- int dataType,
- int offset,
- const QVector<char> &suffixes)
+ int dataType,
+ int offset,
+ const QVector<char> &suffixes)
{
const int expectedComponentCount = componentsForType(dataType);
const int actualComponentCount = channel.channelComponents.size();
@@ -183,21 +194,37 @@ ComponentIndices channelComponentsToIndicesHelper(const Channel &channel,
}
ComponentIndices indices(expectedComponentCount);
+
+ // Generate the set of channel suffixes
+ QVector<char> channelSuffixes;
+ channelSuffixes.reserve(expectedComponentCount);
for (int i = 0; i < expectedComponentCount; ++i) {
const QString &componentName = channel.channelComponents[i].name;
+
// An unset component name indicates that the no mapping is necessary
// and the index can be used as-is.
if (componentName.isEmpty()) {
indices[i] = i + offset;
continue;
}
- char suffix = componentName.at(componentName.length() - 1).toLatin1();
- int index = suffixes.indexOf(suffix);
+
+ char channelSuffix = componentName.at(componentName.length() - 1).toLatin1();
+ channelSuffixes.push_back(channelSuffix);
+ }
+
+ // We can short-circuit if the channels were all unnamed (in order)
+ if (channelSuffixes.isEmpty())
+ return indices;
+
+ // Find index of standard index in channel indexes
+ for (int i = 0; i < expectedComponentCount; ++i) {
+ int index = channelSuffixes.indexOf(suffixes[i]);
if (index != -1)
indices[i] = index + offset;
else
indices[i] = -1;
}
+
return indices;
}
@@ -642,16 +669,14 @@ ComponentIndices generateClipFormatIndices(const QVector<ChannelNameAndType> &ta
const int componentCount = targetIndices[i].size();
if (clipChannelIndex != -1) {
- // Found a matching channel in the clip. Get the base channel
- // component index and populate the format indices for this channel.
+ // Found a matching channel in the clip. Populate the corresponding
+ // entries in the format vector with the *source indices*
+ // needed to build the formatted results.
const int baseIndex = clip->channelComponentBaseIndex(clipChannelIndex);
-
- // Within this group, match channel names with index ordering
const auto channelIndices = channelComponentsToIndices(clip->channels()[clipChannelIndex],
targetChannel.type,
baseIndex);
std::copy(channelIndices.begin(), channelIndices.end(), formatIt);
-
} else {
// No such channel in this clip. We'll use default values when
// mapping from the clip to the formatted clip results.
@@ -673,11 +698,16 @@ ClipResults formatClipResults(const ClipResults &rawClipResults,
ClipResults formattedClipResults(elementCount);
// Perform a gather operation to format the data
+
// TODO: For large numbers of components do this in parallel with
// for e.g. a parallel_for() like construct
+ // TODO: We could potentially avoid having holes in these intermediate
+ // vectors by adjusting the component indices stored in the MappingData
+ // and format vectors. Needs careful investigation!
for (int i = 0; i < elementCount; ++i) {
- const float value = format[i] != -1 ? rawClipResults[format[i]] : 0.0f;
- formattedClipResults[i] = value;
+ if (format[i] == -1)
+ continue;
+ formattedClipResults[i] = rawClipResults[format[i]];
}
return formattedClipResults;
diff --git a/src/animation/backend/fcurve_p.h b/src/animation/backend/fcurve_p.h
index f2148d1e9..8c5cdd54d 100644
--- a/src/animation/backend/fcurve_p.h
+++ b/src/animation/backend/fcurve_p.h
@@ -98,14 +98,27 @@ private:
inline QDebug operator<<(QDebug dbg, const FCurve &fcurve)
{
QDebugStateSaver saver(dbg);
- dbg << "Keyframe Count =" << fcurve.keyframeCount() << endl;
+ dbg << "Keyframe Count = " << fcurve.keyframeCount() << endl;
for (int i = 0; i < fcurve.keyframeCount(); ++i) {
const Keyframe &kf = fcurve.keyframe(i);
- dbg << "t =" << fcurve.localTime(i)
- << "value =" << kf.value
- << "leftHandle =" << kf.leftControlPoint
- << "rightHandle =" << kf.rightControlPoint
- << endl;
+ switch (kf.interpolation) {
+ case QKeyFrame::BezierInterpolation: {
+ dbg << "t = " << fcurve.localTime(i)
+ << ", value = " << kf.value
+ << ", leftHandle = " << kf.leftControlPoint
+ << ", rightHandle = " << kf.rightControlPoint
+ << endl;
+ break;
+ }
+
+ case QKeyFrame::ConstantInterpolation:
+ case QKeyFrame::LinearInterpolation: {
+ dbg << "t = " << fcurve.localTime(i)
+ << ", value = " << kf.value
+ << endl;
+ break;
+ }
+ }
}
return dbg;
}