Przeglądaj źródła

Bugfix WIP: collada instanced nodes, still working on it.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@751 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
ulfjorensen 15 lat temu
rodzic
commit
a9161ede18
2 zmienionych plików z 12 dodań i 13 usunięć
  1. 7 8
      code/ColladaLoader.cpp
  2. 5 5
      code/ColladaLoader.h

+ 7 - 8
code/ColladaLoader.cpp

@@ -178,8 +178,8 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla
 	// create a node for it
 	// create a node for it
 	aiNode* node = new aiNode();
 	aiNode* node = new aiNode();
 
 
-  // find a name for the new node. It's more complicated than you might think
-  node->mName.Set( FindNameForNode( pNode));
+	// find a name for the new node. It's more complicated than you might think
+	node->mName.Set( FindNameForNode( pNode));
 
 
 	// calculate the transformation matrix for it
 	// calculate the transformation matrix for it
 	node->mTransformation = pParser.CalculateResultTransform( pNode->mTransforms);
 	node->mTransformation = pParser.CalculateResultTransform( pNode->mTransforms);
@@ -192,18 +192,17 @@ aiNode* ColladaLoader::BuildHierarchy( const ColladaParser& pParser, const Colla
 	node->mNumChildren = pNode->mChildren.size()+instances.size();
 	node->mNumChildren = pNode->mChildren.size()+instances.size();
 	node->mChildren = new aiNode*[node->mNumChildren];
 	node->mChildren = new aiNode*[node->mNumChildren];
 
 
-	unsigned int a = 0;
-	for(; a < pNode->mChildren.size(); a++)
+	for( size_t a = 0; a < pNode->mChildren.size(); a++)
 	{
 	{
 		node->mChildren[a] = BuildHierarchy( pParser, pNode->mChildren[a]);
 		node->mChildren[a] = BuildHierarchy( pParser, pNode->mChildren[a]);
 		node->mChildren[a]->mParent = node;
 		node->mChildren[a]->mParent = node;
 	}
 	}
 
 
 	// ... and finally the resolved node instances
 	// ... and finally the resolved node instances
-	for(; a < node->mNumChildren; a++)
+	for( size_t a = 0; a < instances.size(); a++)
 	{
 	{
-		node->mChildren[a] = BuildHierarchy( pParser, instances[a-pNode->mChildren.size()]);
-		node->mChildren[a]->mParent = node;
+		node->mChildren[pNode->mChildren.size() + a] = BuildHierarchy( pParser, instances[a]);
+		node->mChildren[pNode->mChildren.size() + a]->mParent = node;
 	}
 	}
 
 
 	// construct meshes
 	// construct meshes
@@ -1263,7 +1262,7 @@ void ColladaLoader::BuildMaterials( const ColladaParser& pParser, aiScene* pScen
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Resolves the texture name for the given effect texture entry
 // Resolves the texture name for the given effect texture entry
-const aiString& ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pParser,
+aiString ColladaLoader::FindFilenameForEffectTexture( const ColladaParser& pParser,
 	const Collada::Effect& pEffect, const std::string& pName)
 	const Collada::Effect& pEffect, const std::string& pName)
 {
 {
 	// recurse through the param references until we end up at an image
 	// recurse through the param references until we end up at an image

+ 5 - 5
code/ColladaLoader.h

@@ -173,7 +173,7 @@ protected:
 		aiTextureType type, unsigned int idx = 0);
 		aiTextureType type, unsigned int idx = 0);
 
 
 	/** Resolves the texture name for the given effect texture entry */
 	/** Resolves the texture name for the given effect texture entry */
-	const aiString& FindFilenameForEffectTexture( const ColladaParser& pParser, 
+	aiString FindFilenameForEffectTexture( const ColladaParser& pParser, 
 		const Collada::Effect& pEffect, const std::string& pName);
 		const Collada::Effect& pEffect, const std::string& pName);
 
 
 	/** Converts a path read from a collada file to the usual representation */
 	/** Converts a path read from a collada file to the usual representation */
@@ -201,11 +201,11 @@ protected:
 
 
 	/** Finds a node in the collada scene by the given name */
 	/** Finds a node in the collada scene by the given name */
 	const Collada::Node* FindNode( const Collada::Node* pNode, const std::string& pName) const;
 	const Collada::Node* FindNode( const Collada::Node* pNode, const std::string& pName) const;
-  /** Finds a node in the collada scene by the given SID */
-  const Collada::Node* FindNodeBySID( const Collada::Node* pNode, const std::string& pSID) const;
+	/** Finds a node in the collada scene by the given SID */
+	const Collada::Node* FindNodeBySID( const Collada::Node* pNode, const std::string& pSID) const;
 
 
-  /** Finds a proper name for a node derived from the collada-node's properties */
-  std::string FindNameForNode( const Collada::Node* pNode) const;
+	/** Finds a proper name for a node derived from the collada-node's properties */
+	std::string FindNameForNode( const Collada::Node* pNode) const;
 
 
 protected:
 protected:
 	/** Filename, for a verbose error message */
 	/** Filename, for a verbose error message */