Skip to content

Commit

Permalink
gltfpack: Merge index streams into one when compressing
Browse files Browse the repository at this point in the history
Now that we can use version=1 index codec, we can merge all index streams
into one which is slightly more efficient in terms of binary size and
JSON size, and faster to decode.
  • Loading branch information
zeux committed Jan 27, 2020
1 parent 10426fd commit 3b4d1c9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tools/gltfpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3303,10 +3303,7 @@ size_t writeMeshIndices(std::vector<BufferView>& views, std::string& json_access
std::string scratch;
StreamFormat format = writeIndexStream(scratch, mesh.indices);

// note: we prefer to merge all index streams together; however, index codec currently doesn't handle concatenated index streams well and loses compression ratio
int variant = settings.compress ? -1 : 0;

size_t view = getBufferView(views, BufferView::Kind_Index, variant, format.stride, settings.compress);
size_t view = getBufferView(views, BufferView::Kind_Index, 0, format.stride, settings.compress);
size_t offset = views[view].data.size();
views[view].data += scratch;

Expand Down Expand Up @@ -4517,6 +4514,8 @@ int gltfpack(const char* input, const char* output, const Settings& settings)

int main(int argc, char** argv)
{
meshopt_encodeIndexVersion(1);

Settings settings = {};
settings.pos_bits = 14;
settings.tex_bits = 12;
Expand Down

0 comments on commit 3b4d1c9

Please sign in to comment.