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