From: Mikko Rasa Date: Sat, 1 Jun 2019 12:55:28 +0000 (+0300) Subject: Better naming algorithm for objects in scene export X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=inline;h=9d1fa012a23693768bbe287371e97751c03acc50;hp=b38a4cba9d2a9963a0937757eff9e955f18ddf2a;p=libs%2Fgl.git Better naming algorithm for objects in scene export Arbitrary prefixes can cut words or numbers in silly places. Only allow truncating at common separator characters. --- diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index 9b36c48f..245d2d3e 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -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"