Followup to r59434 : py UI scripts edits.
[blender.git] / release / scripts / startup / bl_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 from bpy.types import Panel
22
23 from bl_ui.properties_physics_common import (point_cache_ui,
24                                              effector_weights_ui)
25
26
27 class PhysicButtonsPanel():
28     bl_space_type = 'PROPERTIES'
29     bl_region_type = 'WINDOW'
30     bl_context = "physics"
31
32     @classmethod
33     def poll(cls, context):
34         ob = context.object
35         rd = context.scene.render
36         return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.smoke)
37
38
39 class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
40     bl_label = "Smoke"
41
42     def draw(self, context):
43         layout = self.layout
44
45         md = context.smoke
46         ob = context.object
47
48         layout.prop(md, "smoke_type", expand=True)
49
50         if md.smoke_type == 'DOMAIN':
51             domain = md.domain_settings
52
53             split = layout.split()
54
55             split.enabled = not domain.point_cache.is_baked
56
57             col = split.column()
58             col.label(text="Resolution:")
59             col.prop(domain, "resolution_max", text="Divisions")
60             col.label(text="Time:")
61             col.prop(domain, "time_scale", text="Scale")
62             col.label(text="Border Collisions:")
63             col.prop(domain, "collision_extents", text="")
64
65             col = split.column()
66             col.label(text="Behavior:")
67             col.prop(domain, "alpha")
68             col.prop(domain, "beta", text="Temp. Diff.")
69             col.prop(domain, "vorticity")
70             col.prop(domain, "use_dissolve_smoke", text="Dissolve")
71             sub = col.column()
72             sub.active = domain.use_dissolve_smoke
73             sub.prop(domain, "dissolve_speed", text="Time")
74             sub.prop(domain, "use_dissolve_smoke_log", text="Slow")
75
76         elif md.smoke_type == 'FLOW':
77
78             flow = md.flow_settings
79
80             layout.prop(flow, "smoke_flow_type", expand=False)
81
82             if flow.smoke_flow_type != "OUTFLOW":
83                 split = layout.split()
84                 col = split.column()
85                 col.label(text="Flow Source:")
86                 col.prop(flow, "smoke_flow_source", expand=False, text="")
87                 if flow.smoke_flow_source == "PARTICLES":
88                     col.label(text="Particle System:")
89                     col.prop_search(flow, "particle_system", ob, "particle_systems", text="")
90                     col.prop(flow, "use_particle_size", text="Set Size")
91                     sub = col.column()
92                     sub.active = flow.use_particle_size
93                     sub.prop(flow, "particle_size")
94                 else:
95                     col.prop(flow, "surface_distance")
96                     col.prop(flow, "volume_density")
97
98                 sub = col.column(align=True)
99                 sub.prop(flow, "use_initial_velocity")
100
101                 sub = sub.column()
102                 sub.active = flow.use_initial_velocity
103                 sub.prop(flow, "velocity_factor")
104                 if flow.smoke_flow_source == "MESH":
105                     sub.prop(flow, "velocity_normal")
106                     #sub.prop(flow, "velocity_random")
107
108                 sub = split.column()
109                 sub.label(text="Initial Values:")
110                 sub.prop(flow, "use_absolute")
111                 if flow.smoke_flow_type in {'SMOKE', 'BOTH'}:
112                     sub.prop(flow, "density")
113                     sub.prop(flow, "temperature")
114                     sub.prop(flow, "smoke_color")
115                 if flow.smoke_flow_type in {'FIRE', 'BOTH'}:
116                     sub.prop(flow, "fuel_amount")
117                 sub.label(text="Sampling:")
118                 sub.prop(flow, "subframes")
119
120         elif md.smoke_type == 'COLLISION':
121             coll = md.coll_settings
122
123             split = layout.split()
124
125             col = split.column()
126             col.prop(coll, "collision_type")
127
128
129 class PHYSICS_PT_smoke_flow_advanced(PhysicButtonsPanel, Panel):
130     bl_label = "Smoke Flow Advanced"
131     bl_options = {'DEFAULT_CLOSED'}
132
133     @classmethod
134     def poll(cls, context):
135         md = context.smoke
136         return md and (md.smoke_type == 'FLOW') and (md.flow_settings.smoke_flow_source == "MESH")
137
138     def draw(self, context):
139         layout = self.layout
140         ob = context.object
141         flow = context.smoke.flow_settings
142
143         split = layout.split()
144         col = split.column()
145
146         col.prop(flow, "use_texture")
147         sub = col.column()
148         sub.active = flow.use_texture
149         sub.prop(flow, "noise_texture", text="")
150         sub.label(text="Mapping:")
151         sub.prop(flow, "texture_map_type", expand=False, text="")
152         if flow.texture_map_type == "UV":
153             sub.prop_search(flow, "uv_layer", ob.data, "uv_textures", text="")
154         if flow.texture_map_type == "AUTO":
155             sub.prop(flow, "texture_size")
156         sub.prop(flow, "texture_offset")
157
158         col = split.column()
159         col.label(text="Vertex Group:")
160         col.prop_search(flow, "density_vertex_group", ob, "vertex_groups", text="")
161
162
163 class PHYSICS_PT_smoke_fire(PhysicButtonsPanel, Panel):
164     bl_label = "Smoke Flames"
165     bl_options = {'DEFAULT_CLOSED'}
166
167     @classmethod
168     def poll(cls, context):
169         md = context.smoke
170         return md and (md.smoke_type == 'DOMAIN')
171
172     def draw(self, context):
173         layout = self.layout
174         domain = context.smoke.domain_settings
175
176         split = layout.split()
177         split.enabled = not domain.point_cache.is_baked
178
179         col = split.column(align=True)
180         col.label(text="Reaction:")
181         col.prop(domain, "burning_rate")
182         col.prop(domain, "flame_smoke")
183         col.prop(domain, "flame_vorticity")
184
185         col = split.column(align=True)
186         col.label(text="Temperatures:")
187         col.prop(domain, "flame_ignition")
188         col.prop(domain, "flame_max_temp")
189         col.prop(domain, "flame_smoke_color")
190
191
192 class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel):
193     bl_label = "Smoke Adaptive Domain"
194     bl_options = {'DEFAULT_CLOSED'}
195
196     @classmethod
197     def poll(cls, context):
198         md = context.smoke
199         return md and (md.smoke_type == 'DOMAIN')
200
201     def draw_header(self, context):
202         md = context.smoke.domain_settings
203
204         self.layout.prop(md, "use_adaptive_domain", text="")
205
206     def draw(self, context):
207         layout = self.layout
208
209         domain = context.smoke.domain_settings
210         layout.active = domain.use_adaptive_domain
211
212         split = layout.split()
213         split.enabled = (not domain.point_cache.is_baked)
214
215         col = split.column(align=True)
216         col.label(text="Resolution:")
217         col.prop(domain, "additional_res")
218         col.prop(domain, "adapt_margin")
219
220         col = split.column(align=True)
221         col.label(text="Advanced:")
222         col.prop(domain, "adapt_threshold")
223
224
225 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
226     bl_label = "Smoke High Resolution"
227     bl_options = {'DEFAULT_CLOSED'}
228
229     @classmethod
230     def poll(cls, context):
231         md = context.smoke
232         rd = context.scene.render
233         return md and (md.smoke_type == 'DOMAIN') and (not rd.use_game_engine)
234
235     def draw_header(self, context):
236         md = context.smoke.domain_settings
237
238         self.layout.prop(md, "use_high_resolution", text="")
239
240     def draw(self, context):
241         layout = self.layout
242
243         md = context.smoke.domain_settings
244
245         layout.active = md.use_high_resolution
246
247         split = layout.split()
248         split.enabled = not md.point_cache.is_baked
249
250         col = split.column()
251         col.label(text="Resolution:")
252         col.prop(md, "amplify", text="Divisions")
253         col.label(text="Flow Sampling:")
254         col.row().prop(md, "highres_sampling", text="")
255
256         col = split.column()
257         col.label(text="Noise Method:")
258         col.row().prop(md, "noise_type", text="")
259         col.prop(md, "strength")
260
261         layout.prop(md, "show_high_resolution")
262
263
264 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
265     bl_label = "Smoke Groups"
266     bl_options = {'DEFAULT_CLOSED'}
267
268     @classmethod
269     def poll(cls, context):
270         md = context.smoke
271         rd = context.scene.render
272         return md and (md.smoke_type == 'DOMAIN') and (not rd.use_game_engine)
273
274     def draw(self, context):
275         layout = self.layout
276         domain = context.smoke.domain_settings
277
278         split = layout.split()
279
280         col = split.column()
281         col.label(text="Flow Group:")
282         col.prop(domain, "fluid_group", text="")
283
284         #col.label(text="Effector Group:")
285         #col.prop(domain, "effector_group", text="")
286
287         col = split.column()
288         col.label(text="Collision Group:")
289         col.prop(domain, "collision_group", text="")
290
291
292 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
293     bl_label = "Smoke Cache"
294     bl_options = {'DEFAULT_CLOSED'}
295
296     @classmethod
297     def poll(cls, context):
298         md = context.smoke
299         rd = context.scene.render
300         return md and (md.smoke_type == 'DOMAIN') and (not rd.use_game_engine)
301
302     def draw(self, context):
303         layout = self.layout
304
305         md = context.smoke.domain_settings
306         cache = md.point_cache
307
308         layout.label(text="Compression:")
309         layout.prop(md, "point_cache_compress_type", expand=True)
310
311         point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
312
313
314 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
315     bl_label = "Smoke Field Weights"
316     bl_options = {'DEFAULT_CLOSED'}
317
318     @classmethod
319     def poll(cls, context):
320         md = context.smoke
321         rd = context.scene.render
322         return md and (md.smoke_type == 'DOMAIN') and (not rd.use_game_engine)
323
324     def draw(self, context):
325         domain = context.smoke.domain_settings
326         effector_weights_ui(self, context, domain.effector_weights, 'SMOKE')
327
328 if __name__ == "__main__":  # only for live edit.
329     bpy.utils.register_module(__name__)