-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathskw_props.py
47 lines (37 loc) · 1.52 KB
/
skw_props.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import bpy
class SKW_ListItem(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(default='')
checked: bpy.props.BoolProperty(default=True)
class SKW_Property(bpy.types.PropertyGroup):
shape_keys_to_transfer: bpy.props.CollectionProperty(type=SKW_ListItem)
shape_key_index: bpy.props.IntProperty()
transfer_by_list: bpy.props.BoolProperty(default=False)
show_advanced: bpy.props.BoolProperty(default=False)
bind_noise: bpy.props.BoolProperty(default=False)
min_noise: bpy.props.FloatProperty(default=-0.0001, precision=5)
max_noise: bpy.props.FloatProperty(default=0.0001, precision=5)
def refresh_shape_keys(self, mesh, default=None):
old_values = dict()
for sk in self.shape_keys_to_transfer:
old_values[sk.name] = sk.checked
self.shape_keys_to_transfer.clear()
if mesh.shape_keys is None:
return
for idx, sk in enumerate(mesh.shape_keys.key_blocks):
if idx == 0:
continue
item = self.shape_keys_to_transfer.add()
item.name = sk.name
if default is None:
item.checked = old_values.get(item.name, False)
else:
item.checked = default
classes = [SKW_ListItem, SKW_Property]
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.types.Mesh.skw_prop = bpy.props.PointerProperty(type=SKW_Property)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
del bpy.types.Mesh.skw_prop