From d164943ee230b7cc036695eceb4cf376947c6e77 Mon Sep 17 00:00:00 2001 From: Frank Galligan Date: Sat, 7 Oct 2017 11:54:34 -0700 Subject: [PATCH] spec: Add connectivity_method == 0 to Sequential decoder This addresses a comment in KhronosGroup/glTF#1114 --- docs/spec/sequential.decoder.md | 42 ++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/docs/spec/sequential.decoder.md b/docs/spec/sequential.decoder.md index 2209387..5ba0677 100644 --- a/docs/spec/sequential.decoder.md +++ b/docs/spec/sequential.decoder.md @@ -55,11 +55,10 @@ void ParseSequentialIndicesUI32() { {:.draco-syntax } -### DecodeSequentialConnectivityData() +### DecodeSequentialIndices() ~~~~~ -void DecodeSequentialConnectivityData() { - ParseSequentialConnectivityData(); +void DecodeSequentialIndices() { if (num_points < 256) { ParseSequentialIndicesUI8(); } else if (num_points < (1 << 16)) { @@ -70,3 +69,40 @@ void DecodeSequentialConnectivityData() { } ~~~~~ {:.draco-syntax } + + +### DecodeSequentialCompressedIndices() + +~~~~~ +void DecodeSequentialCompressedIndices() { + DecodeSymbols(num_faces * 3, 1, &decoded_symbols); + last_index_value = 0; + for (i = 0; i < num_faces; ++i) { + for (j = 0; j < 3; ++j) { + encoded_val = decoded_symbols[i * 3 + j]; + index_diff = (encoded_val >> 1); + if (encoded_val & 1) + index_diff = -index_diff; + val = index_diff + last_index_value; + face_to_vertex[j][i] = val; + last_index_value = val; + } + } +} +~~~~~ +{:.draco-syntax } + + +### DecodeSequentialConnectivityData() + +~~~~~ +void DecodeSequentialConnectivityData() { + ParseSequentialConnectivityData(); + if (connectivity_method == 0) { + DecodeSequentialCompressedIndices(); + } else if (connectivity_method == 1) { + DecodeSequentialIndices(); + } +} +~~~~~ +{:.draco-syntax }