Explorar o código

Possibly fixed BlenderLoader heap corruption.
Removed incompatible Assimp processing flag.

Lasse Öörni %!s(int64=12) %!d(string=hai) anos
pai
achega
f14cb1aafc

+ 1 - 1
Docs/Reference.dox

@@ -1484,7 +1484,7 @@ Options:
 -pX   Set path X for scene resources. Default is output file path
 -pX   Set path X for scene resources. Default is output file path
 -rX   Use scene node X as root node
 -rX   Use scene node X as root node
 -fX   Animation tick frequency to use if unspecified. Default 4800
 -fX   Animation tick frequency to use if unspecified. Default 4800
--o    Optimize scene hierarchy. Loses animations
+-o    Optimize redundant submeshes. Loses scene hierarchy and animations
 -t    Generate tangents
 -t    Generate tangents
 \endverbatim
 \endverbatim
 
 

+ 5 - 2
ThirdParty/Assimp/code/BlenderLoader.cpp

@@ -644,14 +644,17 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co
 
 
 	// collect per-submesh numbers
 	// collect per-submesh numbers
 	std::map<int,size_t> per_mat;
 	std::map<int,size_t> per_mat;
+	std::map<int,size_t> per_mat_verts;
 	for (int i = 0; i < mesh->totface; ++i) {
 	for (int i = 0; i < mesh->totface; ++i) {
 
 
 		const MFace& mf = mesh->mface[i];
 		const MFace& mf = mesh->mface[i];
 		per_mat[ mf.mat_nr ]++;
 		per_mat[ mf.mat_nr ]++;
+		per_mat_verts[ mf.mat_nr ] += mf.v4?4:3;
 	}
 	}
 	for (int i = 0; i < mesh->totpoly; ++i) {
 	for (int i = 0; i < mesh->totpoly; ++i) {
 		const MPoly& mp = mesh->mpoly[i];
 		const MPoly& mp = mesh->mpoly[i];
 		per_mat[ mp.mat_nr ]++;
 		per_mat[ mp.mat_nr ]++;
+		per_mat_verts[ mp.mat_nr ] += mp.totloop;
 	}
 	}
 
 
 	// ... and allocate the corresponding meshes
 	// ... and allocate the corresponding meshes
@@ -665,8 +668,8 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co
 		temp->push_back(new aiMesh());
 		temp->push_back(new aiMesh());
 
 
 		aiMesh* out = temp->back();
 		aiMesh* out = temp->back();
-		out->mVertices = new aiVector3D[it.second*4];
-		out->mNormals  = new aiVector3D[it.second*4];
+		out->mVertices = new aiVector3D[per_mat_verts[it.first]];
+		out->mNormals  = new aiVector3D[per_mat_verts[it.first]];
 
 
 		//out->mNumFaces = 0
 		//out->mNumFaces = 0
 		//out->mNumVertices = 0
 		//out->mNumVertices = 0

+ 2 - 2
Tools/AssetImporter/AssetImporter.cpp

@@ -198,7 +198,7 @@ void Run(const Vector<String>& arguments)
             "-pX   Set path X for scene resources. Default is output file path\n"
             "-pX   Set path X for scene resources. Default is output file path\n"
             "-rX   Use scene node X as root node\n"
             "-rX   Use scene node X as root node\n"
             "-fX   Animation tick frequency to use if unspecified. Default 4800\n"
             "-fX   Animation tick frequency to use if unspecified. Default 4800\n"
-            "-o    Optimize scene hierarchy. Loses animations\n"
+            "-o    Optimize redundant submeshes. Loses scene hierarchy and animations\n"
             "-t    Generate tangents\n"
             "-t    Generate tangents\n"
         );
         );
     }
     }
@@ -267,7 +267,7 @@ void Run(const Vector<String>& arguments)
                 break;
                 break;
                 
                 
             case 'o':
             case 'o':
-                flags |= aiProcess_OptimizeGraph | aiProcess_PreTransformVertices;
+                flags |= aiProcess_PreTransformVertices;
                 break;
                 break;
                 
                 
             case 'n':
             case 'n':