@@ -477,6 +477,27 @@ static void decodeVertexV1Custom()
477477 assert (memcmp (decoded, kVertexBuffer , sizeof (kVertexBuffer )) == 0 );
478478}
479479
480+ static void decodeVertexV1Deltas ()
481+ {
482+ const unsigned short expected[] = {
483+ 248 , 248 , 240 , 240 , 249 , 250 , 243 , 244 , 250 , 252 , 246 , 248 , 251 , 254 , 249 , 252 ,
484+ 252 , 256 , 252 , 256 , 253 , 258 , 255 , 260 , 254 , 260 , 258 , 264 , 255 , 262 , 261 , 268 ,
485+ 256 , 264 , 264 , 272 , 257 , 262 , 267 , 268 , 258 , 260 , 270 , 264 , 259 , 258 , 273 , 260 ,
486+ 260 , 256 , 276 , 256 , 261 , 254 , 279 , 252 , 262 , 252 , 282 , 248 , 263 , 250 , 285 , 244 , // clang-format :-/
487+ };
488+
489+ const unsigned char input[] = {
490+ 0xa1 , 0x99 , 0x99 , 0x01 , 0x2a , 0xaa , 0xaa , 0xaa , 0x02 , 0x04 , 0x44 , 0x44 , 0x44 , 0x43 , 0x33 , 0x33 ,
491+ 0x33 , 0x02 , 0x06 , 0x66 , 0x66 , 0x66 , 0x66 , 0x66 , 0x66 , 0x66 , 0x02 , 0x08 , 0x88 , 0x88 , 0x88 , 0x87 ,
492+ 0x77 , 0x77 , 0x77 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
493+ 0x00 , 0xf8 , 0x00 , 0xf8 , 0x00 , 0xf0 , 0x00 , 0xf0 , 0x00 , 0x01 , 0x01 , // clang-format :-/
494+ };
495+
496+ unsigned short decoded[sizeof (expected) / sizeof (expected[0 ])];
497+ assert (meshopt_decodeVertexBuffer (decoded, 16 , 8 , input, sizeof (input)) == 0 );
498+ assert (memcmp (decoded, expected, sizeof (expected)) == 0 );
499+ }
500+
480501static void encodeVertexMemorySafe ()
481502{
482503 const size_t vertex_count = sizeof (kVertexBuffer ) / sizeof (kVertexBuffer [0 ]);
@@ -610,9 +631,9 @@ static void decodeVertexDeltas()
610631 for (size_t i = 0 ; i < 16 ; ++i)
611632 {
612633 data[i * 4 + 0 ] = (unsigned short )(0xf8 + i * 1 );
613- data[i * 4 + 1 ] = (unsigned short )(0xf8 + i * 2 );
634+ data[i * 4 + 1 ] = (unsigned short )(0xf8 + (i < 8 ? i : 16 - i) * 2 );
614635 data[i * 4 + 2 ] = (unsigned short )(0xf0 + i * 3 );
615- data[i * 4 + 3 ] = (unsigned short )(0xf0 + i * 4 );
636+ data[i * 4 + 3 ] = (unsigned short )(0xf0 + (i < 8 ? i : 16 - i) * 4 );
616637 }
617638
618639 std::vector<unsigned char > buffer (meshopt_encodeVertexBufferBound (16 , 8 ));
@@ -2733,6 +2754,7 @@ void runTests()
27332754 decodeVertexV0Mode2 ();
27342755 decodeVertexV1 ();
27352756 decodeVertexV1Custom ();
2757+ decodeVertexV1Deltas ();
27362758
27372759 for (int version = 0 ; version <= 1 ; ++version)
27382760 {
0 commit comments