61c477b6d4927e46dbde58f89c9ed4b8b5b8cd99
[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 from blf import gettext as _
23
24 from bl_ui.properties_physics_common import (
25     point_cache_ui,
26     effector_weights_ui,
27     )
28
29
30 class PhysicButtonsPanel():
31     bl_space_type = 'PROPERTIES'
32     bl_region_type = 'WINDOW'
33     bl_context = "physics"
34
35     @classmethod
36     def poll(cls, context):
37         ob = context.object
38         rd = context.scene.render
39         return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.smoke)
40
41
42 class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
43     bl_label = "Smoke"
44
45     def draw(self, context):
46         layout = self.layout
47
48         md = context.smoke
49         ob = context.object
50
51         if md:
52             layout.prop(md, "smoke_type", expand=True)
53
54             if md.smoke_type == 'DOMAIN':
55                 domain = md.domain_settings
56
57                 split = layout.split()
58
59                 split.enabled = not domain.point_cache.is_baked
60
61                 col = split.column()
62                 col.label(text=_("Resolution:"))
63                 col.prop(domain, "resolution_max", text=_("Divisions"))
64                 col.label(text=_("Time:"))
65                 col.prop(domain, "time_scale", text=_("Scale"))
66                 col.label(text=_("Border Collisions:"))
67                 col.prop(domain, "collision_extents", text="")
68
69                 col = split.column()
70                 col.label(text=_("Behavior:"))
71                 col.prop(domain, "alpha")
72                 col.prop(domain, "beta", text=_("Temp. Diff."))
73                 col.prop(domain, "vorticity")
74                 col.prop(domain, "use_dissolve_smoke", text=_("Dissolve"))
75                 sub = col.column()
76                 sub.active = domain.use_dissolve_smoke
77                 sub.prop(domain, "dissolve_speed", text=_("Time"))
78                 sub.prop(domain, "use_dissolve_smoke_log", text_("Slow"))
79
80             elif md.smoke_type == 'FLOW':
81
82                 flow = md.flow_settings
83
84                 split = layout.split()
85
86                 col = split.column()
87                 col.prop(flow, "use_outflow")
88                 col.label(text=_("Particle System:"))
89                 col.prop_search(flow, "particle_system", ob, "particle_systems", text="")
90
91                 sub = col.column()
92                 sub.active = not md.flow_settings.use_outflow
93
94                 sub.prop(flow, "initial_velocity", text=_("Initial Velocity"))
95                 sub = sub.column()
96                 sub.active = flow.initial_velocity
97                 sub.prop(flow, "velocity_factor", text=_("Multiplier"))
98
99                 sub = split.column()
100                 sub.active = not md.flow_settings.use_outflow
101                 sub.label(text=_("Initial Values:"))
102                 sub.prop(flow, "use_absolute")
103                 sub.prop(flow, "density")
104                 sub.prop(flow, "temperature")
105
106
107 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
108     bl_label = "Smoke Groups"
109     bl_options = {'DEFAULT_CLOSED'}
110
111     @classmethod
112     def poll(cls, context):
113         md = context.smoke
114         return md and (md.smoke_type == 'DOMAIN')
115
116     def draw(self, context):
117         layout = self.layout
118
119         group = context.smoke.domain_settings
120
121         split = layout.split()
122
123         col = split.column()
124         col.label(text=_("Flow Group:"))
125         col.prop(group, "fluid_group", text="")
126
127         #col.label(text=_("Effector Group:"))
128         #col.prop(group, "effector_group", text="")
129
130         col = split.column()
131         col.label(text=_("Collision Group:"))
132         col.prop(group, "collision_group", text="")
133
134
135 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, Panel):
136     bl_label = "Smoke High Resolution"
137     bl_options = {'DEFAULT_CLOSED'}
138
139     @classmethod
140     def poll(cls, context):
141         md = context.smoke
142         return md and (md.smoke_type == 'DOMAIN')
143
144     def draw_header(self, context):
145         md = context.smoke.domain_settings
146
147         self.layout.prop(md, "use_high_resolution", text="")
148
149     def draw(self, context):
150         layout = self.layout
151
152         md = context.smoke.domain_settings
153
154         layout.active = md.use_high_resolution
155
156         split = layout.split()
157         split.enabled = not md.point_cache.is_baked
158
159         col = split.column()
160         col.label(text=_("Resolution:"))
161         col.prop(md, "amplify", text=_("Divisions"))
162         col.prop(md, "smooth_emitter")
163
164         col = split.column()
165         col.label(text=_("Noise Method:"))
166         col.row().prop(md, "noise_type", text="")
167         col.prop(md, "strength")
168
169         layout.prop(md, "show_high_resolution")
170
171
172 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
173     bl_label = "Smoke Cache"
174     bl_options = {'DEFAULT_CLOSED'}
175
176     @classmethod
177     def poll(cls, context):
178         md = context.smoke
179         return md and (md.smoke_type == 'DOMAIN')
180
181     def draw(self, context):
182         layout = self.layout
183
184         md = context.smoke.domain_settings
185         cache = md.point_cache
186
187         layout.label(text=_("Compression:"))
188         layout.prop(md, "point_cache_compress_type", expand=True)
189
190         point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
191
192
193 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
194     bl_label = "Smoke Field Weights"
195     bl_options = {'DEFAULT_CLOSED'}
196
197     @classmethod
198     def poll(cls, context):
199         smoke = context.smoke
200         return (smoke and smoke.smoke_type == 'DOMAIN')
201
202     def draw(self, context):
203         domain = context.smoke.domain_settings
204         effector_weights_ui(self, context, domain.effector_weights)
205
206 if __name__ == "__main__":  # only for live edit.
207     bpy.utils.register_module(__name__)