src/GLTFLoader.cpp
int GetNodeIndex(cgltf_node* target, cgltf_node* nodes, unsigned int numNodes)
   {
      if (target == nullptr)
      {
         return -1;
      }

      for (unsigned int nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex)
      {
         if (target == &nodes[nodeIndex])
         {
            return static_cast<int>(nodeIndex);
         }
      }

      return -1;
   }
// A glTF file may contain an array of scenes and an array of nodes
// Each scene may contain an array of indices of nodes
// Each node may contain an array of indices of its children
// The function below linearly searches for a specific node in the array of nodes and returns its index
A glTF file may contain an array of scenes and an array of nodes
Each scene may contain an array of indices of nodes
Each node may contain an array of indices of its children
The function below linearly searches for a specific node in the array of nodes and returns its index
A glTF file may contain an array of scenes and an array of nodes Each scene may contain an array of indices of nodes Each node may contain an array of indices of its children The function below linearly searches for a specific node in the array of nodes and returns its index
int GetNodeIndex(cgltf_node* target, cgltf_node* nodes, unsigned int numNodes)
   {
      if (target == nullptr)
      {
         return -1;
      }
      for (unsigned int nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex)
      {
         if (target == &nodes[nodeIndex])
         {
            return static_cast<int>(nodeIndex);
         }
      }
      return -1;
   }
int GetNodeIndex ( cgltf_node * target , cgltf_node * nodes , unsigned int numNodes ) { if ( target == nullptr ) { return -1 ; } for ( unsigned int nodeIndex = 0 ; nodeIndex < numNodes ; ++ nodeIndex ) { if ( target == & nodes [ nodeIndex ] ) { return static_cast < int > ( nodeIndex ) ; } } return -1 ; }
A glTF file may contain an array of scenes and an array of nodes
Each scene may contain an array of indices of nodes
Each node may contain an array of indices of its children
The function below linearly searches for a specific node in the array of nodes and returns its index
A glTF file may contain an array of scenes and an array of nodes Each scene may contain an array of indices of nodes Each node may contain an array of indices of its children The function below linearly searches for a specific node in the array of nodes and returns its index