diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-11-30 14:01:33 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2021-01-05 16:03:52 +0000 |
commit | ddcff225991192bb596e05ec09f7c1a9e6872c7a (patch) | |
tree | cc1a6b44a17120079821806fbd32c30afcb9b864 | |
parent | 582e7c0aade1f929cf0f02a90ad70b0d6f8834fb (diff) |
Drop use of QVector in GLTFSkeletonLoader
Change-Id: Iacb06149178f02811885f6fbee88713894b5a7b6
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/render/geometry/gltfskeletonloader.cpp | 30 | ||||
-rw-r--r-- | src/render/geometry/gltfskeletonloader_p.h | 18 |
2 files changed, 24 insertions, 24 deletions
diff --git a/src/render/geometry/gltfskeletonloader.cpp b/src/render/geometry/gltfskeletonloader.cpp index 9bd59f54b..8c14ead31 100644 --- a/src/render/geometry/gltfskeletonloader.cpp +++ b/src/render/geometry/gltfskeletonloader.cpp @@ -335,12 +335,12 @@ bool GLTFSkeletonLoader::load(QIODevice *ioDev) SkeletonData GLTFSkeletonLoader::createSkeleton(const QString &skeletonName) { - if (m_skins.isEmpty()) { + if (m_skins.empty()) { qCWarning(Jobs, "glTF file does not contain any skins"); return SkeletonData(); } - Skin *skin = m_skins.begin(); + auto skin = m_skins.begin(); if (!skeletonName.isNull()) { const auto result = std::find_if(m_skins.begin(), m_skins.end(), [skeletonName](const Skin &skin) { return skin.name == skeletonName; }); @@ -348,23 +348,23 @@ SkeletonData GLTFSkeletonLoader::createSkeleton(const QString &skeletonName) skin = result; } - Q_ASSERT(skin != nullptr); - return createSkeletonFromSkin(skin); + Q_ASSERT(skin != m_skins.end()); + return createSkeletonFromSkin(*skin); } -SkeletonData GLTFSkeletonLoader::createSkeletonFromSkin(Skin *skin) const +SkeletonData GLTFSkeletonLoader::createSkeletonFromSkin(const Skin &skin) const { SkeletonData skel; - const int jointCount = skin->jointNodeIndices.size(); - skel.reserve(jointCount); + const auto jointCount = skin.jointNodeIndices.size(); + skel.reserve(int(jointCount)); QHash<const Node *, int> jointIndexMap; for (int i = 0; i < jointCount; ++i) { // Get a pointer to the node for this joint and store it in // a map to the JointInfo index. We can later use this to set // the parent indices of the joints - const Node *node = &m_nodes[skin->jointNodeIndices[i]]; + const Node *node = &m_nodes[skin.jointNodeIndices[i]]; jointIndexMap.insert(node, i); JointInfo joint; @@ -381,10 +381,10 @@ SkeletonData GLTFSkeletonLoader::createSkeletonFromSkin(Skin *skin) const return skel; } -QMatrix4x4 GLTFSkeletonLoader::inverseBindMatrix(Skin *skin, int jointIndex) const +QMatrix4x4 GLTFSkeletonLoader::inverseBindMatrix(const Skin &skin, int jointIndex) const { // Create a matrix and copy the data into it - RawData rawData = accessorData(skin->inverseBindAccessorIndex, jointIndex); + RawData rawData = accessorData(skin.inverseBindAccessorIndex, jointIndex); QMatrix4x4 m; memcpy(m.data(), rawData.data, rawData.byteLength); return m; @@ -552,15 +552,15 @@ bool GLTFSkeletonLoader::processJSONNode(const QJsonObject &json) void GLTFSkeletonLoader::setupNodeParentLinks() { - const int nodeCount = m_nodes.size(); - for (int i = 0; i < nodeCount; ++i) { + const size_t nodeCount = m_nodes.size(); + for (size_t i = 0; i < nodeCount; ++i) { const Node &node = m_nodes[i]; - const QList<int> &childNodeIndices = node.childNodeIndices; + const std::vector<int> &childNodeIndices = node.childNodeIndices; for (const auto childNodeIndex : childNodeIndices) { Q_ASSERT(childNodeIndex < m_nodes.size()); - Node &childNode = m_nodes[childNodeIndex]; + Node &childNode = m_nodes[size_t(childNodeIndex)]; Q_ASSERT(childNode.parentNodeIndex == -1); - childNode.parentNodeIndex = i; + childNode.parentNodeIndex = int(i); } } } diff --git a/src/render/geometry/gltfskeletonloader_p.h b/src/render/geometry/gltfskeletonloader_p.h index c52c71951..448ec0ced 100644 --- a/src/render/geometry/gltfskeletonloader_p.h +++ b/src/render/geometry/gltfskeletonloader_p.h @@ -113,7 +113,7 @@ class GLTFSkeletonLoader QString name; int inverseBindAccessorIndex; - QList<int> jointNodeIndices; + std::vector<int> jointNodeIndices; }; class Node @@ -123,7 +123,7 @@ class GLTFSkeletonLoader explicit Node(const QJsonObject &json); Qt3DCore::Sqt localTransform; - QList<int> childNodeIndices; + std::vector<int> childNodeIndices; QString name; int parentNodeIndex; int cameraIndex; @@ -164,17 +164,17 @@ private: void setupNodeParentLinks(); QByteArray resolveLocalData(const QString &path) const; - SkeletonData createSkeletonFromSkin(Skin *skin) const; - QMatrix4x4 inverseBindMatrix(Skin *skin, int jointIndex) const; + SkeletonData createSkeletonFromSkin(const Skin &skin) const; + QMatrix4x4 inverseBindMatrix(const Skin &skin, int jointIndex) const; RawData accessorData(int accessorIndex, int index) const; QJsonDocument m_json; QString m_basePath; - QVector<BufferData> m_bufferDatas; - QVector<BufferView> m_bufferViews; - QVector<AccessorData> m_accessors; - QVector<Skin> m_skins; - QVector<Node> m_nodes; + std::vector<BufferData> m_bufferDatas; + std::vector<BufferView> m_bufferViews; + std::vector<AccessorData> m_accessors; + std::vector<Skin> m_skins; + std::vector<Node> m_nodes; }; } // namespace Render |