Compare commits

...

5 Commits

Author SHA1 Message Date
christophe.seux 6798053389 Update README.md 2024-10-30 17:36:07 +01:00
christophe.seux de3b78e741 Update README.md 2024-10-30 17:35:16 +01:00
christophe.seux 76ea717df8 Update README.md 2024-10-30 17:34:17 +01:00
ChristopheSeux 7d2d69ba0f Fix pack picker if missing 2024-03-04 09:55:46 +01:00
ChristopheSeux 75bc414e26 bone space in context menu 2024-02-28 09:59:11 +01:00
7 changed files with 38 additions and 14 deletions

View File

@ -2,6 +2,8 @@
> Blender addon for picking rig contollers > Blender addon for picking rig contollers
Rig_picker is an OpenGl tool for having a 2d interface for the 3d animators allowing them to pick a controller easily. Rig_picker is an OpenGl tool for having a 2d interface for the 3d animators allowing them to pick a controller easily.
The addon is drawing 2d shapes inside a dedicated Node Editor Area using the gpu module.
You can use multiple pickers for one rig, each picker shapes are in there own collection.
Video of the previous version : https://vimeo.com/241970235 Video of the previous version : https://vimeo.com/241970235
@ -23,7 +25,12 @@ Video of the previous version : https://vimeo.com/241970235
<!-- INSTALLATION --> <!-- INSTALLATION -->
## Installation ## Installation
For external user, you can clone the repository using:
```sh
git clone https://git.autourdeminuit.com/autour_de_minuit/rig_picker.git
```
For Internal user:
1. Create your own local directory in 1. Create your own local directory in
```sh ```sh
/home/<USER>/dev /home/<USER>/dev

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 = []
@ -736,8 +736,11 @@ def get_picker_path(rig, source, start=None):
def pack_picker(rig, start=None): def pack_picker(rig, start=None):
if not 'rig_picker' in rig.data:
return
pickers = [] pickers = []
for picker_source in rig.data.get('rig_picker', {}).get('sources', {}): for picker_source in rig.data['rig_picker'].get('sources', []):
picker_path = get_picker_path(rig, picker_source['source'], start) picker_path = get_picker_path(rig, picker_source['source'], start)
if not picker_path.exists(): if not picker_path.exists():
print(f'{picker_path} not exists') print(f'{picker_path} not exists')

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 = (