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