Merge pull request 'replace layers with collections' (#1) from for_blender_v4 into master
Reviewed-on: #1Gizmo
commit
b855e8ac37
|
@ -29,9 +29,9 @@ class Shape:
|
||||||
self.press = False
|
self.press = False
|
||||||
|
|
||||||
|
|
||||||
self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
|
self.shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
||||||
|
|
||||||
#self.hover_shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
|
#self.hover_shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
||||||
#self.hover_shader.uniform_float("color", [1, 1, 1, 0.1])
|
#self.hover_shader.uniform_float("color", [1, 1, 1, 0.1])
|
||||||
self.hover_color = [1, 1, 1, 0.1]
|
self.hover_color = [1, 1, 1, 0.1]
|
||||||
|
|
||||||
|
@ -124,33 +124,8 @@ class BoneShape(Shape):
|
||||||
self.type = 'bone'
|
self.type = 'bone'
|
||||||
self.bone = bone
|
self.bone = bone
|
||||||
self.active_color = [1, 1, 1, 0.1]
|
self.active_color = [1, 1, 1, 0.1]
|
||||||
#self.contour_shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
|
|
||||||
|
|
||||||
#self.contour_batches = []
|
self.bone_colors = self.get_bone_colors()
|
||||||
|
|
||||||
#self.line_batch =
|
|
||||||
#for loop in edges:
|
|
||||||
# loop_points = [points[i] for i in loop]
|
|
||||||
# batch = batch_for_shader(self.shader, 'LINE_LOOP', {"pos": loop_points})
|
|
||||||
# #self.contour_batches.append(batch)
|
|
||||||
|
|
||||||
theme = bpy.context.preferences.themes['Default']
|
|
||||||
self.bone_colors = {
|
|
||||||
'select': [*theme.view_3d.bone_pose, 1],
|
|
||||||
'normal': [0.05, 0.05, 0.05, 1],
|
|
||||||
'active': [*theme.view_3d.bone_pose_active, 1],
|
|
||||||
'hide': [0.85, 0.85, 0.85, 0.2],
|
|
||||||
}
|
|
||||||
|
|
||||||
if bone and bone.bone_group:
|
|
||||||
normal_color = bone.bone_group.colors.normal.copy()
|
|
||||||
normal_color.s *= 0.75
|
|
||||||
self.bone_colors['normal'] = [*normal_color, 1]
|
|
||||||
self.bone_colors['select'] = [*bone.bone_group.colors.select, 1]
|
|
||||||
self.bone_colors['active'] = [*bone.bone_group.colors.active, 1]
|
|
||||||
self.bone_colors['hide'] = [*normal_color, 0.1]
|
|
||||||
|
|
||||||
#self.color = [i for i in self.color]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def select(self):
|
def select(self):
|
||||||
|
@ -172,20 +147,14 @@ class BoneShape(Shape):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#return self.bone not in (bpy.context.visible_pose_bones or [])
|
#return self.bone not in (bpy.context.visible_pose_bones or [])
|
||||||
bl = [i for i, l in enumerate(self.bone.bone.layers) if l]
|
|
||||||
rl = [i for i, l in enumerate(self.rig.data.layers) if l]
|
return self.bone.bone.hide or not any(l.is_visible for l in self.bone.bone.collections)
|
||||||
return self.bone.bone.hide or not len(set(bl).intersection(rl))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bone_color(self):
|
def bone_color(self):
|
||||||
if not self.bone:
|
if not self.bone:
|
||||||
return [0, 0, 0, 1]
|
return [0, 0, 0, 1]
|
||||||
|
|
||||||
bone = self.bone.bone
|
|
||||||
|
|
||||||
bl = bone.layers
|
|
||||||
rl = self.rig.data.layers
|
|
||||||
|
|
||||||
if self.select and self.active:
|
if self.select and self.active:
|
||||||
return self.bone_colors['active']
|
return self.bone_colors['active']
|
||||||
elif self.select:
|
elif self.select:
|
||||||
|
@ -195,6 +164,35 @@ class BoneShape(Shape):
|
||||||
else:
|
else:
|
||||||
return self.bone_colors['normal']
|
return self.bone_colors['normal']
|
||||||
|
|
||||||
|
def get_bone_colors(self):
|
||||||
|
|
||||||
|
theme = bpy.context.preferences.themes['Default']
|
||||||
|
bone_colors = {
|
||||||
|
'select': [*theme.view_3d.bone_pose, 1],
|
||||||
|
'normal': [0.05, 0.05, 0.05, 1],
|
||||||
|
'active': [*theme.view_3d.bone_pose_active, 1],
|
||||||
|
'hide': [0.85, 0.85, 0.85, 0.2],
|
||||||
|
}
|
||||||
|
|
||||||
|
if not self.bone:
|
||||||
|
return bone_colors
|
||||||
|
|
||||||
|
if self.bone.color.palette == 'CUSTOM':
|
||||||
|
bone_color = self.bone
|
||||||
|
|
||||||
|
elif self.bone.color.palette == 'DEFAULT':
|
||||||
|
bone_color = self.bone.bone
|
||||||
|
|
||||||
|
normal_color = bone_color.color.custom.normal.copy()
|
||||||
|
normal_color.s *= 0.75
|
||||||
|
|
||||||
|
bone_colors['normal'] = [*normal_color, 1]
|
||||||
|
bone_colors['select'] = [*bone_color.color.custom.select, 1]
|
||||||
|
bone_colors['active'] = [*bone_color.color.custom.active, 1]
|
||||||
|
bone_colors['hide'] = [*normal_color, 0.1]
|
||||||
|
|
||||||
|
return bone_colors
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
gpu.state.blend_set('ALPHA')
|
gpu.state.blend_set('ALPHA')
|
||||||
|
|
||||||
|
@ -393,7 +391,7 @@ class Picker:
|
||||||
self.shapes = []
|
self.shapes = []
|
||||||
self.box_select = None
|
self.box_select = None
|
||||||
self.hover_shape = None
|
self.hover_shape = None
|
||||||
self.shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
|
self.shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
||||||
|
|
||||||
self.tooltip_shape = None
|
self.tooltip_shape = None
|
||||||
self.tooltip_mouse = None
|
self.tooltip_mouse = None
|
||||||
|
|
|
@ -98,7 +98,7 @@ class RP_OT_box_select(bpy.types.Operator):
|
||||||
|
|
||||||
mode: EnumProperty(items=[(i, i.title(), '') for i in ('SET', 'EXTEND', 'SUBSTRACT')])
|
mode: EnumProperty(items=[(i, i.title(), '') for i in ('SET', 'EXTEND', 'SUBSTRACT')])
|
||||||
|
|
||||||
color_shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
|
color_shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
||||||
dash_shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
|
dash_shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -324,9 +324,8 @@ class RP_OT_toogle_bone_layer(bpy.types.Operator):
|
||||||
hide = picker.hover_shape.hide
|
hide = picker.hover_shape.hide
|
||||||
|
|
||||||
if bone:
|
if bone:
|
||||||
for i, l in enumerate(bone.bone.layers):
|
for layer in bone.bone.collections:
|
||||||
if l:
|
layer.is_visible = hide
|
||||||
ob.data.layers[i] = hide
|
|
||||||
|
|
||||||
context.region.tag_redraw()
|
context.region.tag_redraw()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue