bigwheels icon indicating copy to clipboard operation
bigwheels copied to clipboard

[glTF] Support meshes without indices

Open footballhead opened this issue 1 year ago • 1 comments

GltfLoader::LoadMeshData currently complains when a mesh lacks indices. However, meshes are allowed to not have indices. 5.24.2 says:

When this is undefined, the primitive defines non-indexed geometry

This would allow BigWheels to load and render:

footballhead avatar May 31 '24 18:05 footballhead

There's evidence that this is partly implemented but incomplete. In GltfLoader::LoadMeshData (scene_gltf_loader.cpp):

  • GetFormat() can return FORMAT_UNDEFINED when indices are missing (pGltfPrimitive->indices == nullptr). There's a comment that says: "It's valid for this to be UNDEFINED, means the primitive doesn't have any index data."
  • There's a code path involving genTopologyIndices. This is set to true when indexFormat == grfx::FORMAT_UNDEFINED. This factors into code that populates targetGeometry.

However, there's also an independent check for IsNull() very early on when BatchInfos are being made:

        // We require index data so bail if there isn't index data.
        if (IsNull(pGltfPrimitive->indices)) {
            PPX_ASSERT_MSG(false, "GLTF mesh primitive does not have index data");
            return ppx::ERROR_SCENE_INVALID_SOURCE_GEOMETRY_INDEX_DATA;
        }

Additionally, none of the staging/target buffer sizing code considers the case where indexFormat == grfx::FORMAT_UNDEFINED

footballhead avatar Sep 13 '24 20:09 footballhead