Smoke:
[blender.git] / release / ui / buttons_physics_smoke.py
1
2 import bpy
3
4 def smoke_panel_enabled_low(smd):
5         if smd.smoke_type == 'TYPE_DOMAIN':
6                 return smd.domain.point_cache.baked==False
7         return True
8
9 class PhysicButtonsPanel(bpy.types.Panel):
10         __space_type__ = "PROPERTIES"
11         __region_type__ = "WINDOW"
12         __context__ = "physics"
13
14         def poll(self, context):
15                 ob = context.object
16                 rd = context.scene.render_data
17                 return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
18                 
19 class PHYSICS_PT_smoke(PhysicButtonsPanel):
20         __label__ = "Smoke"
21
22         def draw(self, context):
23                 layout = self.layout
24                 
25                 md = context.smoke
26                 ob = context.object
27
28                 split = layout.split()
29                 split.operator_context = 'EXEC_DEFAULT'
30
31                 if md:
32                         # remove modifier + settings
33                         split.set_context_pointer("modifier", md)
34                         split.itemO("object.modifier_remove", text="Remove")
35
36                         row = split.row(align=True)
37                         row.itemR(md, "render", text="")
38                         row.itemR(md, "realtime", text="")
39                         
40                 else:
41                         # add modifier
42                         split.item_enumO("object.modifier_add", "type", 'SMOKE', text="Add")
43                         split.itemL()
44
45                 if md:
46                 
47                         # layout.enabled = smoke_panel_enabled(md)
48                         layout.itemR(md, "smoke_type", expand=True)
49                 
50                         if md.smoke_type == 'TYPE_DOMAIN':
51                                 
52                                 domain = md.domain_settings
53                                 
54                                 split = layout.split()
55                                 
56                                 col = split.column()
57                                 col.itemL(text="Resolution:")
58                                 col.itemR(domain, "maxres", text="Divisions")
59                                 
60                                 col = split.column()
61                                 col.itemL(text="Behavior:")
62                                 col.itemR(domain, "alpha")
63                                 col.itemR(domain, "beta")
64                                 col.itemR(domain, "dissolve_smoke", text="Dissolve")
65                                 sub = col.column()
66                                 sub.active = domain.dissolve_smoke
67                                 sub.itemR(domain, "dissolve_speed", text="Speed")
68                                 sub.itemR(domain, "dissolve_smoke_log", text="Slow")
69                                 
70                         elif md.smoke_type == 'TYPE_FLOW':
71                                 
72                                 flow = md.flow_settings
73                                 
74                                 split = layout.split()
75                                 
76                                 col = split.column()
77                                 col.itemR(flow, "outflow")
78                                 col.itemL(text="Particle System:")
79                                 col.item_pointerR(flow, "psys", ob, "particle_systems", text="")
80                                 
81                                 if md.flow_settings.outflow:                            
82                                         col = split.column()
83                                 else:
84                                         col = split.column()
85                                         col.itemL(text="Behavior:")
86                                         col.itemR(flow, "temperature")
87                                         col.itemR(flow, "density")
88                                         
89                         #elif md.smoke_type == 'TYPE_COLL':
90                         #       layout.itemS()
91                                         
92 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
93         __label__ = "Smoke Groups"
94         __default_closed__ = True
95         
96         def poll(self, context):
97                 md = context.smoke
98                 if md:
99                                 return (md.smoke_type == 'TYPE_DOMAIN')
100                 
101                 return False
102
103         def draw(self, context):
104                 layout = self.layout
105                 
106                 group = context.smoke.domain_settings
107                 
108                 split = layout.split()
109                 
110                 col = split.column()
111                 col.itemL(text="Flow Group:")
112                 col.itemR(group, "fluid_group", text="")
113                                 
114                 #col.itemL(text="Effector Group:")
115                 #col.itemR(group, "eff_group", text="")
116                                 
117                 col = split.column()
118                 col.itemL(text="Collision Group:")
119                 col.itemR(group, "coll_group", text="")
120                 
121 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
122         __label__ = "Smoke Cache"
123         __default_closed__ = True
124
125         def poll(self, context):
126                 md = context.smoke
127                 if md:
128                                 return (md.smoke_type == 'TYPE_DOMAIN')
129                 
130                 return False
131
132         def draw(self, context):
133                 layout = self.layout
134
135                 md = context.smoke
136                 
137                 if md.smoke_type == 'TYPE_DOMAIN':
138                         
139                         domain = md.domain_settings
140                         cache = domain.point_cache
141                         
142                         layout.set_context_pointer("PointCache", cache)
143                         
144                         row = layout.row()
145                         row.template_list(cache, "point_cache_list", cache, "active_point_cache_index")
146                         col = row.column(align=True)
147                         col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="")
148                         col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="")
149                         
150                         row = layout.row()
151                         row.itemR(cache, "name")
152                         
153                         row = layout.row()
154                         row.itemR(cache, "start_frame")
155                         row.itemR(cache, "end_frame")
156                         
157                         row = layout.row()
158                         
159                         if cache.baked == True:
160                                 row.itemO("ptcache.free_bake", text="Free Bake")
161                         else:
162                                 row.item_booleanO("ptcache.bake", "bake", True, text="Bake")
163                         
164                         subrow = row.row()
165                         subrow.enabled = cache.frames_skipped or cache.outdated
166                         subrow.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame")
167                                 
168                         row = layout.row()
169                         #row.enabled = smoke_panel_enabled(psys)
170                         row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake")
171                 
172                         row = layout.row()
173                         #row.enabled = smoke_panel_enabled(psys)
174                         
175                         layout.itemL(text=cache.info)
176                         
177                         layout.itemS()
178                         
179                         row = layout.row()
180                         row.itemO("ptcache.bake_all", "bake", True, text="Bake All Dynamics")
181                         row.itemO("ptcache.free_bake_all", text="Free All Bakes")
182                         layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame")
183                         
184 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
185         __label__ = "Smoke High Resolution"
186         __default_closed__ = True
187         
188         def poll(self, context):
189                 md = context.smoke
190                 if md:
191                                 return (md.smoke_type == 'TYPE_DOMAIN')
192                 
193                 return False
194
195         def draw_header(self, context):
196                 layout = self.layout
197                 
198                 high = context.smoke.domain_settings
199         
200                 layout.itemR(high, "highres", text="")
201                 
202         def draw(self, context):
203                 layout = self.layout
204                 
205                 md = context.smoke_hr
206                 
207                 if md:
208                 
209                         split = layout.split()
210                         
211                         col = split.column()
212                         col.itemL(text="Resolution:")
213                         col.itemR(md, "amplify", text="Divisions")
214                         
215                         sub = split.column()
216                         sub.itemL(text="Noise Method:")
217                         sub.row().itemR(md, "noise_type", text="")
218                         sub.itemR(md, "strength")
219                         sub.itemR(md, "show_highres")
220                 
221 class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
222         __label__ = "Smoke Cache"
223         __default_closed__ = True
224
225         def poll(self, context):
226                 return (context.smoke_hr != None)
227
228         def draw(self, context):
229                 layout = self.layout
230
231                 md = context.smoke_hr
232                 
233                 if md:
234                         
235                         cache = md.point_cache
236                         
237                         layout.set_context_pointer("PointCache", cache)
238                         
239                         row = layout.row()
240                         row.template_list(cache, "point_cache_list", cache, "active_point_cache_index")
241                         col = row.column(align=True)
242                         col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="")
243                         col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="")
244                         
245                         row = layout.row()
246                         row.itemR(cache, "name")
247                         
248                         row = layout.row()
249                         row.itemR(cache, "start_frame")
250                         row.itemR(cache, "end_frame")
251                         
252                         row = layout.row()
253                         
254                         if cache.baked == True:
255                                 row.itemO("ptcache.free_bake", text="Free Bake")
256                         else:
257                                 row.item_booleanO("ptcache.bake", "bake", True, text="Bake")
258                         
259                         subrow = row.row()
260                         subrow.enabled = cache.frames_skipped or cache.outdated
261                         subrow.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame")
262                                 
263                         row = layout.row()
264                         #row.enabled = smoke_panel_enabled(psys)
265                         row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake")
266                 
267                         row = layout.row()
268                         #row.enabled = smoke_panel_enabled(psys)
269                         
270                         layout.itemL(text=cache.info)
271                         
272                         layout.itemS()
273                         
274                         row = layout.row()
275                         row.itemO("ptcache.bake_all", "bake", True, text="Bake All Dynamics")
276                         row.itemO("ptcache.free_bake_all", text="Free All Bakes")
277                         layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame")
278
279
280 bpy.types.register(PHYSICS_PT_smoke)
281 bpy.types.register(PHYSICS_PT_smoke_cache)
282 bpy.types.register(PHYSICS_PT_smoke_groups)
283 #bpy.types.register(PHYSICS_PT_smoke_highres)
284 #bpy.types.register(PHYSICS_PT_smoke_cache_highres)