Skip to content

Commit

Permalink
Fixed warnings (assimp#5903)
Browse files Browse the repository at this point in the history
* Fixed conversion warning when compiling without ASSIMP_DOUBLE_PRECISION. Fixed size() <> unsigned warnings

* Fix: Review finding

---------

Co-authored-by: Kim Kulling <[email protected]>
  • Loading branch information
sacereda and kimkulling authored Dec 12, 2024
1 parent 76d22e5 commit 862abe4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
25 changes: 13 additions & 12 deletions code/AssetLib/USD/USDLoaderImplTinyusdz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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('.');
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
32 changes: 16 additions & 16 deletions code/AssetLib/USD/USDLoaderImplTinyusdzHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 862abe4

Please sign in to comment.