]> git.tdb.fi Git - libs/gl.git/commitdiff
Better naming algorithm for objects in scene export
authorMikko Rasa <tdb@tdb.fi>
Sat, 1 Jun 2019 12:55:28 +0000 (15:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 1 Jun 2019 12:55:28 +0000 (15:55 +0300)
Arbitrary prefixes can cut words or numbers in silly places.  Only allow
truncating at common separator characters.

blender/io_mspgl/export_scene.py

index 9b36c48ff43faadb0f7ef6da596f37e7806dfd47..245d2d3efeef77db689367a2667e7eb16e341d1d 100644 (file)
@@ -39,10 +39,11 @@ class SceneExporter:
 
                        prefix = o.name
                        for c in clones:
-                               for i in range(min(len(c.name), len(prefix))):
-                                       if c.name[i]!=prefix[i]:
-                                               prefix = prefix[:i]
-                                               break
+                               while not c.name.startswith(prefix):
+                                       pos = max(prefix.rfind(' '), prefix.rfind('.'))
+                                       if pos<0:
+                                               break;
+                                       prefix = prefix[:pos]
 
                        if prefix:
                                export_names[o.name+".object"] = prefix.strip(" .")+".object"