+ accessor.mBufferView ? accessor.mBufferView->mBuffer.GetIndex() : 0,
+ accessor.mNormalized};
+}
+
+MeshDefinition::Accessor* GetAccessorFromAttribute(gltf2::Attribute::HashType attributeHash,
+ MeshDefinition& meshDefinition,
+ bool& needNormals,
+ bool& needTangents)
+{
+ MeshDefinition::Accessor* accessorDest{nullptr};
+
+ switch(gltf2::Attribute::TypeFromHash(attributeHash))
+ {
+ case gltf2::Attribute::POSITION:
+ {
+ accessorDest = &meshDefinition.mPositions;
+ break;
+ }
+ case gltf2::Attribute::NORMAL:
+ {
+ accessorDest = &meshDefinition.mNormals;
+ needNormals = false;
+ break;
+ }
+ case gltf2::Attribute::TANGENT:
+ {
+ accessorDest = &meshDefinition.mTangents;
+ needTangents = false;
+ break;
+ }
+ case gltf2::Attribute::TEXCOORD_N:
+ {
+ meshDefinition.mTexCoords.emplace_back(MeshDefinition::Accessor{});
+ accessorDest = &meshDefinition.mTexCoords.back();
+ break;
+ }
+ case gltf2::Attribute::COLOR_N:
+ {
+ meshDefinition.mColors.emplace_back(MeshDefinition::Accessor{});
+ accessorDest = &meshDefinition.mColors.back();
+ break;
+ }
+ case gltf2::Attribute::JOINTS_N:
+ {
+ if(meshDefinition.mJoints.size() < MeshDefinition::MAX_NUMBER_OF_JOINT_SETS)
+ {
+ meshDefinition.mJoints.emplace_back(MeshDefinition::Accessor{});
+ accessorDest = &meshDefinition.mJoints.back();
+ }
+ break;
+ }
+ case gltf2::Attribute::WEIGHTS_N:
+ {
+ if(meshDefinition.mWeights.size() < MeshDefinition::MAX_NUMBER_OF_JOINT_SETS)
+ {
+ meshDefinition.mWeights.emplace_back(MeshDefinition::Accessor{});
+ accessorDest = &meshDefinition.mWeights.back();
+ }
+ break;
+ }
+ case gltf2::Attribute::INVALID:
+ {
+ accessorDest = nullptr;
+ break;
+ }
+ }
+ return accessorDest;
+}
+
+void SetFlagsFromComponentType(const gltf2::Accessor& accessor,
+ gltf2::Attribute::HashType attributeHash,
+ MeshDefinition& meshDefinition,
+ bool isQuantized)
+{
+ switch(gltf2::Attribute::TypeFromHash(attributeHash))
+ {
+ case gltf2::Attribute::POSITION:
+ {
+ if(isQuantized)
+ {
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::BYTE) * MeshDefinition::S8_POSITION;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_BYTE) * MeshDefinition::U8_POSITION;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::SHORT) * MeshDefinition::S16_POSITION;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_SHORT) * MeshDefinition::U16_POSITION;
+ }
+ DALI_ASSERT_DEBUG((isQuantized && (MaskMatch(meshDefinition.mFlags, MeshDefinition::S8_POSITION) || MaskMatch(meshDefinition.mFlags, MeshDefinition::U8_POSITION) || MaskMatch(meshDefinition.mFlags, MeshDefinition::S16_POSITION) || MaskMatch(meshDefinition.mFlags, MeshDefinition::U16_POSITION))) || accessor.mComponentType == gltf2::Component::FLOAT);
+ break;
+ }
+ case gltf2::Attribute::NORMAL:
+ {
+ if(isQuantized)
+ {
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::BYTE) * MeshDefinition::S8_NORMAL;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::SHORT) * MeshDefinition::S16_NORMAL;
+ }
+
+ DALI_ASSERT_DEBUG((isQuantized && (MaskMatch(meshDefinition.mFlags, MeshDefinition::S8_NORMAL) || MaskMatch(meshDefinition.mFlags, MeshDefinition::S16_NORMAL))) || accessor.mComponentType == gltf2::Component::FLOAT);
+ break;
+ }
+ case gltf2::Attribute::TANGENT:
+ {
+ if(isQuantized)
+ {
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::BYTE) * MeshDefinition::S8_TANGENT;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::SHORT) * MeshDefinition::S16_TANGENT;
+ }
+
+ DALI_ASSERT_DEBUG((isQuantized && (MaskMatch(meshDefinition.mFlags, MeshDefinition::S8_TANGENT) || MaskMatch(meshDefinition.mFlags, MeshDefinition::S16_TANGENT))) || accessor.mComponentType == gltf2::Component::FLOAT);
+ break;
+ }
+ case gltf2::Attribute::TEXCOORD_N:
+ {
+ if(isQuantized)
+ {
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::BYTE) * MeshDefinition::S8_TEXCOORD;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_BYTE) * MeshDefinition::U8_TEXCOORD;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::SHORT) * MeshDefinition::S16_TEXCOORD;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_SHORT) * MeshDefinition::U16_TEXCOORD;
+ }
+ DALI_ASSERT_DEBUG((isQuantized && (MaskMatch(meshDefinition.mFlags, MeshDefinition::S8_TEXCOORD) || MaskMatch(meshDefinition.mFlags, MeshDefinition::U8_TEXCOORD) || MaskMatch(meshDefinition.mFlags, MeshDefinition::S16_TEXCOORD) || MaskMatch(meshDefinition.mFlags, MeshDefinition::U16_TEXCOORD))) || accessor.mComponentType == gltf2::Component::FLOAT);
+ break;
+ }
+ case gltf2::Attribute::COLOR_N:
+ {
+ break;
+ }
+ case gltf2::Attribute::JOINTS_N:
+ {
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_SHORT) * MeshDefinition::U16_JOINT_IDS;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_BYTE) * MeshDefinition::U8_JOINT_IDS;
+ DALI_ASSERT_DEBUG(MaskMatch(meshDefinition.mFlags, MeshDefinition::U16_JOINT_IDS) ||
+ MaskMatch(meshDefinition.mFlags, MeshDefinition::U8_JOINT_IDS) ||
+ accessor.mComponentType == gltf2::Component::FLOAT);
+ break;
+ }
+ case gltf2::Attribute::WEIGHTS_N:
+ {
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_SHORT) * MeshDefinition::U16_WEIGHT;
+ meshDefinition.mFlags |= (accessor.mComponentType == gltf2::Component::UNSIGNED_BYTE) * MeshDefinition::U8_WEIGHT;
+ DALI_ASSERT_DEBUG(MaskMatch(meshDefinition.mFlags, MeshDefinition::U16_WEIGHT) ||
+ MaskMatch(meshDefinition.mFlags, MeshDefinition::U8_WEIGHT) ||
+ accessor.mComponentType == gltf2::Component::FLOAT);
+
+ break;
+ }
+ case gltf2::Attribute::INVALID:
+ {
+ break;
+ }
+ }