Skip to content

Commit 3b4d1c9

Browse files
committed
gltfpack: Merge index streams into one when compressing
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.
1 parent 10426fd commit 3b4d1c9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tools/gltfpack.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,10 +3303,7 @@ size_t writeMeshIndices(std::vector<BufferView>& views, std::string& json_access
33033303
std::string scratch;
33043304
StreamFormat format = writeIndexStream(scratch, mesh.indices);
33053305

3306-
// note: we prefer to merge all index streams together; however, index codec currently doesn't handle concatenated index streams well and loses compression ratio
3307-
int variant = settings.compress ? -1 : 0;
3308-
3309-
size_t view = getBufferView(views, BufferView::Kind_Index, variant, format.stride, settings.compress);
3306+
size_t view = getBufferView(views, BufferView::Kind_Index, 0, format.stride, settings.compress);
33103307
size_t offset = views[view].data.size();
33113308
views[view].data += scratch;
33123309

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

45184515
int main(int argc, char** argv)
45194516
{
4517+
meshopt_encodeIndexVersion(1);
4518+
45204519
Settings settings = {};
45214520
settings.pos_bits = 14;
45224521
settings.tex_bits = 12;

0 commit comments

Comments
 (0)