@@ -265,31 +265,32 @@ bool LLGLTFLoader::parseMeshes()
265
265
std::map<std::string, S32> mesh_name_counts;
266
266
U32 submodel_limit = mGLTFAsset .mNodes .size () > 0 ? mGeneratedModelLimit / (U32)mGLTFAsset .mNodes .size () : 0 ;
267
267
268
- // Build parent mapping for efficient traversal
269
- std::vector<S32> node_parents (mGLTFAsset .mNodes .size (), -1 );
270
- std::vector<bool > is_root (mGLTFAsset .mNodes .size (), true );
271
-
272
- // Build parent relationships
273
- for (size_t parent_idx = 0 ; parent_idx < mGLTFAsset .mNodes .size (); parent_idx++)
268
+ // Check if we have scenes defined
269
+ if (!mGLTFAsset .mScenes .empty ())
274
270
{
275
- const auto & parent_node = mGLTFAsset .mNodes [parent_idx];
276
- for (S32 child_idx : parent_node.mChildren )
271
+ // Process the default scene (or first scene if no default)
272
+ S32 scene_idx = mGLTFAsset .mScene >= 0 ? mGLTFAsset .mScene : 0 ;
273
+
274
+ if (scene_idx < mGLTFAsset .mScenes .size ())
277
275
{
278
- if (child_idx >= 0 && child_idx < static_cast <S32>(mGLTFAsset .mNodes .size ()))
276
+ const LL::GLTF::Scene& scene = mGLTFAsset .mScenes [scene_idx];
277
+
278
+ LL_INFOS (" GLTF_IMPORT" ) << " Processing scene " << scene_idx << " with " << scene.mNodes .size () << " root nodes" << LL_ENDL;
279
+
280
+ // Process all root nodes defined in the scene
281
+ for (S32 root_idx : scene.mNodes )
279
282
{
280
- node_parents[child_idx] = static_cast <S32>(parent_idx);
281
- is_root[child_idx] = false ;
283
+ if (root_idx >= 0 && root_idx < static_cast <S32>(mGLTFAsset .mNodes .size ()))
284
+ {
285
+ processNodeHierarchy (root_idx, mesh_name_counts, submodel_limit, volume_params);
286
+ }
282
287
}
283
288
}
284
289
}
285
-
286
- // Process all root nodes and their hierarchies
287
- for (size_t node_idx = 0 ; node_idx < mGLTFAsset .mNodes .size (); node_idx++)
290
+ else
288
291
{
289
- if (is_root[node_idx])
290
- {
291
- processNodeHierarchy (static_cast <S32>(node_idx), mesh_name_counts, submodel_limit, volume_params);
292
- }
292
+ LL_WARNS (" GLTF_IMPORT" ) << " No scenes defined in GLTF file" << LL_ENDL;
293
+ return false ;
293
294
}
294
295
295
296
return true ;
@@ -302,6 +303,10 @@ void LLGLTFLoader::processNodeHierarchy(S32 node_idx, std::map<std::string, S32>
302
303
303
304
auto & node = mGLTFAsset .mNodes [node_idx];
304
305
306
+ LL_INFOS (" GLTF_IMPORT" ) << " Processing node " << node_idx << " (" << node.mName << " )"
307
+ << " - has mesh: " << (node.mMesh >= 0 ? " yes" : " no" )
308
+ << " - children: " << node.mChildren .size () << LL_ENDL;
309
+
305
310
// Process this node's mesh if it has one
306
311
if (node.mMesh >= 0 && node.mMesh < mGLTFAsset .mMeshes .size ())
307
312
{
@@ -378,6 +383,12 @@ void LLGLTFLoader::processNodeHierarchy(S32 node_idx, std::map<std::string, S32>
378
383
return ;
379
384
}
380
385
}
386
+ else if (node.mMesh >= 0 )
387
+ {
388
+ // Log invalid mesh reference
389
+ LL_WARNS (" GLTF_IMPORT" ) << " Node " << node_idx << " references invalid mesh " << node.mMesh
390
+ << " (total meshes: " << mGLTFAsset .mMeshes .size () << " )" << LL_ENDL;
391
+ }
381
392
382
393
// Process all children recursively
383
394
for (S32 child_idx : node.mChildren )
0 commit comments