ソースを参照

Fixed warnings on MSVC caused by implicit conversions from double to float.

Jared Mulconry 8 年 前
コミット
326158633b
3 ファイル変更8 行追加8 行削除
  1. 2 2
      code/glTF2Asset.inl
  2. 3 3
      code/glTF2Exporter.cpp
  3. 3 3
      code/glTFExporter.cpp

+ 2 - 2
code/glTF2Asset.inl

@@ -724,7 +724,7 @@ namespace {
             SetTextureProperties(r, prop, out);
             SetTextureProperties(r, prop, out);
 
 
             if (Value* scale = FindNumber(*prop, "scale")) {
             if (Value* scale = FindNumber(*prop, "scale")) {
-                out.scale = scale->GetDouble();
+                out.scale = static_cast<float>(scale->GetDouble());
             }
             }
         }
         }
     }
     }
@@ -735,7 +735,7 @@ namespace {
             SetTextureProperties(r, prop, out);
             SetTextureProperties(r, prop, out);
 
 
             if (Value* strength = FindNumber(*prop, "strength")) {
             if (Value* strength = FindNumber(*prop, "strength")) {
-                out.strength = strength->GetDouble();
+                out.strength = static_cast<float>(strength->GetDouble());
             }
             }
         }
         }
     }
     }

+ 3 - 3
code/glTF2Exporter.cpp

@@ -563,7 +563,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
                 continue;
                 continue;
             }
             }
 
 
-            vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;
+            vertexJointData[vertexId][jointsPerVertex[vertexId]] = static_cast<float>(jointNamesIndex);
             vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
             vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
 
 
             jointsPerVertex[vertexId] += 1;
             jointsPerVertex[vertexId] += 1;
@@ -872,7 +872,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
             size_t frameIndex = i * nodeChannel->mNumPositionKeys / numKeyframes;
             size_t frameIndex = i * nodeChannel->mNumPositionKeys / numKeyframes;
             // mTime is measured in ticks, but GLTF time is measured in seconds, so convert.
             // mTime is measured in ticks, but GLTF time is measured in seconds, so convert.
             // Check if we have to cast type here. e.g. uint16_t()
             // Check if we have to cast type here. e.g. uint16_t()
-            timeData[i] = nodeChannel->mPositionKeys[frameIndex].mTime / ticksPerSecond;
+            timeData[i] = static_cast<float>(nodeChannel->mPositionKeys[frameIndex].mTime / ticksPerSecond);
         }
         }
 
 
         Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
         Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
@@ -953,7 +953,7 @@ void glTF2Exporter::ExportAnimations()
             Ref<Animation> animRef = mAsset->animations.Create(name);
             Ref<Animation> animRef = mAsset->animations.Create(name);
 
 
             // Parameters
             // Parameters
-            ExtractAnimationData(*mAsset, name, animRef, bufferRef, nodeChannel, anim->mTicksPerSecond);
+            ExtractAnimationData(*mAsset, name, animRef, bufferRef, nodeChannel, static_cast<float>(anim->mTicksPerSecond));
 
 
             for (unsigned int j = 0; j < 3; ++j) {
             for (unsigned int j = 0; j < 3; ++j) {
                 std::string channelType;
                 std::string channelType;

+ 3 - 3
code/glTFExporter.cpp

@@ -473,7 +473,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buf
                 continue;
                 continue;
             }
             }
 
 
-            vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;
+            vertexJointData[vertexId][jointsPerVertex[vertexId]] = static_cast<float>(jointNamesIndex);
             vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
             vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
 
 
             jointsPerVertex[vertexId] += 1;
             jointsPerVertex[vertexId] += 1;
@@ -872,7 +872,7 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
             size_t frameIndex = i * nodeChannel->mNumPositionKeys / numKeyframes;
             size_t frameIndex = i * nodeChannel->mNumPositionKeys / numKeyframes;
             // mTime is measured in ticks, but GLTF time is measured in seconds, so convert.
             // mTime is measured in ticks, but GLTF time is measured in seconds, so convert.
             // Check if we have to cast type here. e.g. uint16_t()
             // Check if we have to cast type here. e.g. uint16_t()
-            timeData[i] = nodeChannel->mPositionKeys[frameIndex].mTime / ticksPerSecond;
+            timeData[i] = static_cast<float>(nodeChannel->mPositionKeys[frameIndex].mTime / ticksPerSecond);
         }
         }
 
 
         Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
         Ref<Accessor> timeAccessor = ExportData(mAsset, animId, buffer, static_cast<unsigned int>(numKeyframes), &timeData[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
@@ -953,7 +953,7 @@ void glTFExporter::ExportAnimations()
             Ref<Animation> animRef = mAsset->animations.Create(name);
             Ref<Animation> animRef = mAsset->animations.Create(name);
 
 
             /******************* Parameters ********************/
             /******************* Parameters ********************/
-            ExtractAnimationData(*mAsset, name, animRef, bufferRef, nodeChannel, anim->mTicksPerSecond);
+            ExtractAnimationData(*mAsset, name, animRef, bufferRef, nodeChannel, static_cast<float>(anim->mTicksPerSecond));
 
 
             for (unsigned int j = 0; j < 3; ++j) {
             for (unsigned int j = 0; j < 3; ++j) {
                 std::string channelType;
                 std::string channelType;