diff --git a/code/glTF2Asset.h b/code/glTF2Asset.h index bbef4413e..52bc18268 100644 --- a/code/glTF2Asset.h +++ b/code/glTF2Asset.h @@ -1074,7 +1074,7 @@ namespace glTF2 std::string version; //!< Specifies the target rendering API (default: "1.0.3") } profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {}) - int version; //!< The glTF format version + float version; //!< The glTF format version void Read(Document& doc); diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index 33598e243..44a1cce00 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -1229,7 +1229,7 @@ inline void Scene::Read(Value& obj, Asset& r) inline void AssetMetadata::Read(Document& doc) { // read the version, etc. - int statedVersion = 0; + float statedVersion = 0; if (Value* obj = FindObject(doc, "asset")) { ReadMember(*obj, "copyright", copyright); ReadMember(*obj, "generator", generator); @@ -1244,14 +1244,15 @@ inline void AssetMetadata::Read(Document& doc) } version = std::max(statedVersion, version); + if (version == 0) { - // if missing version, we'll assume version 1... + // if missing version, we'll assume version 1.0... version = 1; } if (version != 1) { char msg[128]; - ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %d", version); + ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %.1f", version); throw DeadlyImportError(msg); } } diff --git a/code/glTF2AssetWriter.inl b/code/glTF2AssetWriter.inl index 6e1865bbf..ed8ee80ea 100644 --- a/code/glTF2AssetWriter.inl +++ b/code/glTF2AssetWriter.inl @@ -600,7 +600,7 @@ namespace glTF2 { asset.SetObject(); { char versionChar[10]; - ai_snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version); + ai_snprintf(versionChar, sizeof(versionChar), "%.1f", mAsset.asset.version); asset.AddMember("version", Value(versionChar, mAl).Move(), mAl); asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl); diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index b6a2efdd0..11694a89d 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -466,8 +466,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefmWeights[idx_weights].mWeight; // A vertex can only have at most four joint weights. Ignore all others. - if (jointsPerVertex[vertexId] > 3) { - continue; + if (jointsPerVertex[vertexId] > 3) { + continue; } vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex; diff --git a/code/glTFAsset.h b/code/glTFAsset.h index 41d0dfd06..30d0bc056 100644 --- a/code/glTFAsset.h +++ b/code/glTFAsset.h @@ -1058,7 +1058,7 @@ namespace glTF std::string version; //!< Specifies the target rendering API (default: "1.0.3") } profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {}) - int version; //!< The glTF format version (should be 1) + float version; //!< The glTF format version (should be 1.0) void Read(Document& doc); diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index fe29dde70..91d36c59b 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -1228,7 +1228,7 @@ inline void Scene::Read(Value& obj, Asset& r) inline void AssetMetadata::Read(Document& doc) { // read the version, etc. - int statedVersion = 0; + float statedVersion = 0; if (Value* obj = FindObject(doc, "asset")) { ReadMember(*obj, "copyright", copyright); ReadMember(*obj, "generator", generator); @@ -1250,7 +1250,7 @@ inline void AssetMetadata::Read(Document& doc) if (version != 1) { char msg[128]; - ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %d", version); + ai_snprintf(msg, 128, "GLTF: Unsupported glTF version: %.0f", version); throw DeadlyImportError(msg); } } diff --git a/code/glTFAssetWriter.inl b/code/glTFAssetWriter.inl index d3a553c27..166b84fd1 100644 --- a/code/glTFAssetWriter.inl +++ b/code/glTFAssetWriter.inl @@ -608,7 +608,7 @@ namespace glTF { asset.SetObject(); { char versionChar[10]; - ai_snprintf(versionChar, sizeof(versionChar), "%d", mAsset.asset.version); + ai_snprintf(versionChar, sizeof(versionChar), "%.0f", mAsset.asset.version); asset.AddMember("version", Value(versionChar, mAl).Move(), mAl); asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl); diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index aeb5069aa..f3fa5e526 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -469,8 +469,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, RefmWeights[idx_weights].mWeight; // A vertex can only have at most four joint weights. Ignore all others. - if (jointsPerVertex[vertexId] > 3) { - continue; + if (jointsPerVertex[vertexId] > 3) { + continue; } vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;