remove use of gettext: _("...") style translation now its handled by rna.
[blender.git] / release / scripts / startup / bl_ui / properties_physics_softbody.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
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.
7 #
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.
12 #
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.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Panel
22
23 from bl_ui.properties_physics_common import (
24     point_cache_ui,
25     effector_weights_ui,
26     )
27
28
29 def softbody_panel_enabled(md):
30     return (md.point_cache.is_baked is False)
31
32
33 class PhysicButtonsPanel():
34     bl_space_type = 'PROPERTIES'
35     bl_region_type = 'WINDOW'
36     bl_context = "physics"
37
38     @classmethod
39     def poll(cls, context):
40         ob = context.object
41         rd = context.scene.render
42 #        return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
43 # i really hate touching things i do not understand completely .. but i think this should read (bjornmose)
44         return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine) and (context.soft_body)
45
46
47 class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
48     bl_label = "Soft Body"
49
50     def draw(self, context):
51         layout = self.layout
52
53         md = context.soft_body
54         ob = context.object
55
56         if md:
57             softbody = md.settings
58
59             # General
60             split = layout.split()
61             split.enabled = softbody_panel_enabled(md)
62
63             col = split.column()
64             col.label(text="Object:")
65             col.prop(softbody, "friction")
66             col.prop(softbody, "mass")
67             col.prop_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Mass:")
68
69             col = split.column()
70             col.label(text="Simulation:")
71             col.prop(softbody, "speed")
72
73
74 class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
75     bl_label = "Soft Body Cache"
76     bl_options = {'DEFAULT_CLOSED'}
77
78     @classmethod
79     def poll(cls, context):
80         return context.soft_body
81
82     def draw(self, context):
83         md = context.soft_body
84         point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
85
86
87 class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
88     bl_label = "Soft Body Goal"
89     bl_options = {'DEFAULT_CLOSED'}
90
91     @classmethod
92     def poll(cls, context):
93         return context.soft_body
94
95     def draw_header(self, context):
96         softbody = context.soft_body.settings
97
98         self.layout.active = softbody_panel_enabled(context.soft_body)
99         self.layout.prop(softbody, "use_goal", text="")
100
101     def draw(self, context):
102         layout = self.layout
103
104         md = context.soft_body
105         softbody = md.settings
106         ob = context.object
107
108         layout.active = softbody.use_goal and softbody_panel_enabled(md)
109
110         split = layout.split()
111
112         # Goal
113         split = layout.split()
114
115         col = split.column()
116         col.label(text="Goal Strengths:")
117         col.prop(softbody, "goal_default", text="Default")
118         sub = col.column(align=True)
119         sub.prop(softbody, "goal_min", text="Minimum")
120         sub.prop(softbody, "goal_max", text="Maximum")
121
122         col = split.column()
123         col.label(text="Goal Settings:")
124         col.prop(softbody, "goal_spring", text="Stiffness")
125         col.prop(softbody, "goal_friction", text="Damping")
126
127         layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group")
128
129
130 class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
131     bl_label = "Soft Body Edges"
132     bl_options = {'DEFAULT_CLOSED'}
133
134     @classmethod
135     def poll(cls, context):
136         return context.soft_body
137
138     def draw_header(self, context):
139         softbody = context.soft_body.settings
140
141         self.layout.active = softbody_panel_enabled(context.soft_body)
142         self.layout.prop(softbody, "use_edges", text="")
143
144     def draw(self, context):
145         layout = self.layout
146
147         md = context.soft_body
148         softbody = md.settings
149         ob = context.object
150
151         layout.active = softbody.use_edges and softbody_panel_enabled(md)
152
153         split = layout.split()
154
155         col = split.column()
156         col.label(text="Springs:")
157         col.prop(softbody, "pull")
158         col.prop(softbody, "push")
159         col.prop(softbody, "damping")
160         col.prop(softbody, "plastic")
161         col.prop(softbody, "bend")
162         col.prop(softbody, "spring_length", text="Length")
163         col.prop_search(softbody, "vertex_group_spring", ob, "vertex_groups", text="Springs:")
164
165         col = split.column()
166         col.prop(softbody, "use_stiff_quads")
167         sub = col.column()
168         sub.active = softbody.use_stiff_quads
169         sub.prop(softbody, "shear")
170
171         col.label(text="Aerodynamics:")
172         col.row().prop(softbody, "aerodynamics_type", expand=True)
173         col.prop(softbody, "aero", text="Factor")
174
175         #sub = col.column()
176         #sub.enabled = softbody.aero > 0
177
178         col.label(text="Collision:")
179         col.prop(softbody, "use_edge_collision", text="Edge")
180         col.prop(softbody, "use_face_collision", text="Face")
181
182
183 class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
184     bl_label = "Soft Body Self Collision"
185     bl_options = {'DEFAULT_CLOSED'}
186
187     @classmethod
188     def poll(cls, context):
189         return context.soft_body
190
191     def draw_header(self, context):
192         softbody = context.soft_body.settings
193
194         self.layout.active = softbody_panel_enabled(context.soft_body)
195         self.layout.prop(softbody, "use_self_collision", text="")
196
197     def draw(self, context):
198         layout = self.layout
199
200         md = context.soft_body
201         softbody = md.settings
202
203         layout.active = softbody.use_self_collision and softbody_panel_enabled(md)
204
205         layout.label(text="Collision Ball Size Calculation:")
206         layout.prop(softbody, "collision_type", expand=True)
207
208         col = layout.column(align=True)
209         col.label(text="Ball:")
210         col.prop(softbody, "ball_size", text="Size")
211         col.prop(softbody, "ball_stiff", text="Stiffness")
212         col.prop(softbody, "ball_damp", text="Dampening")
213
214
215 class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
216     bl_label = "Soft Body Solver"
217     bl_options = {'DEFAULT_CLOSED'}
218
219     @classmethod
220     def poll(cls, context):
221         return context.soft_body
222
223     def draw(self, context):
224         layout = self.layout
225
226         md = context.soft_body
227         softbody = md.settings
228
229         layout.active = softbody_panel_enabled(md)
230
231         # Solver
232         split = layout.split()
233
234         col = split.column(align=True)
235         col.label(text="Step Size:")
236         col.prop(softbody, "step_min")
237         col.prop(softbody, "step_max")
238         col.prop(softbody, "use_auto_step", text="Auto-Step")
239
240         col = split.column()
241         col.prop(softbody, "error_threshold")
242         col.label(text="Helpers:")
243         col.prop(softbody, "choke")
244         col.prop(softbody, "fuzzy")
245
246         layout.label(text="Diagnostics:")
247         layout.prop(softbody, "use_diagnose")
248         layout.prop(softbody, "use_estimate_matrix")
249
250
251 class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
252     bl_label = "Soft Body Field Weights"
253     bl_options = {'DEFAULT_CLOSED'}
254
255     @classmethod
256     def poll(cls, context):
257         return (context.soft_body)
258
259     def draw(self, context):
260         md = context.soft_body
261         softbody = md.settings
262
263         effector_weights_ui(self, context, softbody.effector_weights)
264
265 if __name__ == "__main__":  # only for live edit.
266     bpy.utils.register_module(__name__)