Merge pull request #3667 from thomasbiang/sparse_minmax

Export Min/Max for Sparse Accessor
pull/3687/head^2
Kim Kulling 2021-03-04 21:42:10 +01:00 committed by GitHub
commit 75144dd7fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 9 deletions

View File

@ -110,19 +110,18 @@ namespace glTF2 {
if (a.bufferView) { if (a.bufferView) {
obj.AddMember("bufferView", a.bufferView->index, w.mAl); obj.AddMember("bufferView", a.bufferView->index, w.mAl);
obj.AddMember("byteOffset", (unsigned int)a.byteOffset, w.mAl); obj.AddMember("byteOffset", (unsigned int)a.byteOffset, w.mAl);
Value vTmpMax, vTmpMin;
if (a.componentType == ComponentType_FLOAT) {
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
} else {
obj.AddMember("max", MakeValueCast<int64_t>(vTmpMax, a.max, w.mAl), w.mAl);
obj.AddMember("min", MakeValueCast<int64_t>(vTmpMin, a.min, w.mAl), w.mAl);
}
} }
obj.AddMember("componentType", int(a.componentType), w.mAl); obj.AddMember("componentType", int(a.componentType), w.mAl);
obj.AddMember("count", (unsigned int)a.count, w.mAl); obj.AddMember("count", (unsigned int)a.count, w.mAl);
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl); obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
Value vTmpMax, vTmpMin;
if (a.componentType == ComponentType_FLOAT) {
obj.AddMember("max", MakeValue(vTmpMax, a.max, w.mAl), w.mAl);
obj.AddMember("min", MakeValue(vTmpMin, a.min, w.mAl), w.mAl);
} else {
obj.AddMember("max", MakeValueCast<int64_t>(vTmpMax, a.max, w.mAl), w.mAl);
obj.AddMember("min", MakeValueCast<int64_t>(vTmpMin, a.min, w.mAl), w.mAl);
}
if (a.sparse) { if (a.sparse) {
Value sparseValue; Value sparseValue;