Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / release / ui / buttons_physics_cloth.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
6         __region_type__ = "WINDOW"
7         __context__ = "physics"
8
9         def poll(self, context):
10                 ob = context.object
11                 rd = context.scene.render_data
12                 return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
13                 
14 class PHYSICS_PT_cloth(PhysicButtonsPanel):
15         __label__ = "Cloth"
16
17         def draw(self, context):
18                 layout = self.layout
19                 
20                 md = context.cloth
21                 ob = context.object
22
23                 split = layout.split()
24                 split.operator_context = 'EXEC_DEFAULT'
25
26                 if md:
27                         # remove modifier + settings
28                         split.set_context_pointer("modifier", md)
29                         split.itemO("object.modifier_remove", text="Remove")
30
31                         row = split.row(align=True)
32                         row.itemR(md, "render", text="")
33                         row.itemR(md, "realtime", text="")
34                 else:
35                         # add modifier
36                         split.item_enumO("object.modifier_add", "type", 'CLOTH', text="Add")
37                         split.itemL()
38
39                 if md:
40                         cloth = md.settings
41
42                         split = layout.split()
43                         
44                         col = split.column()
45                         col.itemL(text="Quality:")
46                         col.itemR(cloth, "quality", text="Steps",slider=True)
47                         col.itemL(text="Gravity:")
48                         col.itemR(cloth, "gravity", text="")
49
50                         col.itemR(cloth, "pin_cloth", text="Pin")
51                         sub = col.column(align=True)
52                         sub.active = cloth.pin_cloth
53                         sub.itemR(cloth, "pin_stiffness", text="Stiffness")
54                         sub.item_pointerR(cloth, "mass_vertex_group", ob, "vertex_groups", text="")
55                         
56                         col = split.column()
57                         col.itemL(text="Presets...")
58                         col.itemL(text="TODO!")
59                         col.itemL(text="Material:")
60                         sub = col.column(align=True)
61                         sub.itemR(cloth, "mass")
62                         sub.itemR(cloth, "structural_stiffness", text="Structural")
63                         sub.itemR(cloth, "bending_stiffness", text="Bending")
64                         col.itemL(text="Damping:")
65                         sub = col.column(align=True)
66                         sub.itemR(cloth, "spring_damping", text="Spring")
67                         sub.itemR(cloth, "air_damping", text="Air")
68                         
69                         # Disabled for now
70                         """
71                         if cloth.mass_vertex_group:
72                                 layout.itemL(text="Goal:")
73                         
74                                 col = layout.column_flow()
75                                 col.itemR(cloth, "goal_default", text="Default")
76                                 col.itemR(cloth, "goal_spring", text="Stiffness")
77                                 col.itemR(cloth, "goal_friction", text="Friction")
78                         """
79
80 class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
81         __label__ = "Cloth Cache"
82         __default_closed__ = True
83
84         def poll(self, context):
85                 return (context.cloth != None)
86
87         def draw(self, context):
88                 layout = self.layout
89
90                 cache = context.cloth.point_cache
91                 layout.set_context_pointer("PointCache", cache)
92                 
93                 row = layout.row()
94                 row.template_list(cache, "point_cache_list", cache, "active_point_cache_index")
95                 col = row.column(align=True)
96                 col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="")
97                 col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="")
98                 
99                 row = layout.row()
100                 row.itemR(cache, "name")
101                 
102                 row = layout.row()
103                 row.itemR(cache, "start_frame")
104                 row.itemR(cache, "end_frame")
105                 
106                 row = layout.row()
107                 
108                 if cache.baked == True:
109                         row.itemO("ptcache.free_bake", text="Free Bake")
110                 else:
111                         row.item_booleanO("ptcache.bake", "bake", True, text="Bake")
112                 
113                 subrow = row.row()
114                 subrow.enabled = cache.frames_skipped or cache.outdated
115                 subrow.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame")
116                         
117                 row = layout.row()
118                 #row.enabled = particle_panel_enabled(psys)
119                 row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake")
120                 row.itemR(cache, "step");
121         
122                 row = layout.row()
123                 #row.enabled = particle_panel_enabled(psys)
124                 row.itemR(cache, "quick_cache")
125                 row.itemR(cache, "disk_cache")
126                 
127                 layout.itemL(text=cache.info)
128                 
129                 layout.itemS()
130                 
131                 row = layout.row()
132                 row.itemO("ptcache.bake_all", "bake", True, text="Bake All Dynamics")
133                 row.itemO("ptcache.free_bake_all", text="Free All Bakes")
134                 layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame")
135                 
136 class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
137         __label__ = "Cloth Collision"
138         __default_closed__ = True
139
140         def poll(self, context):
141                 return (context.cloth != None)
142         
143         def draw_header(self, context):
144                 layout = self.layout
145                 cloth = context.cloth.collision_settings
146         
147                 layout.itemR(cloth, "enable_collision", text="")
148
149         def draw(self, context):
150                 layout = self.layout
151                 cloth = context.cloth.collision_settings
152                 split = layout.split()
153                 
154                 layout.active = cloth.enable_collision
155                 
156                 col = split.column()
157                 col.itemR(cloth, "collision_quality", slider=True, text="Quality")
158                 col.itemR(cloth, "min_distance", slider=True, text="Distance")
159                 col.itemR(cloth, "friction")
160                 
161                 col = split.column()
162                 col.itemR(cloth, "enable_self_collision", text="Self Collision")
163                 col = col.column()
164                 col.active = cloth.enable_self_collision
165                 col.itemR(cloth, "self_collision_quality", slider=True, text="Quality")
166                 col.itemR(cloth, "self_min_distance", slider=True, text="Distance")
167
168 class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel):
169         __label__ = "Cloth Stiffness Scaling"
170         __default_closed__ = True
171
172         def poll(self, context):
173                 return (context.cloth != None)
174         
175         def draw_header(self, context):
176                 layout = self.layout
177                 cloth = context.cloth.settings
178         
179                 layout.itemR(cloth, "stiffness_scaling", text="")
180
181         def draw(self, context):
182                 layout = self.layout
183                 ob = context.object
184                 cloth = context.cloth.settings
185                 
186                 layout.active = cloth.stiffness_scaling 
187                 
188                 split = layout.split()
189                 
190                 col = split.column()
191                 col.itemL(text="Structural Stiffness:")
192                 sub = col.column(align=True)
193                 sub.itemR(cloth, "structural_stiffness_max", text="Max")
194                 sub.item_pointerR(cloth, "structural_stiffness_vertex_group", ob, "vertex_groups", text="")
195                 
196                 col = split.column()
197                 col.itemL(text="Bending Stiffness:")
198                 sub = col.column(align=True)
199                 sub.itemR(cloth, "bending_stiffness_max", text="Max")
200                 sub.item_pointerR(cloth, "bending_vertex_group", ob, "vertex_groups", text="")
201                 
202 bpy.types.register(PHYSICS_PT_cloth)
203 bpy.types.register(PHYSICS_PT_cloth_cache)
204 bpy.types.register(PHYSICS_PT_cloth_collision)
205 bpy.types.register(PHYSICS_PT_cloth_stiffness)