blender/release/scripts/startup/bl_ui/properties_physics_fluid.py

289 lines
9.6 KiB
Python
Raw Normal View History

# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2010-02-12 13:34:04 +00:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
from bpy.types import Panel
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.fluid)
class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
bl_label = "Fluid"
def draw(self, context):
layout = self.layout
md = context.fluid
if md:
fluid = md.settings
row = layout.row()
if fluid is None:
row.label("Built without fluids")
return
row.prop(fluid, "type")
if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID'}:
row.prop(fluid, "use", text="")
2010-04-04 14:52:15 +00:00
Restored Fluid Sim baking This commit restores fluid sim baking functionality in 2.5, it's been on the todo for a while, and was previously almost completely non-functional. The old code was quite complicated and specific to the 2.4 animation system, so I've pretty much rewritten most of it. This includes: * Animated variables work again - just key them in the UI. Non-animateable values should be already set non-animateable in RNA, hopefully I got them all. Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale / Object initial velocity / Deforming meshes / Fluid control Attract strength / Fluid control Attract radius / Fluid control Velocity strength / Fluid control Velocity radius / Object Active status (checkbox next to fluid type) The Domain time scale is still not yet implemented. * Fluid sim now use global scene units data by default - when enabled, the scene's global gravity value is used and when units are set (metric/imperial) the simulation real world size is taken from the object's actual measurements. * The baking process is now done in the background, using the nifty threaded Jobs system. It's non-blocking and your domain object will show the simulated fluid as it becomes available for that frame. A nice extra thing for the future would be to improve the visualisation of the object's state while baking, and also the jobs system/ui could do with some touchups - currently it has to share a bit from the 'render' job, and appears as 'Render' in the header. Progress bars for jobs in the header would be great too.
2010-03-25 06:27:25 +00:00
layout = layout.column()
if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID'}:
layout.active = fluid.use
2010-04-04 14:52:15 +00:00
if fluid.type == 'DOMAIN':
layout.operator("fluid.bake", text="Bake (Req. Memory: %s)" % fluid.memory_estimate, icon='MOD_FLUIDSIM')
split = layout.split()
col = split.column()
col.label(text="Resolution:")
col.prop(fluid, "resolution", text="Final")
col.label(text="Render Display:")
col.prop(fluid, "render_display_mode", text="")
col = split.column()
col.label()
col.prop(fluid, "preview_resolution", text="Preview")
col.label(text="Viewport Display:")
col.prop(fluid, "viewport_display_mode", text="")
split = layout.split()
col = split.column()
col.label(text="Time:")
sub = col.column(align=True)
sub.prop(fluid, "start_time", text="Start")
sub.prop(fluid, "end_time", text="End")
col = split.column()
col.label()
col.prop(fluid, "use_speed_vectors")
col.prop(fluid, "use_reverse_frames")
2010-08-19 15:49:30 +00:00
layout.prop(fluid, "filepath", text="")
elif fluid.type == 'FLUID':
split = layout.split()
col = split.column()
col.label(text="Volume Initialization:")
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "use_animated_mesh")
col = split.column()
col.label(text="Initial Velocity:")
col.prop(fluid, "initial_velocity", text="")
elif fluid.type == 'OBSTACLE':
split = layout.split()
col = split.column()
col.label(text="Volume Initialization:")
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "use_animated_mesh")
col = split.column()
col.label(text="Slip Type:")
col.prop(fluid, "slip_type", text="")
if fluid.slip_type == 'PARTIALSLIP':
col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
col.label(text="Impact:")
col.prop(fluid, "impact_factor", text="Factor")
elif fluid.type == 'INFLOW':
split = layout.split()
col = split.column()
col.label(text="Volume Initialization:")
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "use_animated_mesh")
row = col.row()
row.active = not fluid.use_animated_mesh
row.prop(fluid, "use_local_coords")
col = split.column()
col.label(text="Inflow Velocity:")
col.prop(fluid, "inflow_velocity", text="")
elif fluid.type == 'OUTFLOW':
split = layout.split()
col = split.column()
col.label(text="Volume Initialization:")
col.prop(fluid, "volume_initialization", text="")
col.prop(fluid, "use_animated_mesh")
split.column()
elif fluid.type == 'PARTICLE':
split = layout.split()
col = split.column()
col.label(text="Influence:")
col.prop(fluid, "particle_influence", text="Size")
col.prop(fluid, "alpha_influence", text="Alpha")
col = split.column()
col.label(text="Type:")
col.prop(fluid, "use_drops")
col.prop(fluid, "use_floats")
col.prop(fluid, "show_tracer")
2010-08-19 15:49:30 +00:00
layout.prop(fluid, "filepath", text="")
elif fluid.type == 'CONTROL':
split = layout.split()
col = split.column()
col.label(text="")
col.prop(fluid, "quality", slider=True)
col.prop(fluid, "use_reverse_frames")
col = split.column()
col.label(text="Time:")
sub = col.column(align=True)
sub.prop(fluid, "start_time", text="Start")
sub.prop(fluid, "end_time", text="End")
split = layout.split()
col = split.column()
col.label(text="Attraction Force:")
sub = col.column(align=True)
sub.prop(fluid, "attraction_strength", text="Strength")
sub.prop(fluid, "attraction_radius", text="Radius")
col = split.column()
col.label(text="Velocity Force:")
sub = col.column(align=True)
sub.prop(fluid, "velocity_strength", text="Strength")
sub.prop(fluid, "velocity_radius", text="Radius")
class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
bl_label = "Domain World"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.fluid
return md and md.settings and (md.settings.type == 'DOMAIN')
def draw(self, context):
layout = self.layout
fluid = context.fluid.settings
Restored Fluid Sim baking This commit restores fluid sim baking functionality in 2.5, it's been on the todo for a while, and was previously almost completely non-functional. The old code was quite complicated and specific to the 2.4 animation system, so I've pretty much rewritten most of it. This includes: * Animated variables work again - just key them in the UI. Non-animateable values should be already set non-animateable in RNA, hopefully I got them all. Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale / Object initial velocity / Deforming meshes / Fluid control Attract strength / Fluid control Attract radius / Fluid control Velocity strength / Fluid control Velocity radius / Object Active status (checkbox next to fluid type) The Domain time scale is still not yet implemented. * Fluid sim now use global scene units data by default - when enabled, the scene's global gravity value is used and when units are set (metric/imperial) the simulation real world size is taken from the object's actual measurements. * The baking process is now done in the background, using the nifty threaded Jobs system. It's non-blocking and your domain object will show the simulated fluid as it becomes available for that frame. A nice extra thing for the future would be to improve the visualisation of the object's state while baking, and also the jobs system/ui could do with some touchups - currently it has to share a bit from the 'render' job, and appears as 'Render' in the header. Progress bars for jobs in the header would be great too.
2010-03-25 06:27:25 +00:00
scene = context.scene
split = layout.split()
col = split.column()
Restored Fluid Sim baking This commit restores fluid sim baking functionality in 2.5, it's been on the todo for a while, and was previously almost completely non-functional. The old code was quite complicated and specific to the 2.4 animation system, so I've pretty much rewritten most of it. This includes: * Animated variables work again - just key them in the UI. Non-animateable values should be already set non-animateable in RNA, hopefully I got them all. Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale / Object initial velocity / Deforming meshes / Fluid control Attract strength / Fluid control Attract radius / Fluid control Velocity strength / Fluid control Velocity radius / Object Active status (checkbox next to fluid type) The Domain time scale is still not yet implemented. * Fluid sim now use global scene units data by default - when enabled, the scene's global gravity value is used and when units are set (metric/imperial) the simulation real world size is taken from the object's actual measurements. * The baking process is now done in the background, using the nifty threaded Jobs system. It's non-blocking and your domain object will show the simulated fluid as it becomes available for that frame. A nice extra thing for the future would be to improve the visualisation of the object's state while baking, and also the jobs system/ui could do with some touchups - currently it has to share a bit from the 'render' job, and appears as 'Render' in the header. Progress bars for jobs in the header would be great too.
2010-03-25 06:27:25 +00:00
if scene.use_gravity:
col.label(text="Using Scene Gravity", icon="SCENE_DATA")
sub = col.column()
sub.enabled = False
sub.prop(fluid, "gravity", text="")
else:
col.label(text="Gravity:")
col.prop(fluid, "gravity", text="")
2010-04-04 14:52:15 +00:00
Restored Fluid Sim baking This commit restores fluid sim baking functionality in 2.5, it's been on the todo for a while, and was previously almost completely non-functional. The old code was quite complicated and specific to the 2.4 animation system, so I've pretty much rewritten most of it. This includes: * Animated variables work again - just key them in the UI. Non-animateable values should be already set non-animateable in RNA, hopefully I got them all. Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale / Object initial velocity / Deforming meshes / Fluid control Attract strength / Fluid control Attract radius / Fluid control Velocity strength / Fluid control Velocity radius / Object Active status (checkbox next to fluid type) The Domain time scale is still not yet implemented. * Fluid sim now use global scene units data by default - when enabled, the scene's global gravity value is used and when units are set (metric/imperial) the simulation real world size is taken from the object's actual measurements. * The baking process is now done in the background, using the nifty threaded Jobs system. It's non-blocking and your domain object will show the simulated fluid as it becomes available for that frame. A nice extra thing for the future would be to improve the visualisation of the object's state while baking, and also the jobs system/ui could do with some touchups - currently it has to share a bit from the 'render' job, and appears as 'Render' in the header. Progress bars for jobs in the header would be great too.
2010-03-25 06:27:25 +00:00
if scene.unit_settings.system != 'NONE':
col.label(text="Using Scene Size Units", icon="SCENE_DATA")
sub = col.column()
sub.enabled = False
sub.prop(fluid, "simulation_scale", text="Metres")
Restored Fluid Sim baking This commit restores fluid sim baking functionality in 2.5, it's been on the todo for a while, and was previously almost completely non-functional. The old code was quite complicated and specific to the 2.4 animation system, so I've pretty much rewritten most of it. This includes: * Animated variables work again - just key them in the UI. Non-animateable values should be already set non-animateable in RNA, hopefully I got them all. Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale / Object initial velocity / Deforming meshes / Fluid control Attract strength / Fluid control Attract radius / Fluid control Velocity strength / Fluid control Velocity radius / Object Active status (checkbox next to fluid type) The Domain time scale is still not yet implemented. * Fluid sim now use global scene units data by default - when enabled, the scene's global gravity value is used and when units are set (metric/imperial) the simulation real world size is taken from the object's actual measurements. * The baking process is now done in the background, using the nifty threaded Jobs system. It's non-blocking and your domain object will show the simulated fluid as it becomes available for that frame. A nice extra thing for the future would be to improve the visualisation of the object's state while baking, and also the jobs system/ui could do with some touchups - currently it has to share a bit from the 'render' job, and appears as 'Render' in the header. Progress bars for jobs in the header would be great too.
2010-03-25 06:27:25 +00:00
else:
col.label(text="Real World Size:")
col.prop(fluid, "simulation_scale", text="Metres")
col = split.column()
col.label(text="Viscosity Presets:")
sub = col.column(align=True)
sub.prop(fluid, "viscosity_preset", text="")
if fluid.viscosity_preset == 'MANUAL':
sub.prop(fluid, "viscosity_base", text="Base")
sub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True)
col.label(text="Optimization:")
col.prop(fluid, "grid_levels", slider=True)
col.prop(fluid, "compressibility", slider=True)
class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
bl_label = "Domain Boundary"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.fluid
return md and md.settings and (md.settings.type == 'DOMAIN')
def draw(self, context):
layout = self.layout
fluid = context.fluid.settings
split = layout.split()
col = split.column()
col.label(text="Slip Type:")
col.prop(fluid, "slip_type", text="")
if fluid.slip_type == 'PARTIALSLIP':
col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
col.prop(fluid, "surface_noobs")
col = split.column()
col.label(text="Surface:")
col.prop(fluid, "surface_smooth", text="Smoothing")
col.prop(fluid, "surface_subdivisions", text="Subdivisions")
class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel):
bl_label = "Domain Particles"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.fluid
return md and md.settings and (md.settings.type == 'DOMAIN')
def draw(self, context):
layout = self.layout
fluid = context.fluid.settings
col = layout.column(align=True)
col.prop(fluid, "tracer_particles")
col.prop(fluid, "generate_particles")
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)