Skip to content

Commit

Permalink
new demo version 0.8.2!
Browse files Browse the repository at this point in the history
  • Loading branch information
rlguy committed Oct 16, 2024
1 parent 4d5ab9a commit f1c1585
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Want to try the FLIP Fluids addon before buying the [full marketplace product](h

### Getting Started

1. **Download** the latest FLIP Fluids Demo: [FLIP_Fluids_addon_0.8.1_demo_(16_jul_2024.zip)](https://github.com/rlguy/Blender-FLIP-Fluids/releases/download/v0.8.1/FLIP_Fluids_addon_0.8.1_demo_.16_jul_2024.zip)
1. **Download** the latest FLIP Fluids Demo: [FLIP_Fluids_addon_0.8.2_demo_(16_oct_2024.zip)](https://github.com/rlguy/Blender-FLIP-Fluids/releases/download/v0.8.2/FLIP_Fluids_addon_0.8.2_demo_.16_oct_2024.zip)
2. **Install** the FLIP Fluids Demo: [Installation Instructions](https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Addon-Installation-and-Uninstallation)
3. **Get Started** with creating your first FLIP Fluids addon simulation:
- [Video Learning Series](https://github.com/rlguy/Blender-FLIP-Fluids/wiki/Video-Learning-Series)
Expand Down
4 changes: 2 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ set(CMAKE_BUILD_TYPE Release)
set(FLUIDENGINE_VERSION_TYPE_IS_STABLE_BUILD TRUE)
set(FLUIDENGINE_VERSION_MAJOR 0)
set(FLUIDENGINE_VERSION_MINOR 8)
set(FLUIDENGINE_VERSION_REVISION 1)
set(FLUIDENGINE_VERSION_DATE "16-JUL-2024")
set(FLUIDENGINE_VERSION_REVISION 2)
set(FLUIDENGINE_VERSION_DATE "18-OCT-2024")

if(FLUIDENGINE_VERSION_TYPE_IS_STABLE_BUILD)
set(FLUIDENGINE_VERSION_TYPE_LABEL "Demo")
Expand Down
9 changes: 8 additions & 1 deletion src/addon/objects/flip_fluid_geometry_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def get_curve_animated(self, name_slug, frameno):


def get_mesh_geometry_data_dict_for_frame(self, simulation_data, frameno):
cmd = """ SELECT object_id, object_slug, object_motion_type FROM object"""
cmd = """ SELECT object_id, object_slug, object_motion_type, export_mesh FROM object"""
self._cursor.execute(cmd)
result = self._cursor.fetchall()

Expand All @@ -611,6 +611,13 @@ def get_mesh_geometry_data_dict_for_frame(self, simulation_data, frameno):
object_id = row[0]
name_slug = row[1]
object_motion_type = row[2]
export_mesh = row[3]

if not export_mesh:
# Object could be a centroid, vertices, axis, or curve
# This method is only for retrieving mesh type data
continue

is_static = object_motion_type == 'STATIC'
is_dynamic = not is_static

Expand Down
40 changes: 35 additions & 5 deletions src/addon/operators/command_line_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,36 @@ def get_blender_app_binary_path_windows():
return blender_exe_path


def launch_command_windows(command_list, command_text, script_prefix_string, keep_window_open=True):
# Launch command on Windows OS using subprocess.call().
# If the command list contains an argument with a special character that
# subprocess.call cannot handle, write the command to a batch file and
# launch using os.startfile.

special_characters = ["&"]
valid_command_list = True
for arg in command_list:
for ch in special_characters:
if ch in arg:
valid_command_list = False
break

if valid_command_list:
subprocess.call(command_list, shell=True)
else:
bat_text = "echo off\nchcp 65001\n"
bat_text += command_text + "\n"
if keep_window_open:
bat_text += "cmd /k\n"

script_name = script_prefix_string + bpy.path.basename(bpy.context.blend_data.filepath) + ".bat"
script_filepath = os.path.join(os.path.dirname(bpy.data.filepath), script_name)
with open(script_filepath, 'w') as f:
f.write(bat_text)

os.startfile(script_filepath)


def launch_command_darwin_or_linux(command_text, script_prefix_string):
script_text = "#!/bin/bash\n" + command_text
script_name = script_prefix_string + bpy.path.basename(bpy.context.blend_data.filepath) + ".sh"
Expand Down Expand Up @@ -442,7 +472,7 @@ def execute(self, context):
if system == "Windows":
if vcu.get_addon_preferences().cmd_bake_max_attempts == 0:
# Launch with a single command
subprocess.call(command_list, shell=True)
launch_command_windows(command_list, command_text, "BAKE_")
else:
cmd_bake_script_filepath = self.generate_bake_batch_file()
os.startfile(cmd_bake_script_filepath)
Expand Down Expand Up @@ -546,7 +576,7 @@ def execute(self, context):

system = platform.system()
if system == "Windows":
subprocess.call(command_list, shell=True)
launch_command_windows(command_list, command_text, "RENDER_ANIMATION_")
elif system == "Darwin" or system == "Linux":
launch_command_darwin_or_linux(command_text, "RENDER_ANIMATION_")

Expand Down Expand Up @@ -655,7 +685,7 @@ def execute(self, context):

system = platform.system()
if system == "Windows":
subprocess.call(command_list, shell=True)
launch_command_windows(command_list, command_text, "RENDER_FRAME_", keep_window_open=not hprops.cmd_close_window_after_render)
elif system == "Darwin" or system == "Linux":
command_text = "\"" + bpy.app.binary_path + "\" --background \"" + bpy.data.filepath + "\" --python \"" + script_path + "\"" + " -- " + frame_string + " " + open_image_after
launch_command_darwin_or_linux(command_text, "RENDER_FRAME_")
Expand Down Expand Up @@ -734,7 +764,7 @@ def execute(self, context):

system = platform.system()
if system == "Windows":
subprocess.call(command_list, shell=True)
launch_command_windows(command_list, command_text, "ALEMBIC_EXPORT_")
elif system == "Darwin" or system == "Linux":
command_text = "\"" + bpy.app.binary_path + "\" --background \"" + bpy.data.filepath + "\" --python \"" + script_path + "\""
launch_command_darwin_or_linux(command_text, "ALEMBIC_EXPORT_")
Expand Down Expand Up @@ -1106,7 +1136,7 @@ def execute(self, context):

system = platform.system()
if system == "Windows":
subprocess.call(command_list, shell=True)
launch_command_windows(command_list, command_text, "RENDER_PASS_ANIMATION")
elif system == "Darwin" or system == "Linux":
command_text = "\"" + bpy.app.binary_path + "\" --background \"" + bpy.data.filepath + "\" --python \"" + script_path + "\""
launch_command_darwin_or_linux(command_text, "RENDER_PASS_ANIMATION_")
Expand Down
2 changes: 1 addition & 1 deletion src/addon/operators/preferences_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class FLIPFluidInstallMixboxPlugin(bpy.types.Operator, ImportHelper):

filename_ext = "*.plugin"
filter_glob = StringProperty(
default="*.plugin",
default="*.plugin;*.zip",
options={'HIDDEN'},
maxlen=255,
)
Expand Down
4 changes: 2 additions & 2 deletions src/addon/properties/domain_whitewater_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ class DomainWhitewaterProperties(bpy.types.PropertyGroup):
" particles to prevent exceeding this limit. If set to 0, the"
" solver will not limit the number of whitewater particles,"
" however this may require large amounts of storage space depending"
" on the simulation",
min=0, max=2000,
" on the simulation and is not recommended",
min=0, max=357,
default=12,
precision=2,
); exec(conv("max_whitewater_particles"))
Expand Down
2 changes: 2 additions & 0 deletions src/addon/properties/flip_fluid_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def get_force_field_objects(self, skip_hide_viewport=False):
def get_simulation_objects(self, skip_hide_viewport=False):
objects = []
for obj in vcu.get_all_scene_objects():
if obj.flip_fluid.object_type == 'TYPE_NONE':
continue
if not obj.flip_fluid.is_active:
continue
if skip_hide_viewport and obj.hide_viewport:
Expand Down
5 changes: 5 additions & 0 deletions src/addon/resources/command_line_scripts/alembic_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ def get_alembic_output_filepath():

print("\n*** Preparing Alembic Export ***\n")

if bpy.context.mode != 'OBJECT':
# Meshes can only be exported in Object Mode
bpy.ops.object.mode_set(mode='OBJECT')
print("Viewport set to Object Mode.\n")

retval = check_cache_exists()
if not retval:
exit()
Expand Down
19 changes: 14 additions & 5 deletions src/addon/resources/command_line_scripts/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ def play_sound(json_audio_filepath, block=False):
if not (bpy.app.version >= (2, 80, 0)):
# aud not supported in Blender 2.79 or lower
return

try:
prefs = bpy.context.preferences.addons["flip_fluids_addon"].preferences
if bpy.app.version >= (4, 2, 0):
for module in bpy.context.preferences.addons:
module_name = module.module
if module_name.endswith("flip_fluids_addon"):
prefs = bpy.context.preferences.addons[module_name].preferences
print(prefs)
break
else:
prefs = bpy.context.preferences.addons["flip_fluids_addon"].preferences
except:
print("FLIP Fluids: Unable to locate addon preferences")
return
print("FLIP Fluids: Unable to locate addon preferences")
return

if not prefs.enable_bake_alarm:
return
return

import aud

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ def play_sound(json_audio_filepath, block=False):
return

try:
prefs = bpy.context.preferences.addons["flip_fluids_addon"].preferences
if bpy.app.version >= (4, 2, 0):
for module in bpy.context.preferences.addons:
module_name = module.module
if module_name.endswith("flip_fluids_addon"):
prefs = bpy.context.preferences.addons[module_name].preferences
print(prefs)
break
else:
prefs = bpy.context.preferences.addons["flip_fluids_addon"].preferences
except:
print("FLIP Fluids: Unable to locate addon preferences")
return
print("FLIP Fluids: Unable to locate addon preferences")
return

if not prefs.enable_bake_alarm:
return
return

import aud

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ def play_sound(json_audio_filepath, block=False):
return

try:
prefs = bpy.context.preferences.addons["flip_fluids_addon"].preferences
if bpy.app.version >= (4, 2, 0):
for module in bpy.context.preferences.addons:
module_name = module.module
if module_name.endswith("flip_fluids_addon"):
prefs = bpy.context.preferences.addons[module_name].preferences
print(prefs)
break
else:
prefs = bpy.context.preferences.addons["flip_fluids_addon"].preferences
except:
print("FLIP Fluids: Unable to locate addon preferences")
return

if not prefs.enable_bake_alarm:
return

Expand Down
2 changes: 1 addition & 1 deletion src/addon/utils/installation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
IS_INSTALLATION_COMPLETE = False
IS_STABLE_BUILD = True

IS_MIXBOX_SUPPORTED = False
IS_MIXBOX_SUPPORTED = True
IS_MIXBOX_INSTALLATION_COMPLETE = False
MIXBOX_BOOST_FACTOR = 1.2

Expand Down
58 changes: 30 additions & 28 deletions src/engine/diffuseparticlesimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void DiffuseParticleSimulation::setMaxNumDiffuseParticles(int n) {
FLUIDSIM_ASSERT(n >= 0);
_maxNumDiffuseParticles = n;
if (n == 0) {
_maxNumDiffuseParticles = std::numeric_limits<unsigned int>::max();
_maxNumDiffuseParticles = _maxNumDiffuseParticlesLimit;
}
}

Expand Down Expand Up @@ -759,6 +759,7 @@ void DiffuseParticleSimulation::getSprayParticleFileDataWWP(std::vector<char> &d
std::vector<vmath::vec3> *particlePositions;
std::vector<unsigned char> *particleIds;
std::vector<char> *particleTypes;

_diffuseParticles.getAttributeValues("POSITION", particlePositions);
_diffuseParticles.getAttributeValues("ID", particleIds);
_diffuseParticles.getAttributeValues("TYPE", particleTypes);
Expand Down Expand Up @@ -2896,13 +2897,14 @@ void DiffuseParticleSimulation::_getDiffuseParticleFileDataWWP(std::vector<vmath
std::vector<char> &data) {
FLUIDSIM_ASSERT(positions.size() == ids.size())

std::vector<int> idcounts(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idcounts(_diffuseParticleIDLimit, 0);
for (size_t i = 0; i < ids.size(); i++) {
idcounts[(int)ids[i]]++;
}

std::vector<int> idBinIndices(_diffuseParticleIDLimit, 0);
std::vector<int> idData(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idBinIndices(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idData(_diffuseParticleIDLimit, 0);

int currentBinIndex = 0;
for (size_t i = 0; i < idcounts.size(); i++) {
idBinIndices[i] = currentBinIndex;
Expand All @@ -2916,16 +2918,16 @@ void DiffuseParticleSimulation::_getDiffuseParticleFileDataWWP(std::vector<vmath
idBinIndices[ids[i]]++;
}

int idDataSize = (int)idData.size() * sizeof(int);
int numVertices = (int)positions.size();
int vertexDataSize = 3 * numVertices * sizeof(float);
int dataSize = idDataSize + vertexDataSize;
unsigned int idDataSize = (unsigned int)idData.size() * sizeof(int);
unsigned int numVertices = (unsigned int)positions.size();
unsigned int vertexDataSize = 3 * numVertices * sizeof(float);
unsigned int dataSize = idDataSize + vertexDataSize;

data.clear();
data.resize(dataSize);
data.shrink_to_fit();

int byteOffset = 0;
unsigned int byteOffset = 0;
std::memcpy(data.data() + byteOffset, (char *)idData.data(), idDataSize);
byteOffset += idDataSize;

Expand All @@ -2938,36 +2940,36 @@ void DiffuseParticleSimulation::_getDiffuseParticleFileDataWWI(std::vector<int>
std::vector<char> &data) {
FLUIDSIM_ASSERT(intvalues.size() == ids.size())

std::vector<int> idcounts(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idcounts(_diffuseParticleIDLimit, 0);
for (size_t i = 0; i < ids.size(); i++) {
idcounts[(int)ids[i]]++;
idcounts[(unsigned int)ids[i]]++;
}

std::vector<int> idBinIndices(_diffuseParticleIDLimit, 0);
std::vector<int> idData(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idBinIndices(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idData(_diffuseParticleIDLimit, 0);
int currentBinIndex = 0;
for (size_t i = 0; i < idcounts.size(); i++) {
idBinIndices[i] = currentBinIndex;
currentBinIndex += idcounts[i];
idData[i] = currentBinIndex - 1;
}

std::vector<int> intData(intvalues.size());
std::vector<unsigned int> intData(intvalues.size());
for (size_t i = 0; i < intvalues.size(); i++) {
intData[idBinIndices[ids[i]]] = intvalues[i];
idBinIndices[ids[i]]++;
}

int idDataSize = (int)idData.size() * sizeof(int);
int numVertices = (int)intvalues.size();
int intDataSize = numVertices * sizeof(int);
int dataSize = idDataSize + intDataSize;
unsigned int idDataSize = (unsigned int)idData.size() * sizeof(int);
unsigned int numVertices = (unsigned int)intvalues.size();
unsigned int intDataSize = numVertices * sizeof(int);
unsigned int dataSize = idDataSize + intDataSize;

data.clear();
data.resize(dataSize);
data.shrink_to_fit();

int byteOffset = 0;
unsigned int byteOffset = 0;
std::memcpy(data.data() + byteOffset, (char *)idData.data(), idDataSize);
byteOffset += idDataSize;

Expand All @@ -2980,13 +2982,13 @@ void DiffuseParticleSimulation::_getDiffuseParticleFileDataWWF(std::vector<float
std::vector<char> &data) {
FLUIDSIM_ASSERT(floatvalues.size() == ids.size())

std::vector<int> idcounts(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idcounts(_diffuseParticleIDLimit, 0);
for (size_t i = 0; i < ids.size(); i++) {
idcounts[(int)ids[i]]++;
idcounts[(unsigned int)ids[i]]++;
}

std::vector<int> idBinIndices(_diffuseParticleIDLimit, 0);
std::vector<int> idData(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idBinIndices(_diffuseParticleIDLimit, 0);
std::vector<unsigned int> idData(_diffuseParticleIDLimit, 0);
int currentBinIndex = 0;
for (size_t i = 0; i < idcounts.size(); i++) {
idBinIndices[i] = currentBinIndex;
Expand All @@ -3000,16 +3002,16 @@ void DiffuseParticleSimulation::_getDiffuseParticleFileDataWWF(std::vector<float
idBinIndices[ids[i]]++;
}

int idDataSize = (int)idData.size() * sizeof(int);
int numVertices = (int)floatvalues.size();
int intDataSize = numVertices * sizeof(int);
int dataSize = idDataSize + intDataSize;
unsigned int idDataSize = (int)idData.size() * sizeof(int);
unsigned int numVertices = (int)floatvalues.size();
unsigned int intDataSize = numVertices * sizeof(int);
unsigned int dataSize = idDataSize + intDataSize;

data.clear();
data.resize(dataSize);
data.shrink_to_fit();

int byteOffset = 0;
unsigned int byteOffset = 0;
std::memcpy(data.data() + byteOffset, (char *)idData.data(), idDataSize);
byteOffset += idDataSize;

Expand Down
Loading

0 comments on commit f1c1585

Please sign in to comment.