Merge from 2.5 r21160 through r21285
[blender.git] / release / ui / buttons_physic_cloth.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "physics"
8
9         def poll(self, context):
10                 return (context.cloth != None)
11                 
12 class Physic_PT_cloth(PhysicButtonsPanel):
13         __idname__ = "Physic_PT_cloth"
14         __label__ = "Cloth"
15
16         def draw(self, context):
17                 layout = self.layout
18                 cloth = context.cloth.settings
19                 
20                 split = layout.split()
21                 
22                 col = split.column()
23                 col.itemR(cloth, "quality", slider=True)
24                 col.itemR(cloth, "gravity")
25                 col.itemR(cloth, "mass")
26                 col.itemR(cloth, "mass_vertex_group", text="Vertex Group")
27
28                 col = split.column()
29                 col.itemL(text="Stiffness:")
30                 col.itemR(cloth, "structural_stiffness", text="Structural")
31                 col.itemR(cloth, "bending_stiffness", text="Bending")
32                 col.itemL(text="Damping:")
33                 col.itemR(cloth, "spring_damping", text="Spring")
34                 col.itemR(cloth, "air_damping", text="Air")
35                 
36                 # Disabled for now
37                 """
38                 if cloth.mass_vertex_group:
39                         layout.itemL(text="Goal:")
40                 
41                         col = layout.column_flow()
42                         col.itemR(cloth, "goal_default", text="Default")
43                         col.itemR(cloth, "goal_spring", text="Stiffness")
44                         col.itemR(cloth, "goal_friction", text="Friction")
45                 """
46
47 class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
48         __idname__= "PHYSICS_PT_cloth_cache"
49         __label__ = "Cache"
50         __default_closed__ = True
51
52         def draw(self, context):
53                 layout = self.layout
54
55                 cache = context.cloth.point_cache
56                 
57                 row = layout.row()
58                 row.itemR(cache, "name")
59                 
60                 row = layout.row()
61                 row.itemR(cache, "start_frame")
62                 row.itemR(cache, "end_frame")
63                 
64                 row = layout.row()
65                 
66                 if cache.baked == True:
67                         row.itemO("PTCACHE_OT_free_bake_cloth", text="Free Bake")
68                 else:
69                         row.item_booleanO("PTCACHE_OT_cache_cloth", "bake", True, text="Bake")
70                 
71                 subrow = row.row()
72                 subrow.enabled = cache.frames_skipped or cache.outdated
73                 subrow.itemO("PTCACHE_OT_cache_cloth", text="Calculate to Current Frame")
74                         
75                 row = layout.row()
76                 #row.enabled = particle_panel_enabled(psys)
77                 row.itemO("PTCACHE_OT_bake_from_cloth_cache", text="Current Cache to Bake")
78                 row.itemR(cache, "step");
79         
80                 row = layout.row()
81                 #row.enabled = particle_panel_enabled(psys)
82                 row.itemR(cache, "quick_cache")
83                 row.itemR(cache, "disk_cache")
84                 
85                 layout.itemL(text=cache.info)
86                 
87                 layout.itemS()
88                 
89                 row = layout.row()
90                 row.itemO("PTCACHE_OT_bake_all", "bake", True, text="Bake All Dynamics")
91                 row.itemO("PTCACHE_OT_free_bake_all", text="Free All Bakes")
92                 layout.itemO("PTCACHE_OT_bake_all", text="Update All Dynamics to current frame")
93                 
94 class Physic_PT_cloth_collision(PhysicButtonsPanel):
95         __idname__ = "Physic_PT_clothcollision"
96         __label__ = "Cloth Collision"
97         
98         def draw_header(self, context):
99                 layout = self.layout
100                 cloth = context.cloth.settings
101         
102                 layout.itemR(cloth, "enable_collision", text="")
103
104         def draw(self, context):
105                 layout = self.layout
106                 cloth = context.cloth.settings
107                 
108                 layout.active = cloth.enable_collision  
109                 
110                 col = layout.column_flow()
111                 col.itemR(cloth, "collision_quality", slider=True)
112                 col.itemR(cloth, "friction")
113                 col.itemR(cloth, "min_distance", text="MinDistance")
114                 
115                 
116                 layout.itemR(cloth, "enable_self_collision", text="Self Collision")
117                 
118                 col = layout.column_flow()
119                 col.active = cloth.enable_self_collision
120                 col.itemR(cloth, "self_collision_quality", slider=True)
121                 col.itemR(cloth, "self_min_distance", text="MinDistance")
122
123 class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
124         __idname__ = "Physic_PT_stiffness"
125         __label__ = "Cloth Stiffness Scaling"
126         
127         def draw_header(self, context):
128                 layout = self.layout
129                 cloth = context.cloth.settings
130         
131                 layout.itemR(cloth, "stiffness_scaling", text="")
132
133         def draw(self, context):
134                 layout = self.layout
135                 cloth = context.cloth.settings
136                 
137                 layout.active = cloth.stiffness_scaling 
138                 
139                 split = layout.split()
140                 
141                 sub = split.column()
142                 sub.itemL(text="Structural Stiffness:")
143                 sub.column().itemR(cloth, "structural_stiffness_vertex_group", text="VGroup")
144                 sub.itemR(cloth, "structural_stiffness_max", text="Max")
145                 
146                 sub = split.column()
147                 sub.itemL(text="Bending Stiffness:")
148                 sub.column().itemR(cloth, "bending_vertex_group", text="VGroup")
149                 sub.itemR(cloth, "bending_stiffness_max", text="Max")
150                 
151 bpy.types.register(Physic_PT_cloth)
152 bpy.types.register(PHYSICS_PT_cloth_cache)
153 bpy.types.register(Physic_PT_cloth_collision)
154 bpy.types.register(Physic_PT_cloth_stiffness)