1
# ##### BEGIN GPL LICENSE BLOCK #####
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software Foundation,
15
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
# ##### END GPL LICENSE BLOCK #####
21
from bpy.types import Menu, Panel
23
from bl_ui.properties_physics_common import (
29
def cloth_panel_enabled(md):
30
return md.point_cache.is_baked is False
33
class CLOTH_MT_presets(Menu):
34
bl_label = "Cloth Presets"
35
preset_subdir = "cloth"
36
preset_operator = "script.execute_preset"
37
draw = Menu.draw_preset
40
class PhysicButtonsPanel():
41
bl_space_type = 'PROPERTIES'
42
bl_region_type = 'WINDOW'
43
bl_context = "physics"
46
def poll(cls, context):
48
rd = context.scene.render
49
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.cloth)
52
class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
55
def draw(self, context):
62
split = layout.split()
64
split.active = cloth_panel_enabled(md)
68
col.label(text="Presets:")
69
sub = col.row(align=True)
70
sub.menu("CLOTH_MT_presets", text=bpy.types.CLOTH_MT_presets.bl_label)
71
sub.operator("cloth.preset_add", text="", icon='ZOOMIN')
72
sub.operator("cloth.preset_add", text="", icon='ZOOMOUT').remove_active = True
74
col.label(text="Quality:")
75
col.prop(cloth, "quality", text="Steps", slider=True)
77
col.label(text="Material:")
78
col.prop(cloth, "mass")
79
col.prop(cloth, "structural_stiffness", text="Structural")
80
col.prop(cloth, "bending_stiffness", text="Bending")
84
col.label(text="Damping:")
85
col.prop(cloth, "spring_damping", text="Spring")
86
col.prop(cloth, "air_damping", text="Air")
87
col.prop(cloth, "vel_damping", text="Velocity")
89
col.prop(cloth, "use_pin_cloth", text="Pinning")
91
sub.active = cloth.use_pin_cloth
92
sub.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="")
93
sub.prop(cloth, "pin_stiffness", text="Stiffness")
95
col.label(text="Pre roll:")
96
col.prop(cloth, "pre_roll", text="Frame")
100
if cloth.vertex_group_mass:
101
layout.label(text="Goal:")
103
col = layout.column_flow()
104
col.prop(cloth, "goal_default", text="Default")
105
col.prop(cloth, "goal_spring", text="Stiffness")
106
col.prop(cloth, "goal_friction", text="Friction")
109
key = ob.data.shape_keys
112
col.label(text="Rest Shape Key:")
113
col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="")
116
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
117
bl_label = "Cloth Cache"
118
bl_options = {'DEFAULT_CLOSED'}
121
def poll(cls, context):
124
def draw(self, context):
126
point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
129
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
130
bl_label = "Cloth Collision"
131
bl_options = {'DEFAULT_CLOSED'}
134
def poll(cls, context):
137
def draw_header(self, context):
138
cloth = context.cloth.collision_settings
140
self.layout.active = cloth_panel_enabled(context.cloth)
141
self.layout.prop(cloth, "use_collision", text="")
143
def draw(self, context):
146
cloth = context.cloth.collision_settings
149
layout.active = cloth.use_collision and cloth_panel_enabled(md)
151
split = layout.split()
154
col.prop(cloth, "collision_quality", slider=True, text="Quality")
155
col.prop(cloth, "distance_min", slider=True, text="Distance")
156
col.prop(cloth, "repel_force", slider=True, text="Repel")
157
col.prop(cloth, "distance_repel", slider=True, text="Repel Distance")
158
col.prop(cloth, "friction")
161
col.prop(cloth, "use_self_collision", text="Self Collision")
163
sub.active = cloth.use_self_collision
164
sub.prop(cloth, "self_collision_quality", slider=True, text="Quality")
165
sub.prop(cloth, "self_distance_min", slider=True, text="Distance")
167
layout.prop(cloth, "group")
170
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
171
bl_label = "Cloth Stiffness Scaling"
172
bl_options = {'DEFAULT_CLOSED'}
175
def poll(cls, context):
178
def draw_header(self, context):
179
cloth = context.cloth.settings
181
self.layout.active = cloth_panel_enabled(context.cloth)
182
self.layout.prop(cloth, "use_stiffness_scale", text="")
184
def draw(self, context):
189
cloth = context.cloth.settings
191
layout.active = cloth.use_stiffness_scale and cloth_panel_enabled(md)
193
split = layout.split()
196
col.label(text="Structural Stiffness:")
197
col.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
198
col.prop(cloth, "structural_stiffness_max", text="Max")
201
col.label(text="Bending Stiffness:")
202
col.prop_search(cloth, "vertex_group_bending", ob, "vertex_groups", text="")
203
col.prop(cloth, "bending_stiffness_max", text="Max")
206
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
207
bl_label = "Cloth Field Weights"
208
bl_options = {'DEFAULT_CLOSED'}
211
def poll(cls, context):
212
return (context.cloth)
214
def draw(self, context):
215
cloth = context.cloth.settings
216
effector_weights_ui(self, context, cloth.effector_weights)
218
if __name__ == "__main__": # only for live edit.
219
bpy.utils.register_module(__name__)