@@ -163,7 +163,6 @@ gltf_accessor_component::Type GetComponentTypeEnum( int id , uint* sizeInBytes
163163
164164idList<gltfData*> gltfData::dataList;
165165idHashIndex gltfData::fileDataHash;
166- gltfItemArray* gltfItem_Extra::items = new gltfItemArray();
167166
168167// Helper macros for gltf data deserialize
169168// NOTE: gltfItems that deviate from the default SET(T*) function cannot be handled with itemref macro.
@@ -300,14 +299,20 @@ int gltfItemArray::Fill( idLexer* lexer, idDict* strPairs )
300299 idToken token;
301300 bool parsing = true ;
302301 int parseCount = 0 ;
303- lexer->ExpectTokenString ( " { " );
302+ lexer->ReadToken ( &token );
304303 while ( parsing && !lexer->PeekTokenString ( " }" ) && lexer->ExpectAnyToken ( &token ) )
305304 {
306305 lexer->ExpectTokenString ( " :" );
307306 idStr key = token;
308307 idStr value;
309308 key.StripTrailingWhitespace ();
310- if ( lexer->PeekTokenString ( " {" ) )
309+ if ( lexer->PeekTokenString ( " [" ) )
310+ {
311+ lexer->ParseBracketSectionExact ( value );
312+ value.StripTrailingWhitespace ();
313+ strPairs->Set ( key, value );
314+ }
315+ else if ( lexer->PeekTokenString ( " {" ) )
311316 {
312317 lexer->ParseBracedSectionExact ( value );
313318 value.StripTrailingWhitespace ();
@@ -338,6 +343,7 @@ int gltfItemArray::Parse( idLexer* lexer, bool forwardLexer/* = false*/ )
338343 idToken token;
339344 bool parsing = true ;
340345 int parseCount = 0 ;
346+
341347 lexer->ExpectTokenString ( " {" );
342348 while ( parsing && !lexer->PeekTokenString ( " }" ) && lexer->ExpectAnyToken ( &token ) )
343349 {
@@ -362,7 +368,7 @@ int gltfItemArray::Parse( idLexer* lexer, bool forwardLexer/* = false*/ )
362368 }
363369 if ( !parsed )
364370 {
365- lexer->SkipBracedSection ();
371+ lexer->SkipBracedSection ( true , lexer-> PeekTokenString ( " { " ) ? BRSKIP_BRACES : BRSKIP_BRACKET );
366372 }
367373 else
368374 {
@@ -452,25 +458,18 @@ void gltfItem_Extra::parse( idToken& token )
452458{
453459 parser->UnreadToken ( &token );
454460 parser->ParseBracedSectionExact ( item->json );
455-
461+ gltfItemArray items;
456462 idLexer lexer ( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
457463 lexer.LoadMemory ( item->json , item->json .Size (), " gltfItem_Extra" , 0 );
458- items-> Fill ( &lexer, &item->strPairs );
464+ items. Fill ( &lexer, &item->strPairs );
459465 lexer.Reset ();
460- items->Parse ( &lexer , true );
461466
462467 if ( gltf_parseVerbose.GetBool () )
463468 {
464469 common->Printf ( " %s" , item->json .c_str () );
465470 }
466471}
467472
468- void gltfItem_Extra::Register ( parsable* extra )
469- {
470- common->DPrintf ( " ...Registering gltf Extra \" %s\" total(%i)\n " , extra->Name ().c_str (), items->Num () );
471- items->AddItemDef ( extra );
472- }
473-
474473void gltfItem_animation_sampler::parse ( idToken& token )
475474{
476475 gltfItemArray animSampler;
@@ -692,7 +691,6 @@ void gltfItem_number_array::parse( idToken& token )
692691
693692void gltfItem_vec4::parse ( idToken& token )
694693{
695-
696694 auto * numbers = new gltfItem_number_array ( " " );
697695 idList<double > numberarray;
698696 numbers->Set ( &numberarray, parser );
@@ -704,6 +702,7 @@ void gltfItem_vec4::parse( idToken& token )
704702
705703 double * val = numbers->item ->Ptr ();
706704 *item = idVec4 ( val[0 ], val[1 ], val[2 ], val[3 ] );
705+ delete numbers;
707706}
708707
709708void gltfItem_vec3::parse ( idToken& token )
@@ -719,6 +718,7 @@ void gltfItem_vec3::parse( idToken& token )
719718
720719 double * val = numbers->item ->Ptr ();
721720 *item = idVec3 ( val[0 ], val[1 ], val[2 ] );
721+ delete numbers;
722722}
723723
724724void gltfItem_vec2::parse ( idToken& token )
@@ -734,6 +734,7 @@ void gltfItem_vec2::parse( idToken& token )
734734
735735 double * val = numbers->item ->Ptr ();
736736 *item = idVec2 ( val[0 ], val[1 ] );
737+ delete numbers;
737738}
738739
739740void gltfItem_quat::parse ( idToken& token )
@@ -749,6 +750,7 @@ void gltfItem_quat::parse( idToken& token )
749750
750751 double * val = numbers->item ->Ptr ();
751752 *item = idQuat ( val[0 ] , val[1 ] , val[2 ] , val[3 ] );
753+ delete numbers;
752754}
753755
754756void gltfItem_mat4::parse ( idToken& token )
@@ -769,6 +771,7 @@ void gltfItem_mat4::parse( idToken& token )
769771 val[8 ], val[9 ], val[10 ], val[11 ],
770772 val[12 ], val[13 ], val[14 ], val[15 ]
771773 );
774+ delete numbers;
772775}
773776
774777void gltfItem_accessor_sparse::parse ( idToken& token )
0 commit comments