cd5bbecc9d60eef05af8ed1035a1f2bd37608435
[blender-staging.git] / release / scripts / ui / properties_physics_smoke.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6
7 import bpy
8
9 from properties_physics_common import point_cache_ui
10 from properties_physics_common import effector_weights_ui
11
12 class PhysicButtonsPanel(bpy.types.Panel):
13     bl_space_type = 'PROPERTIES'
14     bl_region_type = 'WINDOW'
15     bl_context = "physics"
16
17     def poll(self, context):
18         ob = context.object
19         rd = context.scene.render_data
20         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
21
22 class PHYSICS_PT_smoke(PhysicButtonsPanel):
23     bl_label = "Smoke"
24
25     def draw(self, context):
26         layout = self.layout
27
28         md = context.smoke
29         ob = context.object
30
31         split = layout.split()
32         split.operator_context = 'EXEC_DEFAULT'
33
34         if md:
35             # remove modifier + settings
36             split.set_context_pointer("modifier", md)
37             split.itemO("object.modifier_remove", text="Remove")
38
39             row = split.row(align=True)
40             row.itemR(md, "render", text="")
41             row.itemR(md, "realtime", text="")
42
43         else:
44             # add modifier
45             split.item_enumO("object.modifier_add", "type", 'SMOKE', text="Add")
46             split.itemL()
47
48         if md:
49             layout.itemR(md, "smoke_type", expand=True)
50
51             if md.smoke_type == 'TYPE_DOMAIN':
52
53                 domain = md.domain_settings
54
55                 split = layout.split()
56
57                 col = split.column()
58                 col.itemL(text="Resolution:")
59                 col.itemR(domain, "maxres", text="Divisions")
60
61                 col = split.column()
62                 col.itemL(text="Behavior:")
63                 col.itemR(domain, "alpha")
64                 col.itemR(domain, "beta")
65                 col.itemR(domain, "dissolve_smoke", text="Dissolve")
66                 sub = col.column()
67                 sub.active = domain.dissolve_smoke
68                 sub.itemR(domain, "dissolve_speed", text="Time")
69                 sub.itemR(domain, "dissolve_smoke_log", text="Slow")
70
71             elif md.smoke_type == 'TYPE_FLOW':
72
73                 flow = md.flow_settings
74
75                 split = layout.split()
76
77                 col = split.column()
78                 col.itemR(flow, "outflow")
79                 col.itemL(text="Particle System:")
80                 col.item_pointerR(flow, "psys", ob, "particle_systems", text="")
81
82                 if md.flow_settings.outflow:
83                     col = split.column()
84                 else:
85                     col = split.column()
86                     col.itemL(text="Behavior:")
87                     col.itemR(flow, "temperature")
88                     col.itemR(flow, "density")
89
90             #elif md.smoke_type == 'TYPE_COLL':
91             #   layout.itemS()
92
93 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
94     bl_label = "Smoke Groups"
95     bl_default_closed = True
96
97     def poll(self, context):
98         md = context.smoke
99         return md and (md.smoke_type == 'TYPE_DOMAIN')
100
101     def draw(self, context):
102         layout = self.layout
103
104         group = context.smoke.domain_settings
105
106         split = layout.split()
107
108         col = split.column()
109         col.itemL(text="Flow Group:")
110         col.itemR(group, "fluid_group", text="")
111
112         #col.itemL(text="Effector Group:")
113         #col.itemR(group, "eff_group", text="")
114
115         col = split.column()
116         col.itemL(text="Collision Group:")
117         col.itemR(group, "coll_group", text="")
118
119 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
120     bl_label = "Smoke Cache"
121     bl_default_closed = True
122
123     def poll(self, context):
124         md = context.smoke
125         return md and (md.smoke_type == 'TYPE_DOMAIN')
126
127     def draw(self, context):
128         layout = self.layout
129
130         md = context.smoke.domain_settings
131         cache = md.point_cache_low
132
133         point_cache_ui(self, cache, cache.baked==False, 0, 1)
134
135 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
136     bl_label = "Smoke High Resolution"
137     bl_default_closed = True
138
139     def poll(self, context):
140         md = context.smoke
141         return md and (md.smoke_type == 'TYPE_DOMAIN')
142
143     def draw_header(self, context):
144         high = context.smoke.domain_settings
145
146         self.layout.itemR(high, "highres", text="")
147
148     def draw(self, context):
149         layout = self.layout
150
151         md = context.smoke.domain_settings
152
153         split = layout.split()
154
155         col = split.column()
156         col.itemL(text="Resolution:")
157         col.itemR(md, "amplify", text="Divisions")
158
159         col = split.column()
160         col.itemL(text="Noise Method:")
161         col.row().itemR(md, "noise_type", text="")
162         col.itemR(md, "strength")
163         col.itemR(md, "viewhighres")
164
165 class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
166     bl_label = "Smoke High Resolution Cache"
167     bl_default_closed = True
168
169     def poll(self, context):
170         md = context.smoke
171         return md and (md.smoke_type == 'TYPE_DOMAIN') and md.domain_settings.highres
172
173     def draw(self, context):
174         layout = self.layout
175
176         md = context.smoke.domain_settings
177         cache = md.point_cache_high
178
179         point_cache_ui(self, cache, cache.baked==False, 0, 1)
180
181 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel):
182     bl_label = "Smoke Field Weights"
183     bl_default_closed = True
184
185     def poll(self, context):
186         smoke = context.smoke
187         return (smoke and smoke.smoke_type == 'TYPE_DOMAIN')
188
189     def draw(self, context):
190         domain = context.smoke.domain_settings
191         effector_weights_ui(self, domain.effector_weights)
192
193 bpy.types.register(PHYSICS_PT_smoke)
194 bpy.types.register(PHYSICS_PT_smoke_field_weights)
195 bpy.types.register(PHYSICS_PT_smoke_cache)
196 bpy.types.register(PHYSICS_PT_smoke_highres)
197 bpy.types.register(PHYSICS_PT_smoke_groups)
198 bpy.types.register(PHYSICS_PT_smoke_cache_highres)