Prechádzať zdrojové kódy

Fixed warnings (#5903)

* Fixed conversion warning when compiling without ASSIMP_DOUBLE_PRECISION. Fixed size() <> unsigned warnings

* Fix: Review finding

---------

Co-authored-by: Kim Kulling <[email protected]>
sacereda 9 mesiacov pred
rodič
commit
862abe410b

+ 13 - 12
code/AssetLib/USD/USDLoaderImplTinyusdz.cpp

@@ -230,10 +230,10 @@ void USDImporterImplTinyusdz::animations(
         return;
     }
 
-    pScene->mNumAnimations = render_scene.animations.size();
+    pScene->mNumAnimations = unsigned(render_scene.animations.size());
     pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations];
 
-    for (int animationIndex = 0; animationIndex < pScene->mNumAnimations; ++animationIndex) {
+    for (unsigned animationIndex = 0; animationIndex < pScene->mNumAnimations; ++animationIndex) {
 
         const auto &animation = render_scene.animations[animationIndex];
 
@@ -249,7 +249,8 @@ void USDImporterImplTinyusdz::animations(
 
         // each channel affects a node (joint)
         newAiAnimation->mTicksPerSecond = render_scene.meta.framesPerSecond;
-        newAiAnimation->mNumChannels = animation.channels_map.size();
+        newAiAnimation->mNumChannels = unsigned(animation.channels_map.size());
+
         newAiAnimation->mChannels = new aiNodeAnim *[newAiAnimation->mNumChannels];
         int channelIndex = 0;
         for (const auto &[jointName, animationChannelMap] : animation.channels_map) {
@@ -330,15 +331,15 @@ void USDImporterImplTinyusdz::animations(
                 }
             }
 
-            newAiNodeAnim->mNumPositionKeys = positionKeys.size();
+            newAiNodeAnim->mNumPositionKeys = unsigned(positionKeys.size());
             newAiNodeAnim->mPositionKeys = new aiVectorKey[newAiNodeAnim->mNumPositionKeys];
             std::move(positionKeys.begin(), positionKeys.end(), newAiNodeAnim->mPositionKeys);
 
-            newAiNodeAnim->mNumRotationKeys = rotationKeys.size();
+            newAiNodeAnim->mNumRotationKeys = unsigned(rotationKeys.size());
             newAiNodeAnim->mRotationKeys = new aiQuatKey[newAiNodeAnim->mNumRotationKeys];
             std::move(rotationKeys.begin(), rotationKeys.end(), newAiNodeAnim->mRotationKeys);
 
-            newAiNodeAnim->mNumScalingKeys = scalingKeys.size();
+            newAiNodeAnim->mNumScalingKeys = unsigned(scalingKeys.size());
             newAiNodeAnim->mScalingKeys = new aiVectorKey[newAiNodeAnim->mNumScalingKeys];
             std::move(scalingKeys.begin(), scalingKeys.end(), newAiNodeAnim->mScalingKeys);
 
@@ -407,7 +408,7 @@ void USDImporterImplTinyusdz::verticesForMesh(
         }
 
         // Convert USD skeleton joints to Assimp bones
-        const unsigned int numBones = skeletonNodes.size();
+        const unsigned int numBones = unsigned(skeletonNodes.size());
         pScene->mMeshes[meshIdx]->mNumBones = numBones;
         pScene->mMeshes[meshIdx]->mBones = new aiBone *[numBones];
 
@@ -442,8 +443,8 @@ void USDImporterImplTinyusdz::verticesForMesh(
             }
         }
 
-        for (int boneIndex = 0; boneIndex < numBones; ++boneIndex) {
-            const unsigned int numWeightsForBone = aiBonesVertexWeights[boneIndex].size();
+        for (unsigned boneIndex = 0; boneIndex < numBones; ++boneIndex) {
+            const auto numWeightsForBone = unsigned(aiBonesVertexWeights[boneIndex].size());
             pScene->mMeshes[meshIdx]->mBones[boneIndex]->mWeights = new aiVertexWeight[numWeightsForBone];
             pScene->mMeshes[meshIdx]->mBones[boneIndex]->mNumWeights = numWeightsForBone;
 
@@ -708,7 +709,7 @@ static aiTexture *ownedEmbeddedTextureFor(
     string embTexName{image.asset_identifier.substr(pos + 1)};
     tex->mFilename.Set(image.asset_identifier.c_str());
     tex->mHeight = image.height;
-//    const size_t imageBytesCount{render_scene.buffers[image.buffer_id].data.size() / image.channels};
+
     tex->mWidth = image.width;
     if (tex->mHeight == 0) {
         pos = embTexName.find_last_of('.');
@@ -829,7 +830,7 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
     }
     TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
 
-    unsigned int numChildren = node.children.size();
+    unsigned int numChildren = unsigned(node.children.size());
 
     // Find any tinyusdz skeletons which might begin at this node
     // Add the skeleton bones as child nodes
@@ -882,7 +883,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
     cNode->mNumChildren = static_cast<unsigned int>(joint.children.size());
     cNode->mChildren = new aiNode *[cNode->mNumChildren];
 
-    for (int i = 0; i < cNode->mNumChildren; ++i) {
+    for (unsigned i = 0; i < cNode->mNumChildren; ++i) {
         const tinyusdz::tydra::SkelNode &childJoint = joint.children[i];
         cNode->mChildren[i] = skeletonNodesRecursive(cNode, childJoint);
     }

+ 16 - 16
code/AssetLib/USD/USDLoaderImplTinyusdzHelper.h

@@ -60,22 +60,22 @@ template <typename T>
 aiMatrix4x4 tinyUsdzMat4ToAiMat4(const T matIn[4][4]) {
     static_assert(std::is_floating_point_v<T>, "Only floating-point types are allowed.");
     aiMatrix4x4 matOut;
-    matOut.a1 = matIn[0][0];
-    matOut.a2 = matIn[1][0];
-    matOut.a3 = matIn[2][0];
-    matOut.a4 = matIn[3][0];
-    matOut.b1 = matIn[0][1];
-    matOut.b2 = matIn[1][1];
-    matOut.b3 = matIn[2][1];
-    matOut.b4 = matIn[3][1];
-    matOut.c1 = matIn[0][2];
-    matOut.c2 = matIn[1][2];
-    matOut.c3 = matIn[2][2];
-    matOut.c4 = matIn[3][2];
-    matOut.d1 = matIn[0][3];
-    matOut.d2 = matIn[1][3];
-    matOut.d3 = matIn[2][3];
-    matOut.d4 = matIn[3][3];
+    matOut.a1 = ai_real(matIn[0][0]);
+    matOut.a2 = ai_real(matIn[1][0]);
+    matOut.a3 = ai_real(matIn[2][0]);
+    matOut.a4 = ai_real(matIn[3][0]);
+    matOut.b1 = ai_real(matIn[0][1]);
+    matOut.b2 = ai_real(matIn[1][1]);
+    matOut.b3 = ai_real(matIn[2][1]);
+    matOut.b4 = ai_real(matIn[3][1]);
+    matOut.c1 = ai_real(matIn[0][2]);
+    matOut.c2 = ai_real(matIn[1][2]);
+    matOut.c3 = ai_real(matIn[2][2]);
+    matOut.c4 = ai_real(matIn[3][2]);
+    matOut.d1 = ai_real(matIn[0][3]);
+    matOut.d2 = ai_real(matIn[1][3]);
+    matOut.d3 = ai_real(matIn[2][3]);
+    matOut.d4 = ai_real(matIn[3][3]);
     return matOut;
 }
 aiVector3D tinyUsdzScaleOrPosToAssimp(const std::array<float, 3> &scaleOrPosIn);