soc-2008-mxcurioni: merged changes to revision 23516
[blender.git] / release / scripts / 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                 return md and (md.smoke_type == 'TYPE_DOMAIN')
94
95         def draw(self, context):
96                 layout = self.layout
97                 
98                 group = context.smoke.domain_settings
99                 
100                 split = layout.split()
101                 
102                 col = split.column()
103                 col.itemL(text="Flow Group:")
104                 col.itemR(group, "fluid_group", text="")
105                                 
106                 #col.itemL(text="Effector Group:")
107                 #col.itemR(group, "eff_group", text="")
108                                 
109                 col = split.column()
110                 col.itemL(text="Collision Group:")
111                 col.itemR(group, "coll_group", text="")
112
113 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
114         __label__ = "Smoke Cache"
115         __default_closed__ = True
116
117         def poll(self, context):
118                 md = context.smoke
119                 return md and (md.smoke_type == 'TYPE_DOMAIN')
120
121         def draw(self, context):
122                 layout = self.layout
123
124                 md = context.smoke.domain_settings
125                 cache = md.point_cache_low
126                         
127                 point_cache_ui(self, cache, cache.baked==False, 0, 1)
128                                         
129 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
130         __label__ = "Smoke High Resolution"
131         __default_closed__ = True
132         
133         def poll(self, context):
134                 md = context.smoke
135                 return md and (md.smoke_type == 'TYPE_DOMAIN')
136
137         def draw_header(self, context): 
138                 high = context.smoke.domain_settings
139         
140                 self.layout.itemR(high, "highres", text="")
141                 
142         def draw(self, context):
143                 layout = self.layout
144                 
145                 md = context.smoke.domain_settings
146
147                 split = layout.split()
148                         
149                 col = split.column()
150                 col.itemL(text="Resolution:")
151                 col.itemR(md, "amplify", text="Divisions")
152                         
153                 col = split.column()
154                 col.itemL(text="Noise Method:")
155                 col.row().itemR(md, "noise_type", text="")
156                 col.itemR(md, "strength")
157                 col.itemR(md, "viewhighres")
158                 
159 class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel):
160         __label__ = "Smoke High Resolution Cache"
161         __default_closed__ = True
162
163         def poll(self, context):
164                 md = context.smoke
165                 return md and (md.smoke_type == 'TYPE_DOMAIN') and md.domain_settings.highres
166
167         def draw(self, context):
168                 layout = self.layout
169
170                 md = context.smoke.domain_settings
171                 cache = md.point_cache_high
172                         
173                 point_cache_ui(self, cache, cache.baked==False, 0, 1)
174                                         
175 bpy.types.register(PHYSICS_PT_smoke)
176 bpy.types.register(PHYSICS_PT_smoke_cache)
177 bpy.types.register(PHYSICS_PT_smoke_highres)
178 bpy.types.register(PHYSICS_PT_smoke_groups)
179 bpy.types.register(PHYSICS_PT_smoke_cache_highres)