[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4584] contrib/py/scripts/addons/ uv_texture_atlas.py: [TextureAtlas] refactoring.

paul geraskin paul_geraskin at mail.ru
Wed Jun 19 16:46:43 CEST 2013


Revision: 4584
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4584
Author:   mifth
Date:     2013-06-19 14:46:43 +0000 (Wed, 19 Jun 2013)
Log Message:
-----------
[TextureAtlas] refactoring.

Modified Paths:
--------------
    contrib/py/scripts/addons/uv_texture_atlas.py

Modified: contrib/py/scripts/addons/uv_texture_atlas.py
===================================================================
--- contrib/py/scripts/addons/uv_texture_atlas.py	2013-06-19 13:21:47 UTC (rev 4583)
+++ contrib/py/scripts/addons/uv_texture_atlas.py	2013-06-19 14:46:43 UTC (rev 4584)
@@ -92,7 +92,24 @@
             row.operator(
                 "object.ms_run_remove", text="Finsh Manual Unwrap/Bake", icon="LAMP_SPOT")
 
+    def check_all_objects_visible(self, context):
+            scene = context.scene
+            group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
+            isAllObjectsVisible = True
+            bpy.ops.object.select_all(action='DESELECT')
+            for thisObject in bpy.data.groups[group.name].objects:
+                isThisObjectVisible = False
+                #scene.objects.active = thisObject
+                for thisLayerNumb in range(20):
+                    if thisObject.layers[thisLayerNumb] is True and scene.layers[thisLayerNumb] is True:
+                        isThisObjectVisible = True
+                        break
+                # If Object is on an invisible Layer
+                if isThisObjectVisible is False:
+                    isAllObjectsVisible = False
+            return isAllObjectsVisible
 
+
 class runAuto(bpy.types.Operator):
     bl_idname = "object.ms_auto"
     bl_label = "Auto Unwrapping"
@@ -110,20 +127,9 @@
         if group.bake is True and bpy.data.groups[group.name].objects:
 
             # Check if objects are all on the visible Layers.
-            isAllObjectsVisible = True
-            bpy.ops.object.select_all(action='DESELECT')
-            for thisObject in bpy.data.groups[group.name].objects:
-                isThisObjectVisible = False
-                scene.objects.active = thisObject
-                for thisLayerNumb in range(20):
-                    if thisObject.layers[thisLayerNumb] is True and scene.layers[thisLayerNumb] is True:
-                        isThisObjectVisible = True
-                        break
-                # If Object is on an invisible Layer
-                if isThisObjectVisible is False:
-                    isAllObjectsVisible = False
+            isAllObjVisible = TextureAtlas.check_all_objects_visible(self, context)
 
-            if isAllObjectsVisible is True:
+            if isAllObjVisible is True:
                 res = int(scene.ms_lightmap_groups[group.name].resolution)
                 bpy.ops.object.ms_create_lightmap(
                     group_name=group.name, resolution=res)
@@ -155,20 +161,9 @@
         if group.bake is True and bpy.data.groups[group.name].objects:
 
             # Check if objects are all on the visible Layers.
-            isAllObjectsVisible = True
-            bpy.ops.object.select_all(action='DESELECT')
-            for thisObject in bpy.data.groups[group.name].objects:
-                isThisObjectVisible = False
-                scene.objects.active = thisObject
-                for thisLayerNumb in range(20):
-                    if thisObject.layers[thisLayerNumb] is True and scene.layers[thisLayerNumb] is True:
-                        isThisObjectVisible = True
-                        break
-                # If Object is on an invisible Layer
-                if isThisObjectVisible is False:
-                    isAllObjectsVisible = False
+            isAllObjVisible = TextureAtlas.check_all_objects_visible(self, context)
 
-            if isAllObjectsVisible is True:
+            if isAllObjVisible is True:
                 res = int(scene.ms_lightmap_groups[group.name].resolution)
                 bpy.ops.object.ms_create_lightmap(
                     group_name=group.name, resolution=res)
@@ -192,26 +187,15 @@
 
         group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
         context.area.type = 'VIEW_3D'
-        if scene.objects.active is not None:
-            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
 
         if group.bake is True and bpy.data.groups[group.name].objects:
 
             # Check if objects are all on the visible Layers.
-            isAllObjectsVisible = True
-            bpy.ops.object.select_all(action='DESELECT')
-            for thisObject in bpy.data.groups[group.name].objects:
-                isThisObjectVisible = False
-                scene.objects.active = thisObject
-                for thisLayerNumb in range(20):
-                    if thisObject.layers[thisLayerNumb] is True and scene.layers[thisLayerNumb] is True:
-                        isThisObjectVisible = True
-                        break
-                # If Object is on an invisible Layer
-                if isThisObjectVisible is False:
-                    isAllObjectsVisible = False
+            isAllObjVisible = TextureAtlas.check_all_objects_visible(self, context)
 
-            if isAllObjectsVisible is True:
+            if isAllObjVisible is True:
+                if scene.objects.active is not None:
+                    bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
                 bpy.ops.object.ms_separate_objects(group_name=group.name)
             else:
                 self.report({'INFO'}, "Not All Objects Are Visible!!!!")



More information about the Bf-extensions-cvs mailing list