Smoke UI:
[blender.git] / release / scripts / ui / properties_physics_smoke.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
22 narrowui = bpy.context.user_preferences.view.properties_width_check
23
24
25 from properties_physics_common import point_cache_ui
26 from properties_physics_common import effector_weights_ui
27
28
29 class PhysicButtonsPanel(bpy.types.Panel):
30     bl_space_type = 'PROPERTIES'
31     bl_region_type = 'WINDOW'
32     bl_context = "physics"
33
34     def poll(self, context):
35         ob = context.object
36         rd = context.scene.render
37         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
38
39
40 class PHYSICS_PT_smoke(PhysicButtonsPanel):
41     bl_label = "Smoke"
42
43     def draw(self, context):
44         layout = self.layout
45
46         md = context.smoke
47         ob = context.object
48         wide_ui = context.region.width > narrowui
49
50         split = layout.split()
51
52         if md:
53             # remove modifier + settings
54             split.set_context_pointer("modifier", md)
55             split.operator("object.modifier_remove", text="Remove")
56
57             row = split.row(align=True)
58             row.prop(md, "render", text="")
59             row.prop(md, "realtime", text="")
60
61         else:
62             # add modifier
63             split.operator("object.modifier_add", text="Add").type = 'SMOKE'
64             if wide_ui:
65                 split.label()
66
67         if md:
68             if wide_ui:
69                 layout.prop(md, "smoke_type", expand=True)
70             else:
71                 layout.prop(md, "smoke_type", text="")
72
73             if md.smoke_type == 'DOMAIN':
74                 domain = md.domain_settings
75
76                 split = layout.split()
77
78                 col = split.column()
79                 col.label(text="Resolution:")
80                 col.prop(domain, "maxres", text="Divisions")
81                 col.label(text="Particle:")
82                 col.prop(domain, "initial_velocity", text="Initial Velocity")
83
84                 if wide_ui:
85                     col = split.column()
86                 col.label(text="Behavior:")
87                 col.prop(domain, "alpha")
88                 col.prop(domain, "beta")
89                 col.prop(domain, "dissolve_smoke", text="Dissolve")
90                 sub = col.column()
91                 sub.active = domain.dissolve_smoke
92                 sub.prop(domain, "dissolve_speed", text="Time")
93                 sub.prop(domain, "dissolve_smoke_log", text="Slow")
94
95             elif md.smoke_type == 'FLOW':
96                 flow = md.flow_settings
97
98                 split = layout.split()
99
100                 col = split.column()
101                 col.prop(flow, "outflow")
102                 col.label(text="Particle System:")
103                 col.prop_object(flow, "psys", ob, "particle_systems", text="")
104
105                 if md.flow_settings.outflow:
106                     if wide_ui:
107                         col = split.column()
108                 else:
109                     if wide_ui:
110                         col = split.column()
111                     col.label(text="Behavior:")
112                     col.prop(flow, "temperature")
113                     col.prop(flow, "density")
114
115             #elif md.smoke_type == 'COLLISION':
116             #   layout.separator()
117
118
119 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
120     bl_label = "Smoke Groups"
121     bl_default_closed = True
122
123     def poll(self, context):
124         md = context.smoke
125         return md and (md.smoke_type == 'DOMAIN')
126
127     def draw(self, context):
128         layout = self.layout
129
130         group = context.smoke.domain_settings
131         wide_ui = context.region.width > narrowui
132
133         split = layout.split()
134
135         col = split.column()
136         col.label(text="Flow Group:")
137         col.prop(group, "fluid_group", text="")
138
139         #col.label(text="Effector Group:")
140         #col.prop(group, "eff_group", text="")
141
142         if wide_ui:
143             col = split.column()
144         col.label(text="Collision Group:")
145         col.prop(group, "coll_group", text="")
146
147
148 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
149     bl_label = "Smoke Cache"
150     bl_default_closed = True
151
152     def poll(self, context):
153         md = context.smoke
154         return md and (md.smoke_type == 'DOMAIN')
155
156     def draw(self, context):
157         layout = self.layout
158
159         md = context.smoke.domain_settings
160         cache = md.point_cache_low
161
162         layout.label(text="Compression:")
163         layout.prop(md, "smoke_cache_comp", expand=True)
164
165         point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE')
166
167
168 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
169     bl_label = "Smoke High Resolution"
170     bl_default_closed = True
171
172     def poll(self, context):
173         md = context.smoke
174         return md and (md.smoke_type == 'DOMAIN')
175
176     def draw_header(self, context):
177         md = context.smoke.domain_settings
178
179         self.layout.prop(md, "highres", text="")
180
181     def draw(self, context):
182         layout = self.layout
183
184         md = context.smoke.domain_settings
185         wide_ui = context.region.width > narrowui
186         
187         layout.active = md.highres
188
189         split = layout.split()
190
191         col = split.column()
192         col.label(text="Resolution:")
193         col.prop(md, "amplify", text="Divisions")
194         col.prop(md, "viewhighres")
195
196         if wide_ui:
197             col = split.column()
198         col.label(text="Noise Method:")
199         col.row().prop(md, "noise_type", text="")
200         col.prop(md, "strength")
201
202
203 class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
204     bl_label = "Smoke High Resolution Cache"
205     bl_default_closed = True
206
207     def poll(self, context):
208         md = context.smoke
209         return md and (md.smoke_type == 'DOMAIN') and md.domain_settings.highres
210
211     def draw(self, context):
212         layout = self.layout
213
214         md = context.smoke.domain_settings
215         cache = md.point_cache_high
216
217         layout.label(text="Compression:")
218         layout.prop(md, "smoke_cache_high_comp", expand=True)
219
220         point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE')
221
222
223 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel):
224     bl_label = "Smoke Field Weights"
225     bl_default_closed = True
226
227     def poll(self, context):
228         smoke = context.smoke
229         return (smoke and smoke.smoke_type == 'DOMAIN')
230
231     def draw(self, context):
232         domain = context.smoke.domain_settings
233         effector_weights_ui(self, context, domain.effector_weights)
234
235
236 classes = [
237     PHYSICS_PT_smoke,
238     PHYSICS_PT_smoke_field_weights,
239     PHYSICS_PT_smoke_cache,
240     PHYSICS_PT_smoke_highres,
241     PHYSICS_PT_smoke_groups,
242     PHYSICS_PT_smoke_cache_highres]
243
244
245 def register():
246     register = bpy.types.register
247     for cls in classes:
248         register(cls)
249
250
251 def unregister():
252     unregister = bpy.types.unregister
253     for cls in classes:
254         unregister(cls)
255
256 if __name__ == "__main__":
257     register()