Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix draco extension deserialization #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions GLTFSDK/Source/ExtensionsKHR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ std::unique_ptr<Extension> KHR::Materials::DeserializePBRSpecGloss(const std::st
{
Materials::PBRSpecularGlossiness specGloss;

auto doc = RapidJsonUtils::CreateDocumentFromString(json);
const auto sit = doc.GetObject();
const auto sit = RapidJsonUtils::CreateDocumentFromString(json);

// Diffuse Factor
auto diffuseFactIt = sit.FindMember("diffuseFactor");
Expand Down Expand Up @@ -313,10 +312,9 @@ std::unique_ptr<Extension> KHR::Materials::DeserializeUnlit(const std::string& j
{
Unlit unlit;

auto doc = RapidJsonUtils::CreateDocumentFromString(json);
const auto objValue = doc.GetObject();
const auto doc = RapidJsonUtils::CreateDocumentFromString(json);

ParseProperty(objValue, unlit, extensionDeserializer);
ParseProperty(doc.GetObject(), unlit, extensionDeserializer);

return std::make_unique<Unlit>(unlit);
}
Expand Down Expand Up @@ -374,8 +372,7 @@ std::unique_ptr<Extension> KHR::MeshPrimitives::DeserializeDracoMeshCompression(
{
auto extension = std::make_unique<DracoMeshCompression>();

auto doc = RapidJsonUtils::CreateDocumentFromString(json);
const auto v = doc.GetObject();
const auto v = RapidJsonUtils::CreateDocumentFromString(json);

extension->bufferViewId = GetMemberValueAsString<uint32_t>(v, "bufferView");

Expand All @@ -386,9 +383,8 @@ std::unique_ptr<Extension> KHR::MeshPrimitives::DeserializeDracoMeshCompression(
{
throw GLTFException("Member attributes of " + std::string(DRACOMESHCOMPRESSION_NAME) + " is not an object.");
}
const auto& attributes = it->value.GetObject();

for (const auto& attribute : attributes)
for (const auto& attribute : it->value.GetObject())
{
auto name = attribute.name.GetString();

Expand Down Expand Up @@ -480,7 +476,7 @@ std::unique_ptr<Extension> KHR::TextureInfos::DeserializeTextureTransform(const
{
TextureTransform textureTransform;

auto doc = RapidJsonUtils::CreateDocumentFromString(json);
const auto doc = RapidJsonUtils::CreateDocumentFromString(json);
const auto sit = doc.GetObject();

// Offset
Expand Down