Skip to content

Commit

Permalink
Fix #12 and other issues related to hidden objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
ucupumar committed Mar 27, 2018
1 parent 61ad70e commit 1d2fee4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bake_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def downsample_images(self):
bpy.data.images.remove(img, do_unlink=True)

def select_object(self, o):
o.hide = False
sce = bpy.context.scene
bpy.ops.object.select_all(action='DESELECT')
o.select = True
Expand Down Expand Up @@ -829,6 +830,7 @@ def remember_stuffs(self, context):
# Remember active object and object selection
self.original_active_object = context.object
self.original_selected_objects = [o for o in sce.objects if o.select]
self.original_object_hide = [o for o in sce.objects if o.hide]
#self.old_mode = context.object.mode
self.old_active_layers = [i for i, layer in enumerate(sce.layers) if layer == True]

Expand Down Expand Up @@ -948,6 +950,11 @@ def recover_stuffs(self, context):
o.select = True
else: o.select = False

# Recover hide
if o in self.original_object_hide:
o.hide = True
else: o.hide = False

# Recover object layers
if o.name in self.original_object_layers:
# Set active layer
Expand Down Expand Up @@ -1051,7 +1058,9 @@ def execute(self, context):
self.baked_count = 0

# Go to object mode
old_hide = context.object.hide
old_mode = context.object.mode
context.object.hide = False
bpy.ops.object.mode_set(mode='OBJECT')

# Turn off material override
Expand Down Expand Up @@ -1086,6 +1095,7 @@ def execute(self, context):

# Go back to old mode
bpy.ops.object.mode_set(mode=old_mode)
context.object.hide = old_hide

# Select target image
mat = context.object.active_material
Expand Down
2 changes: 1 addition & 1 deletion header_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def mode_switcher_panel(layout):
if not obj or obj.mode == 'OBJECT':
row.alert = False

if obj and in_active_layer(obj):
if obj and not obj.hide and in_active_layer(obj):

use_mode_particle_edit = (
len(obj.particle_systems) > 0 or
Expand Down
5 changes: 5 additions & 0 deletions material_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ def execute(self, context):
if obj:
old_active = obj.name
old_mode = obj.mode
old_hide = obj.hide
old_selects = [o for o in context.selected_objects]

# Halt update
Expand All @@ -499,6 +500,9 @@ def execute(self, context):
if not mats: return {'FINISHED'}

if obj:
# Unhide object
obj.hide = False

bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')

Expand Down Expand Up @@ -548,6 +552,7 @@ def execute(self, context):
scene.objects.active = scene.objects.get(old_active)
if in_active_layer(obj):
bpy.ops.object.mode_set(mode=old_mode)
obj.hide = old_hide

mat = get_active_material()

Expand Down
3 changes: 3 additions & 0 deletions paint_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ def execute(self, context):

# Add simple uvs
old_mode = obj.mode
old_hide = obj.hide
obj.hide = False
bpy.ops.object.mode_set(mode='TEXTURE_PAINT')
bpy.ops.paint.add_simple_uvs()
bpy.ops.object.mode_set(mode=old_mode)
obj.hide = old_hide

#new_uv = mesh.uv_layers.active
#new_uv.name = 'SimpleUV'
Expand Down

0 comments on commit 1d2fee4

Please sign in to comment.