Skip to content

Commit

Permalink
gltfpack: Limit the number of non-target streams to 16
Browse files Browse the repository at this point in the history
We currently have a limit of 16 on some stream based processing
algorithms, and it's possible with custom attributes to reach a limit of
16, so for now we just drop extra streams.
  • Loading branch information
zeux committed Oct 26, 2023
1 parent 596baab commit b84e83b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gltf/parsegltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <stdlib.h>
#include <string.h>

static const size_t kMaxStreams = 16;

static const char* getError(cgltf_result result, cgltf_data* data)
{
switch (result)
Expand Down Expand Up @@ -211,6 +213,12 @@ static void parseMeshesGltf(cgltf_data* data, std::vector<Mesh>& meshes, std::ve
continue;
}

if (result.streams.size() == kMaxStreams)
{
fprintf(stderr, "Warning: ignoring attribute %s in primitive %d of mesh %d (limit %d reached)\n", attr.name, int(pi), int(mi), int(kMaxStreams));
continue;
}

result.streams.push_back(Stream());
Stream& s = result.streams.back();

Expand Down

0 comments on commit b84e83b

Please sign in to comment.