3737bl_info = {
3838 "name" : "XAtlas Unwrapper" ,
3939 "author" : "Nico Breycha" ,
40- "version" : (0 , 0 , 3 ),
40+ "version" : (0 , 0 , 4 ),
4141 "blender" : (4 , 0 , 0 ),
4242 "location" : "View3D > Sidebar > Tool Tab" ,
4343 "description" : "Unwraps the model using xatals." ,
@@ -76,14 +76,26 @@ def uninstall_xatlas_package():
7676 subprocess .check_call (["pip" , "uninstall" , "-y" , "xatlas" ])
7777
7878
79+ def _process_mesh_single_process (data ):
80+ obj_name , vertices , faces = data
81+ try :
82+ import xatlas
83+ # Parametrize the mesh using xatlas
84+ vmapping , indices , uvs = xatlas .parametrize (vertices , faces )
85+ return obj_name , vmapping , indices , uvs , None
86+ except Exception as e :
87+ # Return the exception message to the main process
88+ return obj_name , None , None , None , str (e )
89+
90+
7991def _process_mesh_multiprocessing (data ):
8092 obj_name , vertices , faces = data
8193 try :
8294 # Save original sys.path
8395 original_sys_path = sys .path .copy ()
8496
8597 # Remove Blender-specific paths
86- sys .path = [p for p in sys .path if ' blender' not in p .lower () and ' scripts' not in p .lower ()]
98+ sys .path = [p for p in sys .path if " blender" not in p .lower () and " scripts" not in p .lower ()]
8799
88100 import xatlas # Import xatlas in the subprocess
89101
@@ -164,7 +176,7 @@ def execute(self, context):
164176
165177 try :
166178 # Restore sys.path to original before starting multiprocessing
167- sys .path = [p for p in original_sys_path if ' blender' not in p .lower () and ' scripts' not in p .lower ()]
179+ sys .path = [p for p in original_sys_path if " blender" not in p .lower () and " scripts" not in p .lower ()]
168180
169181 # Use multiprocessing Pool
170182 multiprocessing .freeze_support ()
@@ -178,6 +190,12 @@ def execute(self, context):
178190 results .append (result )
179191 progress += 1
180192 context .window_manager .progress_update (progress )
193+ except ImportError as e :
194+ # Multiprocessing not available (This is our fallback for using as plugin)
195+ self .report ({"INFO" }, f"Multiprocessing not available: { e } " )
196+ results = []
197+ for data in mesh_data_list :
198+ results .append (_process_mesh_single_process (data ))
181199 except Exception as e :
182200 self .report ({"ERROR" }, f"Multiprocessing failed: { e } " )
183201 context .window_manager .progress_end ()
0 commit comments