Browse Source

Add a condition to detect duplicates objects, so cases like object-col.323, common in blender, is still detected as collision.

Juan Linietsky 7 years ago
parent
commit
beebd0b9de
1 changed files with 11 additions and 3 deletions
  1. 11 3
      editor/import/resource_importer_scene.cpp

+ 11 - 3
editor/import/resource_importer_scene.cpp

@@ -224,11 +224,19 @@ String ResourceImporterScene::get_preset_name(int p_idx) const {
 
 static bool _teststr(const String &p_what, const String &p_str) {
 
-	if (p_what.findn("$" + p_str) != -1) //blender and other stuff
+	String str = p_str;
+
+	//remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this
+	while (str.length() && ((str[str.length() - 1] >= '0' && str[str.length() - 1] <= '9') || str[str.length() - 1] <= 32 || str[str.length() - 1] == '.')) {
+
+		str = str.substr(0, str.length() - 1);
+	}
+
+	if (p_what.findn("$" + str) != -1) //blender and other stuff
 		return true;
-	if (p_what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
+	if (p_what.to_lower().ends_with("-" + str)) //collada only supports "_" and "-" besides letters
 		return true;
-	if (p_what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
+	if (p_what.to_lower().ends_with("_" + str)) //collada only supports "_" and "-" besides letters
 		return true;
 	return false;
 }