فهرست منبع

Blender importer: always sort sets of objects by their name. Previously we accidentally ordered pointers to objects by their memory address, which was non-deterministic and caused regression tests to be flaky.

Alexander Gessler 10 سال پیش
والد
کامیت
1c64c590f2
2فایلهای تغییر یافته به همراه18 افزوده شده و 2 حذف شده
  1. 17 1
      code/BlenderIntermediate.h
  2. 1 1
      code/BlenderLoader.cpp

+ 17 - 1
code/BlenderIntermediate.h

@@ -118,6 +118,16 @@ namespace Blender {
 #ifdef _MSC_VER
 #	pragma warning(disable:4351)
 #endif
+
+	struct ObjectCompare {
+		bool operator() (const Object* left, const Object* right) const {
+			return strcmp(left->id.name, right->id.name) == -1;
+		}
+	};
+
+	// When keeping objects in sets, sort them by their name.
+	typedef std::set<const Object*, ObjectCompare> ObjectSet;
+
 	// --------------------------------------------------------------------
 	/** ConversionData acts as intermediate storage location for
 	 *  the various ConvertXXX routines in BlenderImporter.*/
@@ -130,7 +140,13 @@ namespace Blender {
 			, db(db)
 		{}
 
-		std::set<const Object*> objects;
+		struct ObjectCompare {
+			bool operator() (const Object* left, const Object* right) const {
+				return strcmp(left->id.name, right->id.name) == -1;
+			}
+		};
+
+		ObjectSet objects;
 
 		TempArray <std::vector, aiMesh> meshes;
 		TempArray <std::vector, aiCamera> cameras;

+ 1 - 1
code/BlenderLoader.cpp

@@ -1044,7 +1044,7 @@ aiLight* BlenderImporter::ConvertLight(const Scene& /*in*/, const Object* obj, c
 aiNode* BlenderImporter::ConvertNode(const Scene& in, const Object* obj, ConversionData& conv_data, const aiMatrix4x4& parentTransform)
 {
 	std::deque<const Object*> children;
-	for(std::set<const Object*>::iterator it = conv_data.objects.begin(); it != conv_data.objects.end() ;) {
+	for(ObjectSet::iterator it = conv_data.objects.begin(); it != conv_data.objects.end() ;) {
 		const Object* object = *it;
 		if (object->parent == obj) {
 			children.push_back(object);