diff options
author | Paul Geraskin <paul_geraskin@mail.ru> | 2013-07-21 00:28:54 +0400 |
---|---|---|
committer | Paul Geraskin <paul_geraskin@mail.ru> | 2013-07-21 00:28:54 +0400 |
commit | 39168323d826e7dfa148cdbb1ba64751a11d3d90 (patch) | |
tree | bddf6e5fa13f63638b364a78c38db21adc9c5795 | |
parent | 0f1880cee40d30bdc24de29b46911403b115b6b0 (diff) |
[TextureAtlas] fixes if non MESH objects are in the group.
0.2.0 version now.
-rw-r--r-- | uv_texture_atlas.py | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/uv_texture_atlas.py b/uv_texture_atlas.py index c38eb6aa..271c1d89 100644 --- a/uv_texture_atlas.py +++ b/uv_texture_atlas.py @@ -20,7 +20,7 @@ bl_info = { "name": "Texture Atlas", "author": "Andreas Esau, Paul Geraskin, Campbell Barton", - "version": (0, 18), + "version": (0, 2, 0), "blender": (2, 6, 7), "location": "Properties > Render", "description": "A simple Texture Atlas for unwrapping many objects. It creates additional UV", @@ -429,10 +429,9 @@ class AddLightmapGroup(Operator): item.resolution = '1024' scene.ms_lightmap_groups_index = len(scene.ms_lightmap_groups) - 1 - # if len(context.selected_objects) > 0: + # Add selested objects to group for object in context.selected_objects: - # scene.objects.active = object - if context.active_object.type == 'MESH': + if object.type == 'MESH': obj_group.objects.link(object) return {'FINISHED'} @@ -493,24 +492,41 @@ class CreateLightmap(Operator): image.generated_type = 'COLOR_GRID' image.generated_width = self.resolution image.generated_height = self.resolution + obj_group = bpy.data.groups[self.group_name] + + # non MESH objects for removal list + NON_MESH_LIST = [] + + for object in obj_group.objects: + # Remove non MESH objects + if object.type != 'MESH': + NON_MESH_LIST.append(object) - for object in bpy.data.groups[self.group_name].objects: - if object.data.uv_textures.active is None: - tex = object.data.uv_textures.new() - tex.name = self.group_name else: - if self.group_name not in object.data.uv_textures: + # Add Image to faces + if object.data.uv_textures.active is None: tex = object.data.uv_textures.new() tex.name = self.group_name - tex.active = True - tex.active_render = True else: - tex = object.data.uv_textures[self.group_name] - tex.active = True - tex.active_render = True + if self.group_name not in object.data.uv_textures: + tex = object.data.uv_textures.new() + tex.name = self.group_name + tex.active = True + tex.active_render = True + else: + tex = object.data.uv_textures[self.group_name] + tex.active = True + tex.active_render = True + + for face_tex in tex.data: + face_tex.image = image + + # remove non NESH objects + for object in NON_MESH_LIST: + obj_group.objects.unlink(object) + + NON_MESH_LIST.clear() # clear array - for face_tex in tex.data: - face_tex.image = image return{'FINISHED'} |