Integrated Freestyle to rendering pipeline
[blender.git] / release / ui / buttons_physics_softbody.py
1
2 import bpy
3
4 from buttons_particle import point_cache_ui
5
6 def softbody_panel_enabled(md):
7         return md.point_cache.baked==False
8
9 class PhysicButtonsPanel(bpy.types.Panel):
10         __space_type__ = 'PROPERTIES'
11         __region_type__ = 'WINDOW'
12         __context__ = "physics"
13
14         def poll(self, context):
15                 ob = context.object
16                 rd = context.scene.render_data
17                 return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
18                 
19 class PHYSICS_PT_softbody(PhysicButtonsPanel):
20         __label__ = "Soft Body"
21
22         def draw(self, context):
23                 layout = self.layout
24                 
25                 md = context.soft_body
26                 ob = context.object
27
28                 split = layout.split()
29                 split.operator_context = "EXEC_DEFAULT"
30
31                 if md:
32                         # remove modifier + settings
33                         split.set_context_pointer("modifier", md)
34                         split.itemO("object.modifier_remove", text="Remove")
35
36                         row = split.row(align=True)
37                         row.itemR(md, "render", text="")
38                         row.itemR(md, "realtime", text="")
39                 else:
40                         # add modifier
41                         split.item_enumO("object.modifier_add", "type", 'SOFT_BODY', text="Add")
42                         split.itemL("")
43                         
44                 if md:
45                         softbody = md.settings
46
47                         # General
48                         split = layout.split()
49                         split.enabled = softbody_panel_enabled(md)
50                         
51                         col = split.column()
52                         col.itemL(text="Object:")
53                         col.itemR(softbody, "mass")
54                         col.itemR(softbody, "friction")
55
56                         col = split.column()
57                         col.itemL(text="Simulation:")
58                         col.itemR(softbody, "gravity")
59                         col.itemR(softbody, "speed")
60                         
61 class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
62         __label__ = "Soft Body Cache"
63         __default_closed__ = True
64
65         def poll(self, context):
66                 return (context.soft_body)
67
68         def draw(self, context):
69                 md = context.soft_body
70                 point_cache_ui(self, md.point_cache, softbody_panel_enabled(md), 0, 0)
71                         
72 class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
73         __label__ = "Soft Body Goal"
74         __default_closed__ = True
75         
76         def poll(self, context):
77                 return (context.soft_body)
78                 
79         def draw_header(self, context):
80                 softbody = context.soft_body.settings
81         
82                 self.layout.active = softbody_panel_enabled(context.soft_body)
83                 self.layout.itemR(softbody, "use_goal", text="")
84                 
85         def draw(self, context):
86                 layout = self.layout
87                 
88                 md = context.soft_body
89                 softbody = md.settings
90                 ob = context.object
91                 
92                 layout.active = softbody.use_goal and softbody_panel_enabled(md)
93
94                 split = layout.split()
95
96                 # Goal 
97                 split = layout.split()
98
99                 col = split.column()
100                 col.itemL(text="Goal Strengths:")
101                 col.itemR(softbody, "goal_default", text="Default")
102                 sub = col.column(align=True)
103                 sub.itemR(softbody, "goal_min", text="Minimum")
104                 sub.itemR(softbody, "goal_max", text="Maximum")
105                         
106                 col = split.column()
107                 col.itemL(text="Goal Settings:")
108                 col.itemR(softbody, "goal_spring", text="Stiffness")
109                 col.itemR(softbody, "goal_friction", text="Damping")
110                         
111                 layout.item_pointerR(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
112
113 class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
114         __label__ = "Soft Body Edges"
115         __default_closed__ = True
116         
117         def poll(self, context):
118                 return (context.soft_body)
119                 
120         def draw_header(self, context):
121                 softbody = context.soft_body.settings
122         
123                 self.layout.active = softbody_panel_enabled(context.soft_body)
124                 self.layout.itemR(softbody, "use_edges", text="")
125                 
126         def draw(self, context):
127                 layout = self.layout
128                 
129                 md = context.soft_body
130                 softbody = md.settings
131                 ob = context.object
132
133                 layout.active = softbody.use_edges and softbody_panel_enabled(md)
134                         
135                 split = layout.split()
136                         
137                 col = split.column()
138                 col.itemL(text="Springs:")
139                 col.itemR(softbody, "pull")
140                 col.itemR(softbody, "push")
141                 col.itemR(softbody, "damp")
142                 col.itemR(softbody, "plastic")
143                 col.itemR(softbody, "bending")
144                 col.itemR(softbody, "spring_length", text="Length")
145                         
146                 col = split.column()
147                 col.itemR(softbody, "stiff_quads")
148                 sub = col.column()
149                 sub.active = softbody.stiff_quads
150                 sub.itemR(softbody, "shear")
151                         
152                 col.itemR(softbody, "new_aero", text="Aero")
153                 sub = col.column()
154                 sub.enabled = softbody.new_aero
155                 sub.itemR(softbody, "aero", text="Factor")
156
157                 col.itemL(text="Collision:")
158                 col.itemR(softbody, "edge_collision", text="Edge")
159                 col.itemR(softbody, "face_collision", text="Face")
160                         
161 class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
162         __label__ = "Soft Body Collision"
163         __default_closed__ = True
164         
165         def poll(self, context):
166                 return (context.soft_body)
167                 
168         def draw_header(self, context):
169                 softbody = context.soft_body.settings
170         
171                 self.layout.active = softbody_panel_enabled(context.soft_body)
172                 self.layout.itemR(softbody, "self_collision", text="")
173                 
174         def draw(self, context):
175                 layout = self.layout
176                 
177                 md = context.soft_body
178                 softbody = md.settings
179                 ob = context.object
180
181                 layout.active = softbody.self_collision and softbody_panel_enabled(md)
182                         
183                 layout.itemL(text="Collision Type:")
184                 layout.itemR(softbody, "collision_type", expand=True)
185                         
186                 col = layout.column(align=True)
187                 col.itemL(text="Ball:")
188                 col.itemR(softbody, "ball_size", text="Size")
189                 col.itemR(softbody, "ball_stiff", text="Stiffness")
190                 col.itemR(softbody, "ball_damp", text="Dampening")
191
192 class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
193         __label__ = "Soft Body Solver"
194         __default_closed__ = True
195         
196         def poll(self, context):
197                 return (context.soft_body)
198                 
199         def draw(self, context):
200                 layout = self.layout
201                 
202                 md = context.soft_body
203                 softbody = md.settings
204                 ob = context.object
205
206                 layout.active = softbody_panel_enabled(md)
207
208                 # Solver
209                 split = layout.split()
210                         
211                 col = split.column(align=True)
212                 col.itemL(text="Step Size:")
213                 col.itemR(softbody, "minstep")
214                 col.itemR(softbody, "maxstep")
215                 col.itemR(softbody, "auto_step", text="Auto-Step")
216                         
217                 col = split.column()
218                 col.itemR(softbody, "error_limit")
219                 col.itemL(text="Helpers:")
220                 col.itemR(softbody, "choke")
221                 col.itemR(softbody, "fuzzy")
222                         
223                 layout.itemL(text="Diagnostics:")
224                 layout.itemR(softbody, "diagnose")
225         
226 bpy.types.register(PHYSICS_PT_softbody)
227 bpy.types.register(PHYSICS_PT_softbody_cache)
228 bpy.types.register(PHYSICS_PT_softbody_goal)
229 bpy.types.register(PHYSICS_PT_softbody_edge)
230 bpy.types.register(PHYSICS_PT_softbody_collision)
231 bpy.types.register(PHYSICS_PT_softbody_solver)