Skip to content

Commit 830a9fc

Browse files
committed
new demo version 0.2.0!
1 parent ff8ad98 commit 830a9fc

34 files changed

+1645
-131
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ Want to try FLIP Fluids addon before buying the full [Blender Market Product](ht
22

33
### Limitations
44

5-
- _**New:**_ Unlimited simulation frames (previous limit of 250)
6-
- _**New:**_ Unlimited number of simulation objects (previous limit of 1 per object type)
75
- Simulation meshes are watermarked with _FLIP Fluids Demo_ text
86

97
### Getting Started
108

11-
Download the latest FLIP Fluids Demo installation file here: [FLIP_Fluids_addon_0.1.0_demo_(20_aug_2021.zip)](https://github.com/rlguy/Blender-FLIP-Fluids/releases/download/0.1.0/FLIP_Fluids_addon_0.1.0_demo_.20_aug_2021.zip)
9+
Download the latest FLIP Fluids Demo installation file here: [FLIP_Fluids_addon_0.2.0_demo_(25_nov_2021.zip)](https://github.com/rlguy/Blender-FLIP-Fluids/releases/download/0.2.0/FLIP_Fluids_addon_0.2.0_demo_.25_nov_2021.zip)
1210

1311
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.
1412

15-
Get started creating your first simulation with our [beginners guide](https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Creating-Your-First-FLIP-Fluids-Simulation)!
13+
Get started creating your first simulation with our [beginners guide](https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Creating-Your-First-FLIP-Fluids-Simulation) or [video learning series](https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Video-Learning-Series)!
1614

1715
### Have any questions?
1816

cmake/CMakeLists.txt

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
SOFTWARE.
2121
]]
2222

23-
cmake_minimum_required(VERSION 2.8.9)
23+
cmake_minimum_required(VERSION 3.0)
2424

2525
function(set_output_directories DIR)
2626
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${DIR} PARENT_SCOPE)
@@ -41,13 +41,17 @@ option(WITH_OPENCL "Compile project with OpenCL features" OFF)
4141
option(WITH_ENGINE_TEST "Compile engine test executable" OFF)
4242
option(WITH_PYFLUID_MODULE "Compile pyfluid Python module" OFF)
4343

44+
if(APPLE)
45+
set(MACOSX_DEPLOYMENT_TARGET 10.10)
46+
endif()
47+
4448
project(bl_flip_fluids)
4549
set(CMAKE_BUILD_TYPE Release)
4650

4751
set(FLUIDENGINE_VERSION_MAJOR 0)
48-
set(FLUIDENGINE_VERSION_MINOR 1)
52+
set(FLUIDENGINE_VERSION_MINOR 2)
4953
set(FLUIDENGINE_VERSION_REVISION 0)
50-
set(FLUIDENGINE_VERSION_LABEL "0.1.0 Demo 20-AUG-2021")
54+
set(FLUIDENGINE_VERSION_LABEL "0.2.0 Demo 25-NOV-2021")
5155

