[Bf-blender-cvs] [8da87f1eb0f] fluid-mantaflow: Mantaflow: Customized UI for Manta fluids
Sebastián Barschkis
noreply at git.blender.org
Sat Apr 6 22:12:51 CEST 2019
Commit: 8da87f1eb0f99b57d616d8ab188f589c6976576b
Author: Sebastián Barschkis
Date: Sun Oct 28 15:39:39 2018 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB8da87f1eb0f99b57d616d8ab188f589c6976576b
Mantaflow: Customized UI for Manta fluids
Single UI for smoke and liquid
===================================================================
A release/scripts/presets/mantaflow/honey.py
A release/scripts/presets/mantaflow/oil.py
A release/scripts/presets/mantaflow/water.py
M release/scripts/startup/bl_operators/object_quick_effects.py
M release/scripts/startup/bl_operators/presets.py
M release/scripts/startup/bl_ui/properties_particle.py
M release/scripts/startup/bl_ui/properties_physics_common.py
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M release/scripts/startup/bl_ui/space_view3d.py
===================================================================
diff --git a/release/scripts/presets/mantaflow/honey.py b/release/scripts/presets/mantaflow/honey.py
new file mode 100644
index 00000000000..d1b9707c948
--- /dev/null
+++ b/release/scripts/presets/mantaflow/honey.py
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.smoke.domain_settings.viscosity_base = 2.0
+bpy.context.smoke.domain_settings.viscosity_exponent = 3
diff --git a/release/scripts/presets/mantaflow/oil.py b/release/scripts/presets/mantaflow/oil.py
new file mode 100644
index 00000000000..6bbb84e6f0d
--- /dev/null
+++ b/release/scripts/presets/mantaflow/oil.py
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.smoke.domain_settings.viscosity_base = 5.0
+bpy.context.smoke.domain_settings.viscosity_exponent = 5
diff --git a/release/scripts/presets/mantaflow/water.py b/release/scripts/presets/mantaflow/water.py
new file mode 100644
index 00000000000..17095ce7b7e
--- /dev/null
+++ b/release/scripts/presets/mantaflow/water.py
@@ -0,0 +1,3 @@
+import bpy
+bpy.context.smoke.domain_settings.viscosity_base = 1.0
+bpy.context.smoke.domain_settings.viscosity_exponent = 6
diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py
index e3c8b2c0f04..6c6edda849d 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -323,8 +323,8 @@ class QuickSmoke(Operator):
)
def execute(self, context):
- if not bpy.app.build_options.mod_smoke:
- self.report({'ERROR'}, "Built without Smoke modifier support")
+ if not bpy.app.build_options.manta:
+ self.report({'ERROR'}, "Built without Fluid Mantaflow modifier")
return {'CANCELLED'}
fake_context = context.copy()
@@ -346,6 +346,9 @@ class QuickSmoke(Operator):
# set type
obj.modifiers[-1].flow_settings.smoke_flow_type = self.style
+ # set flow behavior
+ obj.modifiers[-1].flow_settings.smoke_flow_behavior = 'INFLOW'
+
if not self.show_flows:
obj.display_type = 'WIRE'
@@ -365,7 +368,10 @@ class QuickSmoke(Operator):
bpy.ops.object.modifier_add(type='SMOKE')
obj.modifiers[-1].smoke_type = 'DOMAIN'
if self.style == 'FIRE' or self.style == 'BOTH':
- obj.modifiers[-1].domain_settings.use_high_resolution = True
+ obj.modifiers[-1].domain_settings.use_noise = True
+
+ # set correct cache file format for smoke
+ obj.modifiers[-1].domain_settings.cache_data_format = 'UNI'
# Setup material
@@ -538,9 +544,117 @@ class QuickFluid(Operator):
return {'FINISHED'}
+class QuickLiquid(Operator):
+ bl_idname = "object.quick_liquid"
+ bl_label = "Quick Liquid"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ show_flows: BoolProperty(
+ name="Render Liquid Objects",
+ description="Keep the liquid objects visible during rendering",
+ default=False,
+ )
+
+ def execute(self, context):
+ fake_context = context.copy()
+ mesh_objects = [obj for obj in context.selected_objects
+ if obj.type == 'MESH']
+ min_co = Vector((100000.0, 100000.0, 100000.0))
+ max_co = -min_co
+
+ if not mesh_objects:
+ self.report({'ERROR'}, "Select at least one mesh object")
+ return {'CANCELLED'}
+
+ for obj in mesh_objects:
+ fake_context["object"] = obj
+ # make each selected object a liquid flow
+ bpy.ops.object.modifier_add(fake_context, type='SMOKE')
+ obj.modifiers[-1].smoke_type = 'FLOW'
+
+ # set type
+ obj.modifiers[-1].flow_settings.smoke_flow_type = 'LIQUID'
+
+ # set flow behavior
+ obj.modifiers[-1].flow_settings.smoke_flow_behavior = 'GEOMETRY'
+
+ if not self.show_flows:
+ obj.display_type = 'WIRE'
+
+ # store bounding box min/max for the domain object
+ obj_bb_minmax(obj, min_co, max_co)
+
+ # add the liquid domain object
+ bpy.ops.mesh.primitive_cube_add()
+ obj = context.active_object
+ obj.name = "Liquid Domain"
+
+ # give the liquid some room above the flows
+ obj.location = 0.5 * (max_co + min_co) + Vector((0.0, 0.0, -1.0))
+ obj.scale = 0.5 * (max_co - min_co) + Vector((1.0, 1.0, 2.0))
+
+ # setup liquid domain
+ bpy.ops.object.modifier_add(type='SMOKE')
+ obj.modifiers[-1].smoke_type = 'DOMAIN'
+ obj.modifiers[-1].domain_settings.smoke_domain_type = 'LIQUID'
+ # set all domain borders to obstacle
+ obj.modifiers[-1].domain_settings.use_collision_border_front = True
+ obj.modifiers[-1].domain_settings.use_collision_border_back = True
+ obj.modifiers[-1].domain_settings.use_collision_border_right = True
+ obj.modifiers[-1].domain_settings.use_collision_border_left = True
+ obj.modifiers[-1].domain_settings.use_collision_border_top = True
+ obj.modifiers[-1].domain_settings.use_collision_border_bottom = True
+
+ # set correct cache file format for liquid
+ obj.modifiers[-1].domain_settings.cache_mesh_format = 'BOBJECT'
+
+ # allocate and show particle system for FLIP
+ obj.modifiers[-1].domain_settings.use_flip_particles = True
+
+ # make the domain smooth so it renders nicely
+ bpy.ops.object.shade_smooth()
+
+ # create a ray-transparent material for the domain
+ bpy.ops.object.material_slot_add()
+
+ mat = bpy.data.materials.new("Liquid Domain Material")
+ obj.material_slots[0].material = mat
+
+ # Make sure we use nodes
+ mat.use_nodes = True
+
+ # Set node variables and clear the default nodes
+ tree = mat.node_tree
+ nodes = tree.nodes
+ links = tree.links
+
+ nodes.clear()
+
+ # Create shader nodes
+
+ # Material output
+ node_out = nodes.new(type='ShaderNodeOutputMaterial')
+ node_out.location = grid_location(6, 1)
+
+ # Add Glass
+ node_glass = nodes.new(type='ShaderNodeBsdfGlass')
+ node_glass.location = grid_location(4, 1)
+ links.new(node_glass.outputs["BSDF"], node_out.inputs["Surface"])
+ node_glass.inputs["IOR"].default_value = 1.33
+
+ # Add Absorption
+ node_absorption = nodes.new(type='ShaderNodeVolumeAbsorption')
+ node_absorption.location = grid_location(4, 2)
+ links.new(node_absorption.outputs["Volume"], node_out.inputs["Volume"])
+ node_absorption.inputs["Color"].default_value = (0.8, 0.9, 1.0, 1.0)
+
+ return {'FINISHED'}
+
+
classes = (
QuickExplode,
QuickFluid,
QuickFur,
QuickSmoke,
+ QuickLiquid,
)
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 9d64c02d1ca..4d5a0672353 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -408,6 +408,24 @@ class AddPresetFluid(AddPresetBase, Operator):
preset_subdir = "fluid"
+class AddPresetManta(AddPresetBase, Operator):
+ """Add or remove a Mantaflow Preset"""
+ bl_idname = "manta.preset_add"
+ bl_label = "Add Mantaflow Preset"
+ preset_menu = "MANTA_MT_presets"
+
+ preset_defines = [
+ "manta = bpy.context.smoke"
+ ]
+
+ preset_values = [
+ "manta.domain_settings.viscosity_base",
+ "manta.domain_settings.viscosity_exponent",
+ ]
+
+ preset_subdir = "mantaflow"
+
+
class AddPresetHairDynamics(AddPresetBase, Operator):
"""Add or remove a Hair Dynamics Preset"""
bl_idname = "particle.hair_dynamics_preset_add"
@@ -742,6 +760,7 @@ classes = (
AddPresetCamera,
AddPresetCloth,
AddPresetFluid,
+ AddPresetManta,
AddPresetHairDynamics,
AddPresetInteraction,
AddPresetInterfaceTheme,
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index 68b7c5c7187..070593f1189 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -54,7 +54,7 @@ def particle_panel_poll(cls, context):
if not settings:
return False
- return settings.is_fluid is False and (engine in cls.COMPAT_ENGINES)
+ return (settings.is_fluid is False) and (settings.is_manta is False) and (engine in cls.COMPAT_ENGINES)
def particle_get_settings(context):
@@ -177,7 +177,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
layout.template_ID(context.space_data, "pin_id")
- if part.is_fluid:
+ if part.is_fluid or part.is_manta:
layout.label(text="Settings used for fluid")
return
@@ -196,12 +196,12 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
split = layout.split(factor=0.32)
col = split.column()
- if part.is_fluid is False:
+ if (part.is_fluid is False) or (part.is_manta is False):
col.label(text="Settings:")
col.label(text="Type:")
col = split.column()
- if part.is_fluid is False:
+ if (part.is_fluid is False) or (part.is_manta is False):
row = col.row()
row.enabled = particle_panel_enabled(context, psys)
row.template_ID(psys, "settings", new="particle.new")
@@ -209,6 +209,9 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel):
if part.is_fluid:
layout.label(text=iface_("%d fluid particles for this frame") % part.count, translate=False)
return
+ if part.is_manta:
+ layout.label(text=iface_("%d fluid particles for this frame") % part.count, translate=False)
+ return
row = col.row()
row.enabled = particle_panel_enabled(context, psys)
@@ -254,7 +257,7 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Pan
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list