Skip to content

Commit a45cde8

Browse files
committed
new demo version 0.7.5!
1 parent 9403e6c commit a45cde8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1228
-295
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Want to try the FLIP Fluids addon before buying the [full marketplace product](h
1111

1212
### Getting Started
1313

14-
Download the latest FLIP Fluids Demo installation file here: [FLIP_Fluids_addon_0.7.4_demo_(22_jan_2024.zip)](https://github.com/rlguy/Blender-FLIP-Fluids/releases/download/v0.7.4/FLIP_Fluids_addon_0.7.4_demo_.22_jan_2024.zip)
14+
Download the latest FLIP Fluids Demo installation file here: [FLIP_Fluids_addon_0.7.5_demo_(12_mar_2024.zip)](https://github.com/rlguy/Blender-FLIP-Fluids/releases/download/v0.7.5/FLIP_Fluids_addon_0.7.5_demo_.12_mar_2024.zip)
1515

1616
After downloading the demo addon, follow our [Installation Instructions](https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Addon-Installation-and-Uninstallation). The instructions are similar to installing any other Blender addon.
1717

cmake/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ set(CMAKE_BUILD_TYPE Release)
5353
set(FLUIDENGINE_VERSION_TYPE_IS_STABLE_BUILD TRUE)
5454
set(FLUIDENGINE_VERSION_MAJOR 0)
5555
set(FLUIDENGINE_VERSION_MINOR 7)
56-
set(FLUIDENGINE_VERSION_REVISION 4)
57-
set(FLUIDENGINE_VERSION_DATE "22-JAN-2024")
56+
set(FLUIDENGINE_VERSION_REVISION 5)
57+
set(FLUIDENGINE_VERSION_DATE "12-MAR-2024")
5858

5959
if(FLUIDENGINE_VERSION_TYPE_IS_STABLE_BUILD)
6060
set(FLUIDENGINE_VERSION_TYPE_LABEL "Demo")

src/addon/__init__.py.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
bl_info = {
18-
"name" : "FLIP Fluids Demo @FLUIDENGINE_VERSION_MAJOR@.@FLUIDENGINE_VERSION_MINOR@.@FLUIDENGINE_VERSION_REVISION@",
18+
"name" : "FLIP Fluids Demo",
1919
"description": "A FLIP Fluid Simulation Tool for Blender (v@FLUIDENGINE_VERSION_LABEL@)",
2020
"author" : "Ryan Guy & Dennis Fassbaender <support[at]flipfluids.com>",
2121
"version" : (@FLUIDENGINE_VERSION_MAJOR@, @FLUIDENGINE_VERSION_MINOR@, @FLUIDENGINE_VERSION_REVISION@),

src/addon/bake.py

+60-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import sys, os, shutil, json, traceback, math
17+
import sys, os, shutil, json, traceback, math, time
1818

1919
from .objects import flip_fluid_map
2020
from .objects import flip_fluid_geometry_database
@@ -160,7 +160,8 @@ def __extract_keyframed_mesh(object_name, frameno):
160160
raise Exception(msg)
161161

162162
tmesh = TriangleMesh.from_bobj(bobj_data)
163-
tmesh.apply_transform(__extract_transform_data(object_name, frameno))
163+
transform_data = __extract_transform_data(object_name, frameno)
164+
tmesh.apply_transform(transform_data)
164165

165166
data = __get_simulation_data()
166167
scale = data.domain_data.initialize.scale
@@ -1044,6 +1045,11 @@ def __initialize_fluid_simulation_settings(fluidsim, data):
10441045
# World Settings
10451046
world = dprops.world
10461047
fluidsim.add_body_force(__get_parameter_data(world.gravity, frameno))
1048+
fluidsim.force_field_weight_fluid_particles = __get_parameter_data(world.force_field_weight_fluid_particles, frameno)
1049+
fluidsim.force_field_weight_whitewater_foam = __get_parameter_data(world.force_field_weight_whitewater_foam, frameno)
1050+
fluidsim.force_field_weight_whitewater_bubble = __get_parameter_data(world.force_field_weight_whitewater_bubble, frameno)
1051+
fluidsim.force_field_weight_whitewater_spray = __get_parameter_data(world.force_field_weight_whitewater_spray, frameno)
1052+
fluidsim.force_field_weight_whitewater_dust = __get_parameter_data(world.force_field_weight_whitewater_dust, frameno)
10471053

10481054
# Caches created in older versions may not contain force field data. Ignore these features
10491055
# if force field data cannot be found in the cache
@@ -1295,6 +1301,9 @@ def __initialize_fluid_simulation_settings(fluidsim, data):
12951301
fluidsim.enable_asynchronous_meshing = \
12961302
__get_parameter_data(advanced.enable_asynchronous_meshing, frameno)
12971303

1304+
fluidsim.enable_fracture_optimization = \
1305+
__get_parameter_data(advanced.enable_fracture_optimization, frameno)
1306+
12981307
fluidsim.enable_static_solid_levelset_precomputation = \
12991308
__get_parameter_data(advanced.precompute_static_obstacles, frameno)
13001309

@@ -1633,15 +1642,20 @@ def __update_dynamic_force_field_mesh(animated_object, object_data):
16331642
animated_object.update_mesh_animated(mesh_previous, mesh_current, mesh_next)
16341643

16351644

1636-
def __update_animatable_inflow_properties(data, frameid):
1645+
def __update_animatable_inflow_properties(data, mesh_geometry_data, frameid):
16371646
inflow_objects = data.inflow_objects
16381647
inflow_data = data.inflow_data
16391648

16401649
for idx, inflow in enumerate(inflow_objects):
16411650
data = inflow_data[idx]
16421651

1643-
if __is_object_dynamic(data.name):
1644-
__update_dynamic_object_mesh(inflow, data)
1652+
name_slug = __get_name_slug(data.name)
1653+
object_geometry_data = mesh_geometry_data[name_slug]
1654+
if object_geometry_data["is_motion_dynamic"]:
1655+
mesh_previous = object_geometry_data["triangle_mesh_previous"]
1656+
mesh_current = object_geometry_data["triangle_mesh_current"]
1657+
mesh_next = object_geometry_data["triangle_mesh_next"]
1658+
inflow.update_mesh_animated(mesh_previous, mesh_current, mesh_next)
16451659

16461660
inflow.enable = __get_parameter_data(data.is_enabled, frameid)
16471661
inflow.set_velocity(__get_inflow_object_velocity(data, frameid))
@@ -1662,15 +1676,20 @@ def __update_animatable_inflow_properties(data, frameid):
16621676
inflow.set_source_color(__get_parameter_data(data.color, frameid))
16631677

16641678

1665-
def __update_animatable_outflow_properties(data, frameid):
1679+
def __update_animatable_outflow_properties(data, mesh_geometry_data, frameid):
16661680
outflow_objects = data.outflow_objects
16671681
outflow_data = data.outflow_data
16681682

16691683
for idx, outflow in enumerate(outflow_objects):
16701684
data = outflow_data[idx]
16711685

1672-
if __is_object_dynamic(data.name):
1673-
__update_dynamic_object_mesh(outflow, data)
1686+
name_slug = __get_name_slug(data.name)
1687+
object_geometry_data = mesh_geometry_data[name_slug]
1688+
if object_geometry_data["is_motion_dynamic"]:
1689+
mesh_previous = object_geometry_data["triangle_mesh_previous"]
1690+
mesh_current = object_geometry_data["triangle_mesh_current"]
1691+
mesh_next = object_geometry_data["triangle_mesh_next"]
1692+
outflow.update_mesh_animated(mesh_previous, mesh_current, mesh_next)
16741693

16751694
outflow.enable = __get_parameter_data(data.is_enabled, frameid)
16761695
outflow.fluid_outflow = __get_parameter_data(data.remove_fluid, frameid)
@@ -1716,7 +1735,7 @@ def __update_animatable_force_field_properties(data, frameid):
17161735
force_field.gravity_scale_width = __get_parameter_data(data.gravity_scale_width_curve, frameid)
17171736

17181737

1719-
def __update_animatable_obstacle_properties(data, frameid):
1738+
def __update_animatable_obstacle_properties(data, mesh_geometry_data, frameid):
17201739
obstacle_objects = data.obstacle_objects
17211740
obstacle_data = data.obstacle_data
17221741

@@ -1752,11 +1771,19 @@ def __update_animatable_obstacle_properties(data, frameid):
17521771

17531772
#### END WORKAROUND ####
17541773

1774+
total_update_time = 0.0
1775+
start_mesh_object = time.time()
1776+
17551777
for idx, mesh_object in enumerate(obstacle_objects):
17561778
data = obstacle_data[idx]
17571779

1758-
if __is_object_dynamic(data.name):
1759-
__update_dynamic_object_mesh(mesh_object, data)
1780+
name_slug = __get_name_slug(data.name)
1781+
object_geometry_data = mesh_geometry_data[name_slug]
1782+
if object_geometry_data["is_motion_dynamic"]:
1783+
mesh_previous = object_geometry_data["triangle_mesh_previous"]
1784+
mesh_current = object_geometry_data["triangle_mesh_current"]
1785+
mesh_next = object_geometry_data["triangle_mesh_next"]
1786+
mesh_object.update_mesh_animated(mesh_previous, mesh_current, mesh_next)
17601787

17611788
mesh_object.enable = __get_parameter_data(data.is_enabled, frameid)
17621789
mesh_object.friction = __get_parameter_data(data.friction, frameid, value_min=0.0)
@@ -2009,6 +2036,17 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
20092036
gravity = [0.0, 0.0, 0.0]
20102037
__set_body_force_property(fluidsim, gravity)
20112038

2039+
weight_fluid_particles = __get_parameter_data(world.force_field_weight_fluid_particles, frameno)
2040+
weight_whitewater_foam = __get_parameter_data(world.force_field_weight_whitewater_foam, frameno)
2041+
weight_whitewater_bubble = __get_parameter_data(world.force_field_weight_whitewater_bubble, frameno)
2042+
weight_whitewater_spray = __get_parameter_data(world.force_field_weight_whitewater_spray, frameno)
2043+
weight_whitewater_dust = __get_parameter_data(world.force_field_weight_whitewater_dust, frameno)
2044+
__set_property(fluidsim, 'force_field_weight_fluid_particles', weight_fluid_particles)
2045+
__set_property(fluidsim, 'force_field_weight_whitewater_foam', weight_whitewater_foam)
2046+
__set_property(fluidsim, 'force_field_weight_whitewater_bubble', weight_whitewater_bubble)
2047+
__set_property(fluidsim, 'force_field_weight_whitewater_spray', weight_whitewater_spray)
2048+
__set_property(fluidsim, 'force_field_weight_whitewater_dust', weight_whitewater_dust)
2049+
20122050
is_viscosity_enabled = __get_parameter_data(world.enable_viscosity, frameno)
20132051
if is_viscosity_enabled:
20142052
surface = dprops.surface
@@ -2190,6 +2228,9 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
21902228
enable_async_meshing = __get_parameter_data(advanced.enable_asynchronous_meshing, frameno)
21912229
__set_property(fluidsim, 'enable_asynchronous_meshing', enable_async_meshing)
21922230

2231+
enable_fracture_optimization = __get_parameter_data(advanced.enable_fracture_optimization, frameno)
2232+
__set_property(fluidsim, 'enable_fracture_optimization', enable_fracture_optimization)
2233+
21932234
precomp_static_sdf = __get_parameter_data(advanced.precompute_static_obstacles, frameno)
21942235
__set_property(fluidsim, 'enable_static_solid_levelset_precomputation', precomp_static_sdf)
21952236

@@ -2211,10 +2252,15 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
22112252

22122253

22132254
def __update_animatable_properties(fluidsim, data, frameno):
2214-
__update_animatable_inflow_properties(data, frameno)
2215-
__update_animatable_outflow_properties(data, frameno)
2255+
geometry_database = __get_geometry_database()
2256+
simulation_data = __get_simulation_data()
2257+
timeline_frame = __get_timeline_frame()
2258+
geometry_data = geometry_database.get_mesh_geometry_data_dict_for_frame(simulation_data, timeline_frame)
2259+
2260+
__update_animatable_inflow_properties(data, geometry_data, frameno)
2261+
__update_animatable_outflow_properties(data, geometry_data, frameno)
22162262
__update_animatable_force_field_properties(data, frameno)
2217-
__update_animatable_obstacle_properties(data, frameno)
2263+
__update_animatable_obstacle_properties(data, geometry_data, frameno)
22182264
__update_animatable_meshing_volume_properties(data, frameno)
22192265
__update_animatable_domain_properties(fluidsim, data, frameno)
22202266

src/addon/export.py

-3
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,6 @@ def add_objects_to_geometry_exporter(geometry_exporter):
416416
objects = bpy.context.scene.flip_fluid.get_simulation_objects(skip_hide_viewport=True)
417417
disable_topology_warning = dprops.advanced.disable_changing_topology_warning
418418

419-
for obj in objects:
420-
print(obj)
421-
422419
# Add regular FLIP Fluid objects
423420
for obj in objects:
424421
props = obj.flip_fluid.get_property_group()
Binary file not shown.
Binary file not shown.

src/addon/objects/flip_fluid_geometry_database.py

+165
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from .flip_fluid_geometry_export_object import GeometryExportType, MotionExportType
2020
from ..filesystem import filesystem_protection_layer as fpl
2121

22+
from ..pyfluid import TriangleMesh
23+
2224

2325
class GeometryDatabase():
2426
def __init__(self, db_filepath, clear_database=False):
@@ -598,6 +600,169 @@ def get_curve_animated(self, name_slug, frameno):
598600
return result[0]
599601

600602

603+
def get_mesh_geometry_data_dict_for_frame(self, simulation_data, frameno):
604+
cmd = """ SELECT object_id, object_slug, object_motion_type FROM object"""
605+
self._cursor.execute(cmd)
606+
result = self._cursor.fetchall()
607+
608+
geometry_data = {}
609+
object_id_to_name_slug = {}
610+
for row in result:
611+
object_id = row[0]
612+
name_slug = row[1]
613+
object_motion_type = row[2]
614+
is_static = object_motion_type == 'STATIC'
615+
is_dynamic = not is_static
616+
617+
geometry_data[name_slug] = {
618+
"object_id": object_id,
619+
"object_motion_type": object_motion_type,
620+
"is_motion_static": is_static,
621+
"is_motion_dynamic": is_dynamic,
622+
"static_bobj_data": None,
623+
"transform_previous": None,
624+
"transform_current": None,
625+
"transform_next": None,
626+
"triangle_mesh_previous": None,
627+
"triangle_mesh_current": None,
628+
"triangle_mesh_next": None,
629+
}
630+
object_id_to_name_slug[object_id] = name_slug
631+
632+
633+
# Retreive static meshes for static and keyframed objects
634+
cmd = """SELECT object_id, mesh_static_data FROM mesh_static"""
635+
self._cursor.execute(cmd)
636+
result_static_bobj_data = self._cursor.fetchall()
637+
638+
static_bobj_data = {}
639+
for row in result_static_bobj_data:
640+
object_id = row[0]
641+
bobj_data = row[1]
642+
static_bobj_data[object_id] = bobj_data
643+
644+
name_slug = object_id_to_name_slug[object_id]
645+
geometry_data[name_slug]["static_bobj_data"] = bobj_data
646+
647+
frame_previous = frameno - 1
648+
frame_current = frameno
649+
frame_next = frameno + 1
650+
651+
# Retrieve keyframed mesh transforms
652+
cmd = """
653+
SELECT object_id,
654+
m00, m01, m02, m03,
655+
m10, m11, m12, m13,
656+
m20, m21, m22, m23,
657+
m30, m31, m32, m33 FROM mesh_keyframed
658+
WHERE frame_id=?
659+
"""
660+
661+
self._cursor.execute(cmd, (frame_previous,))
662+
result_frame_previous = self._cursor.fetchall()
663+
self._cursor.execute(cmd, (frame_current,))
664+
result_frame_current = self._cursor.fetchall()
665+
self._cursor.execute(cmd, (frame_next,))
666+
result_frame_next = self._cursor.fetchall()
667+
668+
for row in result_frame_previous:
669+
object_id = row[0]
670+
transform = list(row[1:])
671+
name_slug = object_id_to_name_slug[object_id]
672+
geometry_data[name_slug]["transform_previous"] = transform
673+
674+
for row in result_frame_current:
675+
object_id = row[0]
676+
transform = list(row[1:])
677+
name_slug = object_id_to_name_slug[object_id]
678+
geometry_data[name_slug]["transform_current"] = transform
679+
680+
for row in result_frame_next:
681+
object_id = row[0]
682+
transform = list(row[1:])
683+
name_slug = object_id_to_name_slug[object_id]
684+
geometry_data[name_slug]["transform_next"] = transform
685+
686+
for name_slug, entry in geometry_data.items():
687+
if not entry["object_motion_type"] == 'KEYFRAMED':
688+
continue
689+
if entry["transform_previous"] is None:
690+
entry["transform_previous"] = entry["transform_current"]
691+
if entry["transform_next"] is None:
692+
entry["transform_next"] = entry["transform_current"]
693+
694+
# Generate keyframed triangle meshes from transforms
695+
scale = simulation_data.domain_data.initialize.scale
696+
bbox = simulation_data.domain_data.initialize.bbox
697+
for name_slug, entry in geometry_data.items():
698+
if not entry["object_motion_type"] == 'KEYFRAMED':
699+
continue
700+
701+
mesh_previous = TriangleMesh.from_bobj(entry["static_bobj_data"])
702+
mesh_current = TriangleMesh.from_bobj(entry["static_bobj_data"])
703+
mesh_next = TriangleMesh.from_bobj(entry["static_bobj_data"])
704+
mesh_previous.apply_transform(entry["transform_previous"])
705+
mesh_current.apply_transform(entry["transform_current"])
706+
mesh_next.apply_transform(entry["transform_next"])
707+
mesh_previous.translate(-bbox.x, -bbox.y, -bbox.z)
708+
mesh_current.translate(-bbox.x, -bbox.y, -bbox.z)
709+
mesh_next.translate(-bbox.x, -bbox.y, -bbox.z)
710+
mesh_previous.scale(scale)
711+
mesh_current.scale(scale)
712+
mesh_next.scale(scale)
713+
714+
entry["triangle_mesh_previous"] = mesh_previous
715+
entry["triangle_mesh_current"] = mesh_current
716+
entry["triangle_mesh_next"] = mesh_next
717+
718+
# Retrieve animated triangle meshes
719+
cmd = """SELECT object_id, mesh_animated_data FROM mesh_animated WHERE frame_id=?"""
720+
721+
self._cursor.execute(cmd, (frame_previous,))
722+
result_frame_previous = self._cursor.fetchall()
723+
self._cursor.execute(cmd, (frame_current,))
724+
result_frame_current = self._cursor.fetchall()
725+
self._cursor.execute(cmd, (frame_next,))
726+
result_frame_next = self._cursor.fetchall()
727+
728+
for row in result_frame_previous:
729+
object_id = row[0]
730+
bobj_data = row[1]
731+
name_slug = object_id_to_name_slug[object_id]
732+
mesh = TriangleMesh.from_bobj(bobj_data)
733+
mesh.translate(-bbox.x, -bbox.y, -bbox.z)
734+
mesh.scale(scale)
735+
geometry_data[name_slug]["triangle_mesh_previous"] = mesh
736+
737+
for row in result_frame_current:
738+
object_id = row[0]
739+
bobj_data = row[1]
740+
name_slug = object_id_to_name_slug[object_id]
741+
mesh = TriangleMesh.from_bobj(bobj_data)
742+
mesh.translate(-bbox.x, -bbox.y, -bbox.z)
743+
mesh.scale(scale)
744+
geometry_data[name_slug]["triangle_mesh_current"] = mesh
745+
746+
for row in result_frame_next:
747+
object_id = row[0]
748+
bobj_data = row[1]
749+
name_slug = object_id_to_name_slug[object_id]
750+
mesh = TriangleMesh.from_bobj(bobj_data)
751+
mesh.translate(-bbox.x, -bbox.y, -bbox.z)
752+
mesh.scale(scale)
753+
geometry_data[name_slug]["triangle_mesh_next"] = mesh
754+
755+
for name_slug, entry in geometry_data.items():
756+
if not entry["object_motion_type"] == 'ANIMATED':
757+
continue
758+
if entry["triangle_mesh_previous"] is None:
759+
entry["triangle_mesh_previous"] = entry["triangle_mesh_current"]
760+
if entry["triangle_mesh_next"] is None:
761+
entry["triangle_mesh_next"] = entry["triangle_mesh_current"]
762+
763+
return geometry_data
764+
765+
601766

602767

603768
###########################################################################

0 commit comments

Comments
 (0)