5256
if(BUILD_DEBUG)
5357
set(FLUIDENGINE_VERSION_LABEL "${FLUIDENGINE_VERSION_LABEL} (DEBUG BUILD)")
@@ -176,7 +180,6 @@ if(DISTRIBUTE_SOURCE)
176180
set(SOURCE_COPY_PATHS
177181
"${CMAKE_SOURCE_DIR}/src"
178182
"${CMAKE_SOURCE_DIR}/.gitignore"
179-
"${CMAKE_SOURCE_DIR}/CMakeLists.txt"
180183
"${CMAKE_SOURCE_DIR}/LICENSE_GPLv3.md"
181184
"${CMAKE_SOURCE_DIR}/LICENSE_MIT.md"
182185
"${CMAKE_SOURCE_DIR}/LICENSE_Standard_Royalty_Free.md"

src/addon/__init__.py.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bl_info = {
2323
"location" : "Properties > Physics > FLIP Fluid",
2424
"warning" : "",
2525
"wiki_url" : "https://github.com/rlguy/Blender-FLIP-Fluids/wiki",
26-
"tracker_url" : "https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Guidelines-for-Reporting-Bugs-and-Issues",
26+
"doc_url" : "https://github.com/rlguy/Blender-FLIP-Fluids/wiki",
2727
"category" : "Animation"
2828
}
2929

src/addon/bake.py

+47-24
Original file line numberDiff line numberDiff line change
@@ -457,17 +457,24 @@ def __check_bake_cancelled(bakedata):
457457
return False
458458

459459

460-
def __get_parameter_data(parameter, frameno = 0):
460+
def __get_parameter_data(parameter, frameno=0, value_min=None, value_max=None):
461461
if parameter is None:
462462
raise IndexError()
463463

464-
if not hasattr(parameter, 'is_animated'):
465-
return parameter
466-
467-
if parameter.is_animated:
468-
return parameter.data[frameno]
464+
if hasattr(parameter, 'data') and hasattr(parameter, 'is_animated'):
465+
if parameter.is_animated:
466+
value = parameter.data[frameno]
467+
else:
468+
value = parameter.data
469469
else:
470-
return parameter.data
470+
value = parameter
471+
472+
if value_min is not None:
473+
value = max(value, value_min)
474+
if value_max is not None:
475+
value = min(value, value_max)
476+
477+
return value
471478

472479

473480
def __get_limit_behaviour_enum(b):
@@ -514,13 +521,15 @@ def __get_obstacle_meshing_offset(obstacle_meshing_mode):
514521
def __get_viscosity_value(world_data, frameno):
515522
base = __get_parameter_data(world_data.viscosity, frameno)
516523
exp = __get_parameter_data(world_data.viscosity_exponent, frameno)
517-
return base * (10**(-exp))
524+
viscosity = max(base * (10**(-exp)), 0.0)
525+
return viscosity
518526

519527

520528
def __get_surface_tension_value(world_data, frameno):
521529
base = __get_parameter_data(world_data.surface_tension, frameno)
522530
exp = __get_parameter_data(world_data.surface_tension_exponent, frameno)
523-
return world_data.native_surface_tension_scale * base * (10**(-exp))
531+
value = world_data.native_surface_tension_scale * base * (10**(-exp))
532+
return max(value, 0.0)
524533

525534

526535
def __read_save_state_file_data(file_data_path, start_byte, end_byte):
@@ -756,9 +765,9 @@ def __load_save_state_data(fluidsim, data, cache_directory, savestate_id):
756765

757766
init_data = data.domain_data.initialize
758767
if init_data.delete_outdated_savestates:
759-
__delete_outdated_savestates(cache_directory, savestate_id)
768+
__delete_outdated_savestates(cache_directory, autosave_info["frame"])
760769
if init_data.delete_outdated_meshes:
761-
__delete_outdated_meshes(cache_directory, savestate_id)
770+
__delete_outdated_meshes(cache_directory, autosave_info["frame"])
762771

763772

764773
def __initialize_fluid_simulation_settings(fluidsim, data):
@@ -947,14 +956,17 @@ def __initialize_fluid_simulation_settings(fluidsim, data):
947956
surface_tension_number = mincfl + (1.0 - accuracy_pct) * (maxcfl - mincfl)
948957
fluidsim.surface_tension_condition_number = surface_tension_number
949958

959+
st_solver_mode = __get_parameter_data(world.surface_tension_solver_method, frameno)
960+
fluidsim.enable_smooth_surface_tension_kernel = st_solver_mode == 'SURFACE_TENSION_SOLVER_METHOD_SMOOTH'
961+
950962
is_sheet_seeding_enabled = __get_parameter_data(world.enable_sheet_seeding, frameno)
951963
if is_sheet_seeding_enabled:
952964
fluidsim.enable_sheet_seeding = is_sheet_seeding_enabled
953-
fluidsim.sheet_fill_rate = __get_parameter_data(world.sheet_fill_rate, frameno)
954-
threshold = __get_parameter_data(world.sheet_fill_threshold, frameno)
965+
fluidsim.sheet_fill_rate = __get_parameter_data(world.sheet_fill_rate, frameno, value_min=0.0, value_max=1.0)
966+
threshold = __get_parameter_data(world.sheet_fill_threshold, frameno, value_min=0.0, value_max=1.0)
955967
fluidsim.sheet_fill_threshold = threshold - 1
956968

957-
friction = __get_parameter_data(world.boundary_friction, frameno)
969+
friction = __get_parameter_data(world.boundary_friction, frameno, value_min=0.0, value_max=1.0)
958970
fluidsim.boundary_friction = friction
959971

960972
# Surface Settings
@@ -1471,11 +1483,11 @@ def __update_animatable_obstacle_properties(data, frameid):
14711483
__update_dynamic_object_mesh(mesh_object, data)
14721484

14731485
mesh_object.enable = __get_parameter_data(data.is_enabled, frameid)
1474-
mesh_object.friction = __get_parameter_data(data.friction, frameid)
1475-
mesh_object.whitewater_influence = __get_parameter_data(data.whitewater_influence, frameid)
1476-
mesh_object.dust_emission_strength = __get_parameter_data(data.dust_emission_strength, frameid)
1477-
mesh_object.sheeting_strength = __get_parameter_data(data.sheeting_strength, frameid)
1478-
mesh_object.mesh_expansion = __get_parameter_data(data.mesh_expansion, frameid)
1486+
mesh_object.friction = __get_parameter_data(data.friction, frameid, value_min=0.0)
1487+
mesh_object.whitewater_influence = __get_parameter_data(data.whitewater_influence, frameid, value_min=0.0)
1488+
mesh_object.dust_emission_strength = __get_parameter_data(data.dust_emission_strength, frameid, value_min=0.0)
1489+
mesh_object.sheeting_strength = __get_parameter_data(data.sheeting_strength, frameid, value_min=0.0)
1490+
mesh_object.mesh_expansion = __get_parameter_data(data.mesh_expansion, frameid, value_min=0.0)
14791491

14801492

14811493
def __update_animatable_meshing_volume_properties(data, frameid):
@@ -1494,7 +1506,12 @@ def __update_animatable_meshing_volume_properties(data, frameid):
14941506
volume_object.update_mesh_animated(mesh_previous, mesh_current, mesh_next)
14951507

14961508

1497-
def __set_property(obj, pname, value):
1509+
def __set_property(obj, pname, value, value_min=None, value_max=None):
1510+
if value_min is not None:
1511+
value = max(value, value_min)
1512+
if value_max is not None:
1513+
value = min(value, value_max)
1514+
14981515
eps = 1e-6
14991516
old_value = getattr(obj, pname)
15001517
if isinstance(value, list):
@@ -1713,11 +1730,11 @@ def __update_animatable_domain_properties(fluidsim, data, frameno):
17131730
sheet_fill_rate = __get_parameter_data(world.sheet_fill_rate, frameno)
17141731
threshold = __get_parameter_data(world.sheet_fill_threshold, frameno)
17151732
__set_property(fluidsim, 'enable_sheet_seeding', is_sheet_seeding_enabled)
1716-
__set_property(fluidsim, 'sheet_fill_rate', sheet_fill_rate)
1717-
__set_property(fluidsim, 'sheet_fill_threshold', threshold - 1)
1733+
__set_property(fluidsim, 'sheet_fill_rate', sheet_fill_rate, value_min=0, value_max=1.0)
1734+
__set_property(fluidsim, 'sheet_fill_threshold', threshold - 1, value_min=0, value_max=1.0)
17181735

17191736
friction = __get_parameter_data(world.boundary_friction, frameno)
1720-
__set_property(fluidsim, 'boundary_friction', friction)
1737+
__set_property(fluidsim, 'boundary_friction', friction, value_min=0, value_max=1.0)
17211738

17221739
# Surface Settings
17231740

@@ -2451,8 +2468,11 @@ def bake(datafile, cache_directory, bakedata, savestate_id=None, bake_retries=0)
24512468

24522469
error_string = str(e)
24532470
errmsg = error_string
2471+
do_not_attempt_relaunch = False
24542472
if "std::bad_alloc" in errmsg:
24552473
errmsg = "Out of memory. "
2474+
elif "No space left on device" in errmsg:
2475+
do_not_attempt_relaunch = True
24562476
elif not errmsg:
24572477
errmsg = "Unknown error. "
24582478
if not errmsg.endswith(". "):
@@ -2469,10 +2489,13 @@ def bake(datafile, cache_directory, bakedata, savestate_id=None, bake_retries=0)
24692489
print("\nThank you for using FLIP Fluids!")
24702490
print("------------------------------------------------------------")
24712491

2472-
if retry_num == max_baking_retries:
2492+
if retry_num == max_baking_retries or do_not_attempt_relaunch:
24732493
bakedata.error_message = errmsg
24742494
break
24752495
else:
2496+
# Setting to a negative value will default to the most recent savestate on the next attempt.
2497+
savestate_id = -1
2498+
24762499
retry_msg = "Attempting to re-launch bake... "
24772500
retry_msg += "(retry attempt " + str(retry_num + 1) + "/" + str(max_baking_retries) + ")"
24782501
print(retry_msg)

src/addon/objects/flip_fluid_cache.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ def initialize_cache_object(self):
193193
# Motion blur not supported. Leaving motion blur enabled can cause
194194
# slow render in versions of Blender 2.91+. Workaround is to
195195
# automatically disable motion blur on the object.
196-
cache_object.cycles.use_motion_blur = False
196+
try:
197+
# Cycles may not be enabled in the user's preferences
198+
cache_object.cycles.use_motion_blur = False
199+
except:
200+
pass
197201

198202
self._initialize_cache_object_octane(cache_object)
199203

@@ -337,6 +341,9 @@ def _update_velocity_attribute(self, frameno):
337341
frame_string = self._frame_number_to_string(frameno)
338342
velocity_data = self._import_velocity_attribute_data(frameno)
339343

344+
if not velocity_data:
345+
return
346+
340347
attribute_name = "flip_velocity"
341348
mesh = cache_object.data
342349
try:
@@ -357,6 +364,9 @@ def _update_speed_attribute(self, frameno):
357364
frame_string = self._frame_number_to_string(frameno)
358365
speed_data = self._import_speed_attribute_data(frameno)
359366

367+
if not speed_data:
368+
return
369+
360370
attribute_name = "flip_speed"
361371
mesh = cache_object.data
362372
try:
@@ -377,6 +387,9 @@ def _update_age_attribute(self, frameno):
377387
frame_string = self._frame_number_to_string(frameno)
378388
age_data = self._import_age_attribute_data(frameno)
379389

390+
if not age_data:
391+
return
392+
380393
attribute_name = "flip_age"
381394
mesh = cache_object.data
382395
try:
@@ -397,6 +410,9 @@ def _update_color_attribute(self, frameno):
397410
frame_string = self._frame_number_to_string(frameno)
398411
color_data = self._import_color_attribute_data(frameno)
399412

413+
if not color_data:
414+
return
415+
400416
attribute_name = "flip_color"
401417
mesh = cache_object.data
402418
try:
@@ -417,6 +433,9 @@ def _update_source_id_attribute(self, frameno):
417433
frame_string = self._frame_number_to_string(frameno)
418434
source_id_data = self._import_source_id_attribute_data(frameno)
419435

436+
if not source_id_data:
437+
return
438+
420439
attribute_name = "flip_source_id"
421440
mesh = cache_object.data
422441
try:
@@ -616,7 +635,11 @@ def initialize_duplivert_object(self, vertices=[], polygons=[], scale=1.0, insta
616635
# Motion blur not supported. Leaving motion blur enabled can cause
617636
# slow render in versions of Blender 2.91+. Workaround is to
618637
# automatically disable motion blur on the object.
619-
duplivert_object.cycles.use_motion_blur = False
638+
try:
639+
# Cycles may not be enabled in the user's preferences
640+
duplivert_object.cycles.use_motion_blur = False
641+
except:
642+
pass
620643

621644
self.duplivert_object = duplivert_object
622645

src/addon/operators/bake_operators.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ def is_bake_operator_running():
4141
return _IS_BAKE_OPERATOR_RUNNING
4242

4343

44-
def _update_stats(context):
44+
def update_stats(context=None):
45+
if context is None:
46+
context = bpy.context
47+
4548
dprops = bpy.context.scene.flip_fluid.get_domain_properties()
4649
cache_dir = dprops.cache.get_cache_abspath()
4750
statsfilepath = os.path.join(cache_dir, dprops.stats.stats_filename)
4851
if not os.path.isfile(statsfilepath):
49-
with open(statsfilepath, 'w', encoding='utf-8') as f:
50-
f.write(json.dumps({}, sort_keys=True, indent=4))
52+
try:
53+
# Case that the cache directory path is not valid
54+
with open(statsfilepath, 'w', encoding='utf-8') as f:
55+
f.write(json.dumps({}, sort_keys=True, indent=4))
56+
except:
57+
return
5158

5259
temp_dir = os.path.join(cache_dir, "temp")
5360
match_str = "framestats" + "[0-9]"*6 + ".data"
@@ -164,7 +171,7 @@ def _launch_thread(self):
164171

165172

166173
def _update_stats(self, context):
167-
_update_stats(context)
174+
update_stats(context)
168175

169176

170177
def _update_status(self, context):
@@ -443,7 +450,7 @@ def _export_simulation_data(self, context):
443450

444451

445452
def _update_simulation_stats(self, context):
446-
_update_stats(context)
453+
update_stats(context)
447454

448455

449456
def _run_fluid_simulation(self, context):

src/addon/operators/draw_grid_operators.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ def draw_callback_2d(self, context):
242242
xstart = 50
243243

244244
font_id = 0
245+
try:
246+
# Not all Blender versions have functionality to set font color with this method
247+
blf.color(font_id, 1.0, 1.0, 1.0, 1.0)
248+
except:
249+
pass
245250
if dprops.debug.grid_display_mode == 'GRID_DISPLAY_SIMULATION':
246251
blf.size(font_id, 20, 72)
247252
blf.position(font_id, xstart, height - 50, 0)
@@ -258,10 +263,10 @@ def draw_callback_2d(self, context):
258263
blf.draw(font_id, "Grid Dimensions: " + str(dimx) + "m x " + str(dimy) + "m x " + str(dimz) + "m")
259264

260265
blf.position(font_id, xstart + 10, height - 130, 0)
261-
blf.draw(font_id, "Grid Cell Count: " + format(isize*jsize*ksize, ",").replace(",", " "))
266+
blf.draw(font_id, "Voxel Count: " + format(isize*jsize*ksize, ",").replace(",", " "))
262267

263268
blf.position(font_id, xstart + 10, height - 155, 0)
264-
blf.draw(font_id, "Grid Cell Width: " + str(round(simulation_dx, 4)) + "m")
269+
blf.draw(font_id, "Voxel Width: " + str(round(simulation_dx, 4)) + "m")
265270
elif dprops.debug.grid_display_mode == 'GRID_DISPLAY_MESH':
266271
if dprops.surface.compute_chunk_mode == 'COMPUTE_CHUNK_MODE_AUTO':
267272
compute_chunks = dprops.surface.compute_chunks_auto
@@ -286,10 +291,10 @@ def draw_callback_2d(self, context):
286291
num_cells_str = format(num_cells, ",").replace(",", " ")
287292
chunk_cells_str = format(math.ceil(num_cells / compute_chunks), ",").replace(",", " ")
288293
blf.position(font_id, xstart + 10, height - 155, 0)
289-
blf.draw(font_id, "Grid Cell Count: " + num_cells_str + " (" + chunk_cells_str + " / chunk)")
294+
blf.draw(font_id, "Voxel Count: " + num_cells_str + " (" + chunk_cells_str + " / chunk)")
290295

291296
blf.position(font_id, xstart + 10, height - 180, 0)
292-
blf.draw(font_id, "Grid Cell Width: " + str(round(simulation_dx, 4)))
297+
blf.draw(font_id, "Voxel Width: " + str(round(simulation_dx, 4)))
293298
elif dprops.debug.grid_display_mode == 'GRID_DISPLAY_PREVIEW':
294299
blf.size(font_id, 20, 72)
295300
blf.position(font_id, xstart, height - 50, 0)
@@ -302,7 +307,7 @@ def draw_callback_2d(self, context):
302307
num_cells = isize*jsize*ksize
303308
num_cells_str = format(num_cells, ",").replace(",", " ")
304309
blf.position(font_id, xstart + 10, height - 105, 0)
305-
blf.draw(font_id, "Grid Cell Width: " + str(round(simulation_dx, 4)))
310+
blf.draw(font_id, "Voxel Width: " + str(round(simulation_dx, 4)))
306311
elif dprops.debug.grid_display_mode == 'GRID_DISPLAY_FORCE_FIELD':
307312
blf.size(font_id, 20, 72)
308313
blf.position(font_id, xstart, height - 50, 0)
@@ -318,7 +323,7 @@ def draw_callback_2d(self, context):
318323
num_cells = isize*jsize*ksize
319324
num_cells_str = format(num_cells, ",").replace(",", " ")
320325
blf.position(font_id, xstart + 10, height - 130, 0)
321-
blf.draw(font_id, "Grid Cell Width: " + str(round(simulation_dx, 4)))
326+
blf.draw(font_id, "Voxel Width: " + str(round(simulation_dx, 4)))
322327

323328

324329
def draw_callback_3d(self, context):

0 commit comments

Comments
 (0)