8cec90f41ba00a4dbe8863aa1465ccd111a3a861
[blender-staging.git] / release / ui / buttons_physics_fluid.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "physics"
8
9         def poll(self, context):
10                 ob = context.object
11                 return (ob and ob.type == 'MESH')
12                 
13 class PHYSICS_PT_fluid(PhysicButtonsPanel):
14         __idname__ = "PHYSICS_PT_fluid"
15         __label__ = "Fluid"
16
17         def draw(self, context):
18                 layout = self.layout
19                 md = context.fluid
20                 ob = context.object
21
22                 split = layout.split()
23                 split.operator_context = "EXEC_DEFAULT"
24
25                 if md:
26                         # remove modifier + settings
27                         split.set_context_pointer("modifier", md)
28                         split.itemO("object.modifier_remove", text="Remove")
29
30                         row = split.row(align=True)
31                         row.itemR(md, "render", text="")
32                         row.itemR(md, "realtime", text="")
33                         
34                         fluid = md.settings
35                         
36                 else:
37                         # add modifier
38                         split.item_enumO("object.modifier_add", "type", "FLUID_SIMULATION", text="Add")
39                         split.itemL()
40                         
41                         fluid = None
42                 
43                 
44                 if fluid:
45                         
46                         col = layout.column(align=True)
47                         col.itemR(fluid, "type")
48
49                         if fluid.type == 'DOMAIN':
50                                 layout.itemO("fluid.bake", text="BAKE")
51                                 split = layout.split()
52                                 
53                                 col = split.column()
54                                 col.itemL(text="Resolution:")
55                                 colsub = col.column()
56                                 colsub.itemR(fluid, "resolution", text="Final")
57                                 colsub.itemL(text="Render Display:")
58                                 colsub.itemR(fluid, "render_display_mode", text="")
59                                 col.itemL(text="Time:")
60                                 colsub = col.column(align=True)
61                                 colsub.itemR(fluid, "start_time", text="Start")
62                                 colsub.itemR(fluid, "end_time", text="End")
63                                 
64                                 col = split.column()
65                                 colsub = col.column()
66                                 colsub.itemL(text="Required Memory: " + fluid.memory_estimate)
67                                 colsub.itemR(fluid, "preview_resolution", text="Preview")
68                                 colsub.itemL(text="Viewport Display:")
69                                 colsub.itemR(fluid, "viewport_display_mode", text="")
70                                 colsub = col.column()
71                                 colsub.itemL(text="")
72                                 colsub.itemR(fluid, "reverse_frames")
73                                 colsub.itemR(fluid, "generate_speed_vectors")
74                                 
75                                 layout.itemL(text="Path:")
76                                 layout.itemR(fluid, "path", text="")
77                                 
78                         if fluid.type == 'FLUID':
79                                 split = layout.split()
80                                 col = split.column()
81                                 col.itemL(text="Volume Initialization:")
82                                 col.itemR(fluid, "volume_initialization", text="")
83                                 col.itemR(fluid, "export_animated_mesh")
84                                 col = split.column()
85                                 col.itemL(text="Initial Velocity:")
86                                 col.itemR(fluid, "initial_velocity", text="")
87                                 
88                         if fluid.type == 'OBSTACLE':
89                                 split = layout.split()
90                                 col = split.column()
91                                 col.itemL(text="Volume Initialization:")
92                                 col.itemR(fluid, "volume_initialization", text="")
93                                 col.itemR(fluid, "export_animated_mesh")
94                                 col = split.column()
95                                 col.itemL(text="Slip Type:")
96                                 colsub=col.column(align=True)
97                                 colsub.itemR(fluid, "slip_type", text="")
98                                 if fluid.slip_type == 'PARTIALSLIP':
99                                         colsub.itemR(fluid, "partial_slip_amount", slider=True, text="Amount")
100                                         
101                                 col.itemR(fluid, "impact_factor")
102                                 
103                         if fluid.type == 'INFLOW':
104                                 split = layout.split()
105                                 col = split.column()
106                                 col.itemL(text="Volume Initialization:")
107                                 col.itemR(fluid, "volume_initialization", text="")
108                                 col.itemR(fluid, "export_animated_mesh")
109                                 col.itemR(fluid, "local_coordinates")
110                                 
111                                 col = split.column()
112                                 col.itemL(text="Inflow Velocity:")
113                                 col.itemR(fluid, "inflow_velocity", text="")
114                                 
115                         if fluid.type == 'OUTFLOW':
116                                 split = layout.split()
117                                 col = split.column()
118                                 col.itemL(text="Volume Initialization:")
119                                 col.itemR(fluid, "volume_initialization", text="")
120                                 col.itemR(fluid, "export_animated_mesh")
121                                 col = split.column()
122                                 
123                         if fluid.type == 'PARTICLE':
124                                 split = layout.split()
125                                 
126                                 col = split.column()
127                                 col.itemL(text="Influence:")
128                                 colsub = col.column(align=True)
129                                 colsub.itemR(fluid, "particle_influence", text="Size")
130                                 colsub.itemR(fluid, "alpha_influence", text="Alpha")
131                                 col.itemL(text="Path:")
132                                 
133                                 layout.itemR(fluid, "path", text="")
134                                 
135                                 col = split.column()
136                                 col.itemL(text="Type:")
137                                 col.itemR(fluid, "drops")
138                                 col.itemR(fluid, "floats")
139                                 col.itemR(fluid, "tracer")
140                                 
141                         if fluid.type == 'CONTROL':
142                                 split = layout.split()
143                                 
144                                 col = split.column()
145                                 col.itemL(text="")
146                                 col.itemR(fluid, "quality", slider=True)
147                                 col.itemR(fluid, "reverse_frames")
148                                 
149                                 col = split.column()
150                                 col.itemL(text="Time:")
151                                 col=col.column(align=True)
152                                 col.itemR(fluid, "start_time", text="Start")
153                                 col.itemR(fluid, "end_time", text="End")
154                                 
155                                 split = layout.split()
156                                 
157                                 col = split.column()
158                                 col.itemL(text="Attraction Force:")
159                                 col=col.column(align=True)
160                                 col.itemR(fluid, "attraction_strength", text="Strength")
161                                 col.itemR(fluid, "attraction_radius", text="Radius")
162                                 
163                                 col = split.column()
164                                 col.itemL(text="Velocity Force:")
165                                 col=col.column(align=True)
166                                 col.itemR(fluid, "velocity_strength", text="Strength")
167                                 col.itemR(fluid, "velocity_radius", text="Radius")
168
169 class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
170         __idname__ = "PHYSICS_PT_domain_gravity"
171         __label__ = "Domain World"
172         __default_closed__ = True
173         
174         def poll(self, context):
175                 md = context.fluid
176                 if md:
177                         settings = md.settings
178                         if settings:
179                                 return (settings.type == 'DOMAIN')
180                 
181                 return False
182
183         def draw(self, context):
184                 layout = self.layout
185                 fluid = context.fluid.settings
186                 
187                 split = layout.split()
188                 
189                 col = split.column()
190                 col.itemL(text="Gravity:")
191                 col.itemR(fluid, "gravity", text="")
192                 
193                 col.itemL(text="Real World Size:")
194                 col.itemR(fluid, "real_world_size", text="Metres")
195                 
196                 col = split.column()
197                 col.itemL(text="Viscosity Presets:")
198                 colsub=col.column(align=True)
199                 colsub.itemR(fluid, "viscosity_preset", text="")
200                 
201                 if fluid.viscosity_preset == 'MANUAL':
202                         colsub.itemR(fluid, "viscosity_base", text="Base")
203                         colsub.itemR(fluid, "viscosity_exponent", text="Exponent", slider=True)
204                 else:
205                         colsub.itemL(text="")
206                         colsub.itemL(text="")
207                         
208                 col.itemL(text="Optimization:")
209                 col=col.column(align=True)
210                 col.itemR(fluid, "grid_levels", slider=True)
211                 col.itemR(fluid, "compressibility", slider=True)
212         
213 class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
214         __idname__ = "PHYSICS_PT_domain_boundary"
215         __label__ = "Domain Boundary"
216         __default_closed__ = True
217         
218         def poll(self, context):
219                 md = context.fluid
220                 if md:
221                         settings = md.settings
222                         if settings:
223                                 return (settings.type == 'DOMAIN')
224                 
225                 return False
226
227         def draw(self, context):
228                 layout = self.layout
229                 fluid = context.fluid.settings
230                 
231                 split = layout.split()
232                 col = split.column()
233                 col.itemL(text="Slip Type:")
234                 col=col.column(align=True)
235                 col.itemR(fluid, "slip_type", text="")
236                 if fluid.slip_type == 'PARTIALSLIP':
237                         col.itemR(fluid, "partial_slip_amount", slider=True, text="Amount")
238                 col = split.column()
239                 col.itemL(text="Surface:")
240                 col=col.column(align=True)
241                 col.itemR(fluid, "surface_smoothing", text="Smoothing")
242                 col.itemR(fluid, "surface_subdivisions", text="Subdivisions")   
243                 
244 class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
245         __idname__ = "PHYSICS_PT_domain_particles"
246         __label__ = "Domain Particles"
247         __default_closed__ = True
248         
249         def poll(self, context):
250                 md = context.fluid
251                 if md:
252                         settings = md.settings
253                         if settings:
254                                 return (settings.type == 'DOMAIN')
255                 
256                 return False
257
258         def draw(self, context):
259                 layout = self.layout
260                 fluid = context.fluid.settings
261                 
262                 col=layout.column(align=True)
263                 col.itemR(fluid, "tracer_particles")
264                 col.itemR(fluid, "generate_particles")
265
266 bpy.types.register(PHYSICS_PT_fluid)
267 bpy.types.register(PHYSICS_PT_domain_gravity)
268 bpy.types.register(PHYSICS_PT_domain_boundary)
269 bpy.types.register(PHYSICS_PT_domain_particles)