|
@@ -412,7 +412,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|
Mesh::Primitive::Attributes& attr = prim.attributes;
|
|
Mesh::Primitive::Attributes& attr = prim.attributes;
|
|
|
|
|
|
if (attr.position.size() > 0 && attr.position[0]) {
|
|
if (attr.position.size() > 0 && attr.position[0]) {
|
|
- aim->mNumVertices = attr.position[0]->count;
|
|
|
|
|
|
+ aim->mNumVertices = static_cast<unsigned int>(attr.position[0]->count);
|
|
attr.position[0]->ExtractData(aim->mVertices);
|
|
attr.position[0]->ExtractData(aim->mVertices);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -511,10 +511,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|
|
|
|
|
|
|
|
|
aiFace* faces = 0;
|
|
aiFace* faces = 0;
|
|
- unsigned int nFaces = 0;
|
|
|
|
|
|
+ size_t nFaces = 0;
|
|
|
|
|
|
if (prim.indices) {
|
|
if (prim.indices) {
|
|
- unsigned int count = prim.indices->count;
|
|
|
|
|
|
+ size_t count = prim.indices->count;
|
|
|
|
|
|
Accessor::Indexer data = prim.indices->GetIndexer();
|
|
Accessor::Indexer data = prim.indices->GetIndexer();
|
|
ai_assert(data.IsValid());
|
|
ai_assert(data.IsValid());
|
|
@@ -665,8 +665,8 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)
|
|
|
|
|
|
if (faces) {
|
|
if (faces) {
|
|
aim->mFaces = faces;
|
|
aim->mFaces = faces;
|
|
- aim->mNumFaces = nFaces;
|
|
|
|
- ai_assert(CheckValidFacesIndices(faces, nFaces, aim->mNumVertices));
|
|
|
|
|
|
+ aim->mNumFaces = static_cast<unsigned int>(nFaces);
|
|
|
|
+ ai_assert(CheckValidFacesIndices(faces, static_cast<unsigned>(nFaces), aim->mNumVertices));
|
|
}
|
|
}
|
|
|
|
|
|
if (prim.material) {
|
|
if (prim.material) {
|
|
@@ -751,7 +751,7 @@ static void BuildVertexWeightMapping(Mesh::Primitive& primitive, std::vector<std
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- const int num_vertices = attr.weight[0]->count;
|
|
|
|
|
|
+ size_t num_vertices = attr.weight[0]->count;
|
|
|
|
|
|
struct Weights { float values[4]; };
|
|
struct Weights { float values[4]; };
|
|
Weights* weights = nullptr;
|
|
Weights* weights = nullptr;
|
|
@@ -773,13 +773,13 @@ static void BuildVertexWeightMapping(Mesh::Primitive& primitive, std::vector<std
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- for (int i = 0; i < num_vertices; ++i) {
|
|
|
|
|
|
+ for (size_t i = 0; i < num_vertices; ++i) {
|
|
for (int j = 0; j < 4; ++j) {
|
|
for (int j = 0; j < 4; ++j) {
|
|
const unsigned int bone = (indices8!=nullptr) ? indices8[i].values[j] : indices16[i].values[j];
|
|
const unsigned int bone = (indices8!=nullptr) ? indices8[i].values[j] : indices16[i].values[j];
|
|
const float weight = weights[i].values[j];
|
|
const float weight = weights[i].values[j];
|
|
if (weight > 0 && bone < map.size()) {
|
|
if (weight > 0 && bone < map.size()) {
|
|
map[bone].reserve(8);
|
|
map[bone].reserve(8);
|
|
- map[bone].emplace_back(i, weight);
|
|
|
|
|
|
+ map[bone].emplace_back(static_cast<unsigned int>(i), weight);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -822,7 +822,7 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
|
if (node.skin) {
|
|
if (node.skin) {
|
|
for (int primitiveNo = 0; primitiveNo < count; ++primitiveNo) {
|
|
for (int primitiveNo = 0; primitiveNo < count; ++primitiveNo) {
|
|
aiMesh* mesh = pScene->mMeshes[meshOffsets[mesh_idx]+primitiveNo];
|
|
aiMesh* mesh = pScene->mMeshes[meshOffsets[mesh_idx]+primitiveNo];
|
|
- mesh->mNumBones = node.skin->jointNames.size();
|
|
|
|
|
|
+ mesh->mNumBones = static_cast<unsigned int>(node.skin->jointNames.size());
|
|
mesh->mBones = new aiBone*[mesh->mNumBones];
|
|
mesh->mBones = new aiBone*[mesh->mNumBones];
|
|
|
|
|
|
// GLTF and Assimp choose to store bone weights differently.
|
|
// GLTF and Assimp choose to store bone weights differently.
|
|
@@ -837,7 +837,7 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
|
std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
|
|
std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
|
|
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
|
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
|
|
|
|
|
- for (size_t i = 0; i < mesh->mNumBones; ++i) {
|
|
|
|
|
|
+ for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
|
|
aiBone* bone = new aiBone();
|
|
aiBone* bone = new aiBone();
|
|
|
|
|
|
Ref<Node> joint = node.skin->jointNames[i];
|
|
Ref<Node> joint = node.skin->jointNames[i];
|
|
@@ -854,7 +854,7 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
|
|
|
|
|
std::vector<aiVertexWeight>& weights = weighting[i];
|
|
std::vector<aiVertexWeight>& weights = weighting[i];
|
|
|
|
|
|
- bone->mNumWeights = weights.size();
|
|
|
|
|
|
+ bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
|
if (bone->mNumWeights > 0) {
|
|
if (bone->mNumWeights > 0) {
|
|
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
|
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
|
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
|
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
|
@@ -930,7 +930,7 @@ aiNodeAnim* CreateNodeAnim(glTF2::Asset& r, Node& node, AnimationSamplers& sampl
|
|
samplers.translation->input->ExtractData(times);
|
|
samplers.translation->input->ExtractData(times);
|
|
aiVector3D* values = nullptr;
|
|
aiVector3D* values = nullptr;
|
|
samplers.translation->output->ExtractData(values);
|
|
samplers.translation->output->ExtractData(values);
|
|
- anim->mNumPositionKeys = samplers.translation->input->count;
|
|
|
|
|
|
+ anim->mNumPositionKeys = static_cast<uint32_t>(samplers.translation->input->count);
|
|
anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys];
|
|
anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys];
|
|
for (unsigned int i = 0; i < anim->mNumPositionKeys; ++i) {
|
|
for (unsigned int i = 0; i < anim->mNumPositionKeys; ++i) {
|
|
anim->mPositionKeys[i].mTime = times[i] * kMillisecondsFromSeconds;
|
|
anim->mPositionKeys[i].mTime = times[i] * kMillisecondsFromSeconds;
|
|
@@ -952,7 +952,7 @@ aiNodeAnim* CreateNodeAnim(glTF2::Asset& r, Node& node, AnimationSamplers& sampl
|
|
samplers.rotation->input->ExtractData(times);
|
|
samplers.rotation->input->ExtractData(times);
|
|
aiQuaternion* values = nullptr;
|
|
aiQuaternion* values = nullptr;
|
|
samplers.rotation->output->ExtractData(values);
|
|
samplers.rotation->output->ExtractData(values);
|
|
- anim->mNumRotationKeys = samplers.rotation->input->count;
|
|
|
|
|
|
+ anim->mNumRotationKeys = static_cast<uint32_t>(samplers.rotation->input->count);
|
|
anim->mRotationKeys = new aiQuatKey[anim->mNumRotationKeys];
|
|
anim->mRotationKeys = new aiQuatKey[anim->mNumRotationKeys];
|
|
for (unsigned int i = 0; i < anim->mNumRotationKeys; ++i) {
|
|
for (unsigned int i = 0; i < anim->mNumRotationKeys; ++i) {
|
|
anim->mRotationKeys[i].mTime = times[i] * kMillisecondsFromSeconds;
|
|
anim->mRotationKeys[i].mTime = times[i] * kMillisecondsFromSeconds;
|
|
@@ -978,7 +978,7 @@ aiNodeAnim* CreateNodeAnim(glTF2::Asset& r, Node& node, AnimationSamplers& sampl
|
|
samplers.scale->input->ExtractData(times);
|
|
samplers.scale->input->ExtractData(times);
|
|
aiVector3D* values = nullptr;
|
|
aiVector3D* values = nullptr;
|
|
samplers.scale->output->ExtractData(values);
|
|
samplers.scale->output->ExtractData(values);
|
|
- anim->mNumScalingKeys = samplers.scale->input->count;
|
|
|
|
|
|
+ anim->mNumScalingKeys = static_cast<uint32_t>(samplers.scale->input->count);
|
|
anim->mScalingKeys = new aiVectorKey[anim->mNumScalingKeys];
|
|
anim->mScalingKeys = new aiVectorKey[anim->mNumScalingKeys];
|
|
for (unsigned int i = 0; i < anim->mNumScalingKeys; ++i) {
|
|
for (unsigned int i = 0; i < anim->mNumScalingKeys; ++i) {
|
|
anim->mScalingKeys[i].mTime = times[i] * kMillisecondsFromSeconds;
|
|
anim->mScalingKeys[i].mTime = times[i] * kMillisecondsFromSeconds;
|
|
@@ -1042,7 +1042,7 @@ void glTF2Importer::ImportAnimations(glTF2::Asset& r)
|
|
|
|
|
|
std::unordered_map<unsigned int, AnimationSamplers> samplers = GatherSamplers(anim);
|
|
std::unordered_map<unsigned int, AnimationSamplers> samplers = GatherSamplers(anim);
|
|
|
|
|
|
- ai_anim->mNumChannels = samplers.size();
|
|
|
|
|
|
+ ai_anim->mNumChannels = static_cast<uint32_t>(samplers.size());
|
|
if (ai_anim->mNumChannels > 0) {
|
|
if (ai_anim->mNumChannels > 0) {
|
|
ai_anim->mChannels = new aiNodeAnim*[ai_anim->mNumChannels];
|
|
ai_anim->mChannels = new aiNodeAnim*[ai_anim->mNumChannels];
|
|
int j = 0;
|
|
int j = 0;
|