Skip to content

Commit 862abe4

Browse files
saceredakimkulling
andauthored
Fixed warnings (assimp#5903)
* Fixed conversion warning when compiling without ASSIMP_DOUBLE_PRECISION. Fixed size() <> unsigned warnings * Fix: Review finding --------- Co-authored-by: Kim Kulling <[email protected]>
1 parent 76d22e5 commit 862abe4

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

code/AssetLib/USD/USDLoaderImplTinyusdz.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ void USDImporterImplTinyusdz::animations(
230230
return;
231231
}
232232

233-
pScene->mNumAnimations = render_scene.animations.size();
233+
pScene->mNumAnimations = unsigned(render_scene.animations.size());
234234
pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations];
235235

236-
for (int animationIndex = 0; animationIndex < pScene->mNumAnimations; ++animationIndex) {
236+
for (unsigned animationIndex = 0; animationIndex < pScene->mNumAnimations; ++animationIndex) {
237237

238238
const auto &animation = render_scene.animations[animationIndex];
239239

@@ -249,7 +249,8 @@ void USDImporterImplTinyusdz::animations(
249249

250250
// each channel affects a node (joint)
251251
newAiAnimation->mTicksPerSecond = render_scene.meta.framesPerSecond;
252-
newAiAnimation->mNumChannels = animation.channels_map.size();
252+
newAiAnimation->mNumChannels = unsigned(animation.channels_map.size());
253+
253254
newAiAnimation->mChannels = new aiNodeAnim *[newAiAnimation->mNumChannels];
254255
int channelIndex = 0;
255256
for (const auto &[jointName, animationChannelMap] : animation.channels_map) {
@@ -330,15 +331,15 @@ void USDImporterImplTinyusdz::animations(
330331
}
331332
}
332333

333-
newAiNodeAnim->mNumPositionKeys = positionKeys.size();
334+
newAiNodeAnim->mNumPositionKeys = unsigned(positionKeys.size());
334335
newAiNodeAnim->mPositionKeys = new aiVectorKey[newAiNodeAnim->mNumPositionKeys];
335336
std::move(positionKeys.begin(), positionKeys.end(), newAiNodeAnim->mPositionKeys);
336337

337-
newAiNodeAnim->mNumRotationKeys = rotationKeys.size();
338+
newAiNodeAnim->mNumRotationKeys = unsigned(rotationKeys.size());
338339
newAiNodeAnim->mRotationKeys = new aiQuatKey[newAiNodeAnim->mNumRotationKeys];
339340
std::move(rotationKeys.begin(), rotationKeys.end(), newAiNodeAnim->mRotationKeys);
340341

341-
newAiNodeAnim->mNumScalingKeys = scalingKeys.size();
342+
newAiNodeAnim->mNumScalingKeys = unsigned(scalingKeys.size());
342343
newAiNodeAnim->mScalingKeys = new aiVectorKey[newAiNodeAnim->mNumScalingKeys];
343344
std::move(scalingKeys.begin(), scalingKeys.end(), newAiNodeAnim->mScalingKeys);
344345

@@ -407,7 +408,7 @@ void USDImporterImplTinyusdz::verticesForMesh(
407408
}
408409

409410
// Convert USD skeleton joints to Assimp bones
410-
const unsigned int numBones = skeletonNodes.size();
411+
const unsigned int numBones = unsigned(skeletonNodes.size());
411412
pScene->mMeshes[meshIdx]->mNumBones = numBones;
412413
pScene->mMeshes[meshIdx]->mBones = new aiBone *[numBones];
413414

@@ -442,8 +443,8 @@ void USDImporterImplTinyusdz::verticesForMesh(
442443
}
443444
}
444445

445-
for (int boneIndex = 0; boneIndex < numBones; ++boneIndex) {
446-
const unsigned int numWeightsForBone = aiBonesVertexWeights[boneIndex].size();
446+
for (unsigned boneIndex = 0; boneIndex < numBones; ++boneIndex) {
447+
const auto numWeightsForBone = unsigned(aiBonesVertexWeights[boneIndex].size());
447448
pScene->mMeshes[meshIdx]->mBones[boneIndex]->mWeights = new aiVertexWeight[numWeightsForBone];
448449
pScene->mMeshes[meshIdx]->mBones[boneIndex]->mNumWeights = numWeightsForBone;
449450

@@ -708,7 +709,7 @@ static aiTexture *ownedEmbeddedTextureFor(
708709
string embTexName{image.asset_identifier.substr(pos + 1)};
709710
tex->mFilename.Set(image.asset_identifier.c_str());
710711
tex->mHeight = image.height;
711-
// const size_t imageBytesCount{render_scene.buffers[image.buffer_id].data.size() / image.channels};
712+
712713
tex->mWidth = image.width;
713714
if (tex->mHeight == 0) {
714715
pos = embTexName.find_last_of('.');
@@ -829,7 +830,7 @@ aiNode *USDImporterImplTinyusdz::nodesRecursive(
829830
}
830831
TINYUSDZLOGD(TAG, "%s", ss.str().c_str());
831832

832-
unsigned int numChildren = node.children.size();
833+
unsigned int numChildren = unsigned(node.children.size());
833834

834835
// Find any tinyusdz skeletons which might begin at this node
835836
// Add the skeleton bones as child nodes
@@ -882,7 +883,7 @@ aiNode *USDImporterImplTinyusdz::skeletonNodesRecursive(
882883
cNode->mNumChildren = static_cast<unsigned int>(joint.children.size());
883884
cNode->mChildren = new aiNode *[cNode->mNumChildren];
884885

885-
for (int i = 0; i < cNode->mNumChildren; ++i) {
886+
for (unsigned i = 0; i < cNode->mNumChildren; ++i) {
886887
const tinyusdz::tydra::SkelNode &childJoint = joint.children[i];
887888
cNode->mChildren[i] = skeletonNodesRecursive(cNode, childJoint);
888889
}

code/AssetLib/USD/USDLoaderImplTinyusdzHelper.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,22 @@ template <typename T>
6060
aiMatrix4x4 tinyUsdzMat4ToAiMat4(const T matIn[4][4]) {
6161
static_assert(std::is_floating_point_v<T>, "Only floating-point types are allowed.");
6262
aiMatrix4x4 matOut;
63-
matOut.a1 = matIn[0][0];
64-
matOut.a2 = matIn[1][0];
65-
matOut.a3 = matIn[2][0];
66-
matOut.a4 = matIn[3][0];
67-
matOut.b1 = matIn[0][1];
68-
matOut.b2 = matIn[1][1];
69-
matOut.b3 = matIn[2][1];
70-
matOut.b4 = matIn[3][1];
71-
matOut.c1 = matIn[0][2];
72-
matOut.c2 = matIn[1][2];
73-
matOut.c3 = matIn[2][2];
74-
matOut.c4 = matIn[3][2];
75-
matOut.d1 = matIn[0][3];
76-
matOut.d2 = matIn[1][3];
77-
matOut.d3 = matIn[2][3];
78-
matOut.d4 = matIn[3][3];
63+
matOut.a1 = ai_real(matIn[0][0]);
64+
matOut.a2 = ai_real(matIn[1][0]);
65+
matOut.a3 = ai_real(matIn[2][0]);
66+
matOut.a4 = ai_real(matIn[3][0]);
67+
matOut.b1 = ai_real(matIn[0][1]);
68+
matOut.b2 = ai_real(matIn[1][1]);
69+
matOut.b3 = ai_real(matIn[2][1]);
70+
matOut.b4 = ai_real(matIn[3][1]);
71+
matOut.c1 = ai_real(matIn[0][2]);
72+
matOut.c2 = ai_real(matIn[1][2]);
73+
matOut.c3 = ai_real(matIn[2][2]);
74+
matOut.c4 = ai_real(matIn[3][2]);
75+
matOut.d1 = ai_real(matIn[0][3]);
76+
matOut.d2 = ai_real(matIn[1][3]);
77+
matOut.d3 = ai_real(matIn[2][3]);
78+
matOut.d4 = ai_real(matIn[3][3]);
7979
return matOut;
8080
}
8181
aiVector3D tinyUsdzScaleOrPosToAssimp(const std::array<float, 3> &scaleOrPosIn);

0 commit comments

Comments
 (0)