bone space in context menu

master
ChristopheSeux 2024-02-28 09:59:11 +01:00
parent 150bae5920
commit 75bc414e26
6 changed files with 27 additions and 13 deletions

View File

@ -155,6 +155,7 @@ classes = (
def register(): def register():
# Remove the tools inside the picker space
bpy.types.WM_OT_tool_set_by_id._execute = bpy.types.WM_OT_tool_set_by_id.execute #tool_set_by_id bpy.types.WM_OT_tool_set_by_id._execute = bpy.types.WM_OT_tool_set_by_id.execute #tool_set_by_id
bpy.types.WM_OT_tool_set_by_id.execute = tool_set_by_id bpy.types.WM_OT_tool_set_by_id.execute = tool_set_by_id

View File

@ -459,7 +459,7 @@ class Picker:
if shape.type == 'bone' and shape.hover: if shape.type == 'bone' and shape.hover:
shape.assign_bone_event() shape.assign_bone_event()
bpy.ops._rigpicker.save_picker(index=self.index) bpy.ops.rigpicker.save_picker(index=self.index)
def press_event(self, mode='SET'): def press_event(self, mode='SET'):
for shape in self.shapes: for shape in self.shapes:
@ -712,7 +712,7 @@ class PickerGroup:
def load_picker_data(rig): def load_picker_data(rig):
if 'pickers' in rig.data.rig_picker: if 'pickers' in rig.data.rig_picker:
picker_datas = [p.to_dict() for p in rig.rig_picker['pickers']] picker_datas = [[s.to_dict() for s in p] for p in rig.data.rig_picker['pickers']]
else: else:
picker_datas = [] picker_datas = []

View File

@ -93,7 +93,7 @@ def get_shape_data(ob, matrix=None, depsgraph=None):
for vert in mesh.vertices: for vert in mesh.vertices:
co = matrix @ (ob.matrix_world @ Vector(vert.co)) co = matrix @ (ob.matrix_world @ Vector(vert.co))
points.append([round(co[0]), round(co[1])]) points.append([round(co[0], 1), round(co[1], 1)])
depths += [co[2]] depths += [co[2]]

View File

@ -68,6 +68,8 @@ class RP_GT_gizmo(Gizmo):
context.region.tag_redraw() context.region.tag_redraw()
#print(location)
return -1 return -1

View File

@ -392,24 +392,19 @@ class RP_OT_reload_picker(Operator):
# return # return
def execute(self, context): def execute(self, context):
#PICKERS.clear()
if context.object.type == 'ARMATURE': if context.object.type == 'ARMATURE':
rig = context.object rig = context.object
else: else:
collection = get_picker_collection(context.object) collection = get_picker_collection(context.object)
rig = collection.rig_picker.rig rig = collection.rig_picker.rig
#print('Reload', rig)
load_picker_data(rig) load_picker_data(rig)
'''
for area in context.screen.areas: for area in context.screen.areas:
#print(area.type, is_picker_space(area.spaces.active))
if is_picker_space(area.spaces.active): if is_picker_space(area.spaces.active):
print('Tag Redraw Region', area.type)
area.regions[0].tag_redraw()
area.tag_redraw() area.tag_redraw()
'''
return {"FINISHED"} return {"FINISHED"}
@ -551,7 +546,8 @@ class RP_MT_context_menu(Menu):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
col = layout.column() col = layout.column()
col.use_property_split = True col.operator_context = 'INVOKE_DEFAULT'
#col.use_property_split = True
ob = context.object ob = context.object
picker = PICKERS.get(ob) picker = PICKERS.get(ob)
@ -561,9 +557,25 @@ class RP_MT_context_menu(Menu):
else: else:
bone = context.active_pose_bone bone = context.active_pose_bone
# Draw Space Switch Operator
if getattr(ob.data, 'space_switch'):
space_switch = ob.data.space_switch
data_paths = [f'pose.bones["{bone.name}"]["{k}"]' for k in bone.keys()]
space_bone = next((s for s in space_switch.bones if s.data_path in data_paths), None)
if space_bone:
index = list(space_switch.bones).index(space_bone)
value = ob.path_resolve(space_bone.data_path)
space = next((s.name for s in space_bone.spaces if s.value == value), None)
op = col.operator("spaceswitch.change_space", text=f'({space})', icon='PINNED')
op.index=index
col.separator()
if bone: if bone:
for key in bone.keys(): for key in bone.keys():
layout.prop(bone,f'["{key}"]', slider=True) col.prop(bone,f'["{key}"]', slider=True)
#layout.operator("rigpicker.show_bone_layer", text="Show Bone Layer", ).type = 'ACTIVE' #layout.operator("rigpicker.show_bone_layer", text="Show Bone Layer", ).type = 'ACTIVE'
#layout.operator("rigidbody.objects_add", text="B Add Passive").type = 'PASSIVE' #layout.operator("rigidbody.objects_add", text="B Add Passive").type = 'PASSIVE'

View File

@ -222,7 +222,6 @@ class RP_OT_save_picker(Operator):
bpy.ops.rigpicker.reload_picker() bpy.ops.rigpicker.reload_picker()
return {'FINISHED'} return {'FINISHED'}
classes = ( classes = (