summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-12-11 15:53:59 +0100
committerChristian Stromme <christian.stromme@qt.io>2018-12-12 12:44:01 +0000
commit10fc0d4b691116b7c46be91d5490b6a476f0747e (patch)
tree4cef54dd17de10e35b9715c7432a5ba982067893 /src
parent1eb1f09fcc36220dcb9030e4455b69435bfc9b94 (diff)
Use vec3 for storing the animation values
There's no real use-case for vec4 at the moment. Change-Id: Ie7d03e07fa3b411c30c23e493c0216bd487cedb6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/animator/q3dsanimator.cpp15
-rw-r--r--src/runtime/animator/q3dsanimator_p.h7
-rw-r--r--src/runtime/slideplayerng/q3dsanimationmanagerng.cpp36
3 files changed, 22 insertions, 36 deletions
diff --git a/src/runtime/animator/q3dsanimator.cpp b/src/runtime/animator/q3dsanimator.cpp
index 1b5bb54..b5d53f6 100644
--- a/src/runtime/animator/q3dsanimator.cpp
+++ b/src/runtime/animator/q3dsanimator.cpp
@@ -78,9 +78,9 @@ void syncDirtyProperties(const QVector<Q3DSNodeAnimation::DirtyProperty> &dirtyP
return;
}
- const auto &vec4 = property->vec4;
+ const auto &vec3 = property->vec3;
changeFlags = property->changeFlags;
- static const auto toTargetVariant = [](QVariant::Type type, const QVector4D &v) {
+ static const auto toTargetVariant = [](QVariant::Type type, const QVector3D &v) {
switch (int(type)) {
case QVariant::Double:
Q_FALLTHROUGH();
@@ -89,8 +89,6 @@ void syncDirtyProperties(const QVector<Q3DSNodeAnimation::DirtyProperty> &dirtyP
case QVariant::Vector2D:
return QVariant::fromValue(v.toVector2D());
case QVariant::Vector3D:
- return QVariant::fromValue(v.toVector3D());
- case QVariant::Vector4D:
return QVariant::fromValue(v);
case QVariant::Color:
return QVariant::fromValue(QColor::fromRgbF(qreal(v.x()), qreal(v.y()), qreal(v.z())));
@@ -99,7 +97,7 @@ void syncDirtyProperties(const QVector<Q3DSNodeAnimation::DirtyProperty> &dirtyP
}
};
- const QVariant &variant = toTargetVariant(type, vec4);
+ const QVariant &variant = toTargetVariant(type, vec3);
if (Q_UNLIKELY(!variant.isValid())) {
qWarning("The unsupported type %d attempted used on %s", type, target->id().constData());
continue;
@@ -128,7 +126,7 @@ void evaluateNodesAt(const Q3DSAnimator::AnimationList::const_iterator &animBegi
const auto &propertiesEnd = properties.cend();
const auto &keyFrames = animIt->keyFrames;
while (propertiesIt != propertiesEnd) {
- auto &v = propertiesIt->vec4;
+ auto &v = propertiesIt->vec3;
const auto &components = propertiesIt->componentFlags;
if (Q_UNLIKELY(components == Components::None)) {
qWarning("Property animation without no component specified!");
@@ -152,11 +150,6 @@ void evaluateNodesAt(const Q3DSAnimator::AnimationList::const_iterator &animBegi
const auto cend = cbegin + propertiesIt->components[2].size - 1;
changed |= evaluateAnimation(cbegin, cend, time, &v[2]);
}
- if (components & Components::W) {
- const auto cbegin = keyFrames.cbegin() + propertiesIt->components[3].offset;
- const auto cend = cbegin + propertiesIt->components[3].size - 1;
- changed |= evaluateAnimation(cbegin, cend, time, &v[3]);
- }
if (changed)
dirtyList->push_back({propertiesIt, target});
diff --git a/src/runtime/animator/q3dsanimator_p.h b/src/runtime/animator/q3dsanimator_p.h
index d7e933b..6a61c5c 100644
--- a/src/runtime/animator/q3dsanimator_p.h
+++ b/src/runtime/animator/q3dsanimator_p.h
@@ -64,7 +64,6 @@ struct Q3DSNodeAnimation
X = 0x1,
Y = 0x2,
Z = 0x4,
- W = 0x8,
Dynamic = 0x10
};
struct Component
@@ -72,8 +71,8 @@ struct Q3DSNodeAnimation
// Offset and length into the KeyFrameList
quint16 offset;
quint16 size;
- } components[4];
- mutable QVector4D vec4;
+ } components[3];
+ mutable QVector3D vec3;
qint16 pid;
qint8 changeFlags;
Components componentFlags;
@@ -91,7 +90,7 @@ struct Q3DSNodeAnimation
Q3DSGraphObject *target;
PropertyList properties;
- KeyFrameList keyFrames; // Should be ordered (x, y, z, w, x, ...)
+ KeyFrameList keyFrames; // Should be ordered (x, y, z, x, ...)
};
Q_DECLARE_TYPEINFO(Q3DSNodeAnimation, Q_MOVABLE_TYPE);
diff --git a/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp b/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp
index 0ec2b0f..39a277d 100644
--- a/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp
+++ b/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp
@@ -37,30 +37,28 @@ QT_BEGIN_NAMESPACE
static constexpr qint8 componentSuffixToIndex(qint8 c)
{
- return (c >= 'w' && c <= 'z') ? (c == 'w') ? 3 : (c - 'x') : -1;
+ return (c >= 'x' && c <= 'z') ? (c - 'x') : -1;
}
-static QVector4D toVector4D(const QVariant &qv)
+static QVector3D toVector3D(const QVariant &qv)
{
switch (int(qv.type())) {
case QVariant::Double:
Q_FALLTHROUGH();
case QMetaType::Float:
- return QVector4D{QVector2D{*reinterpret_cast<const float *>(qv.constData()), 0.0f}};
+ return QVector3D{QVector2D{*reinterpret_cast<const float *>(qv.constData()), 0.0f}};
case QVariant::Vector2D:
- return QVector4D{*reinterpret_cast<const QVector2D *>(qv.constData())};
+ return QVector3D{*reinterpret_cast<const QVector2D *>(qv.constData())};
case QVariant::Vector3D:
- return QVector4D{*reinterpret_cast<const QVector3D *>(qv.constData())};
- case QVariant::Vector4D:
- return *reinterpret_cast<const QVector4D *>(qv.constData());
+ return *reinterpret_cast<const QVector3D *>(qv.constData());
case QVariant::Color:
{
const auto c = qv.value<QColor>();
- return QVector4D{QVector3D{float(c.redF()), float(c.greenF()), float(c.blueF())}};
+ return QVector3D{float(c.redF()), float(c.greenF()), float(c.blueF())};
}
default:
qCWarning(lcAnim, "The unsupported type %s attempted used!", qv.typeName());
- return QVector4D();
+ return QVector3D();
}
};
@@ -193,9 +191,9 @@ void Q3DSAnimationManagerNg::buildSlideAnimation(Q3DSSlide *slide, bool rebuild)
const auto &atracks = propTrack.value();
const int pid = Q3DSGraphObject::indexOfProperty(target, property.toLatin1());
Q_ASSERT(pid != -1);
- QVector4D vec4;
+ QVector3D vec3;
quint8 compFlag = 0;
- for (int compPos = 0; compPos != 4; ++compPos) {
+ for (int compPos = 0; compPos != 3; ++compPos) {
const auto trackPtr = atracks.at(compPos);
if (!trackPtr)
continue;
@@ -203,7 +201,7 @@ void Q3DSAnimationManagerNg::buildSlideAnimation(Q3DSSlide *slide, bool rebuild)
const auto componentKeyFrames = buildKeyFramesForTrack(*trackPtr);
// Get the start value, which is the value of the first kf.
if (componentKeyFrames.size() > 0)
- vec4[compPos] = componentKeyFrames.at(0).value;
+ vec3[compPos] = componentKeyFrames.at(0).value;
compFlag |= (1 << compPos);
const int offset = nodeAnimation.keyFrames.size();
const int size = componentKeyFrames.size();
@@ -215,7 +213,7 @@ void Q3DSAnimationManagerNg::buildSlideAnimation(Q3DSSlide *slide, bool rebuild)
}
const int changeFlag = targetIt.key()->mapChangeFlags({{property}});
- nodeProperty.vec4 = vec4;
+ nodeProperty.vec3 = vec3;
nodeProperty.changeFlags = qint8(changeFlag);
nodeProperty.componentFlags = static_cast<Q3DSNodeAnimation::Property::Components>(compFlag);
nodeProperty.pid = qint16(pid);
@@ -240,24 +238,20 @@ void Q3DSAnimationManagerNg::updateDynamicKeyFrames(Q3DSSlide *slide)
for (auto &animNode : animations) {
using Component = Q3DSNodeAnimation::Property::Components;
for (const auto &property : qAsConst(animNode.properties)) {
- const auto vec4 = toVector4D(Q3DSGraphObject::readProperty(animNode.target, property.pid));
+ const auto vec3 = toVector3D(Q3DSGraphObject::readProperty(animNode.target, property.pid));
if ((property.componentFlags & Component::Dynamic) == 0)
continue;
if (property.componentFlags & Component::X) {
auto &kf = *(animNode.keyFrames.begin() + property.components[0].offset);
- kf.value = kf.c1.value = kf.c2.value = vec4[0];
+ kf.value = kf.c1.value = kf.c2.value = vec3[0];
}
if (property.componentFlags & Component::Y) {
auto &kf = *(animNode.keyFrames.begin() + property.components[1].offset);
- kf.value = kf.c1.value = kf.c2.value = vec4[1];
+ kf.value = kf.c1.value = kf.c2.value = vec3[1];
}
if (property.componentFlags & Component::Z) {
auto &kf = *(animNode.keyFrames.begin() + property.components[2].offset);
- kf.value = kf.c1.value = kf.c2.value = vec4[2];
- }
- if (property.componentFlags & Component::W) {
- auto &kf = *(animNode.keyFrames.begin() + property.components[3].offset);
- kf.value = kf.c1.value = kf.c2.value = vec4[3];
+ kf.value = kf.c1.value = kf.c2.value = vec3[2];
}
}
}