Skip to content

Commit 3b0c8eb

Browse files
Merge pull request #16 from mattedicksoncom/dev
Dev 0.0.8
2 parents 188fc72 + 5c2cf43 commit 3b0c8eb

File tree

4 files changed

+554
-539
lines changed

4 files changed

+554
-539
lines changed

addons/blender_xatlas/__init__.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"author": "mattedickson",
1919
"wiki_url": "https://github.com/mattedicksoncom/blender-xatlas/",
2020
"tracker_url": "https://github.com/mattedicksoncom/blender-xatlas/issues",
21-
"version": (0, 0, 7),
21+
"version": (0, 0, 8),
2222
"blender": (2, 83, 0),
2323
"location": "3D View > Toolbox",
2424
"category": "Object",
@@ -43,6 +43,8 @@
4343
from queue import Queue, Empty
4444
import string
4545

46+
import uuid
47+
4648

4749
import importlib
4850
sys.path.append(__path__)
@@ -202,6 +204,11 @@ def get_collectionNames(self, context):
202204
colllectionNames.append((collection.name, collection.name, ""))
203205
return colllectionNames
204206

207+
def gen_safe_name():
208+
genId = uuid.uuid4().hex
209+
# genId = "u_" + genId.replace("-","_")
210+
return "u_" + genId
211+
205212
class PG_SharedProperties (PropertyGroup):
206213

207214
unwrapSelection : EnumProperty(
@@ -360,13 +367,16 @@ def execute(self, context):
360367
self.report({"WARNING"}, "Nothing Selected, please select Something")
361368
return {'FINISHED'}
362369

363-
#store the names of objects
370+
#store the names of objects to be lightmapped
364371
rename_dict = dict()
372+
safe_dict = dict()
365373

366374
#make sure all the objects have ligthmap uvs
367375
for obj in selected_objects:
368376
if obj.type == 'MESH':
369-
rename_dict[obj.name] = obj.name
377+
safe_name = gen_safe_name();
378+
rename_dict[obj.name] = (obj.name,safe_name)
379+
safe_dict[safe_name] = obj.name
370380
context.view_layer.objects.active = obj
371381
if obj.data.users > 1:
372382
obj.data = obj.data.copy() #make single user copy
@@ -417,6 +427,7 @@ def execute(self, context):
417427
#Will strip this down further later
418428
fakeFile = StringIO()
419429
export_obj_simple.save(
430+
rename_dict=rename_dict,
420431
context=bpy.context,
421432
filepath=fakeFile,
422433
mainUVChoiceType=sharedProperties.mainUVChoiceType,
@@ -586,7 +597,7 @@ class uvObject:
586597
bpy.ops.object.select_all(action='DESELECT')
587598

588599
obTest = importObject
589-
600+
obTest.obName = safe_dict[obTest.obName] #probably shouldn't just replace it
590601
bpy.context.scene.objects[obTest.obName].select_set(True)
591602
context.view_layer.objects.active = bpy.context.scene.objects[obTest.obName]
592603
bpy.ops.object.mode_set(mode = 'OBJECT')
@@ -659,8 +670,8 @@ class uvObject:
659670

660671
#select the original objects that were selected
661672
for objectName in rename_dict:
662-
if objectName in bpy.context.scene.objects:
663-
current_object = bpy.context.scene.objects[objectName]
673+
if objectName[0] in bpy.context.scene.objects:
674+
current_object = bpy.context.scene.objects[objectName[0]]
664675
current_object.select_set(True)
665676
context.view_layer.objects.active = current_object
666677

0 commit comments

Comments
 (0)