Fluid: Improved OpenVDB support for fluid caches

This commit makes uses of the new OpenVDB IO in Mantaflow (introduced in 781f783a66ac).

From now on, fluid cache files in OpenVDB format will contain a list of grids per frame (before: one .vdb file per grid per frame). Besides regular grids, particle systems are also stored using OpenVDBs PointGrid data structures.

All older cache formats will remain fully functional:
- Uni caches (.uni) files are still available from the UI and can be used as before
- Raw caches (.raw) are no longer available from the UI, but loading them is still possible
- Old OpenVDB caches (one .vdb per grid) can no longer be baked either, but loading them is still possible.

It is also no longer possible to choose file formats for 'Noise' and 'Particles'. Instead there are now options to set the file format for 'Volumetric' and for 'Mesh' data.

Known issues (planned to be resolved soon):
- OpenVDB files are currently not taking into consideration the clipping value (FluidDomainSettings). Empty cells are therefore being written too. Depending on the scene, this can make file sizes unnecessarily large.
- Domains are not being exported at their world position. Instead they are always clipped to the origin.
This commit is contained in:
Sebastián Barschkis 2020-06-24 15:30:49 +02:00
parent 9fe64948ab
commit 9951858942
Notes: blender-bot 2023-02-21 17:59:30 +01:00
Referenced by commit 2036b9771e, Fluid: Fix typos from OpenVDB update
Referenced by issue #77432, Mantaflow Liquid not work when "Data File Format" is changed to "OpenVDB"
14 changed files with 478 additions and 1857 deletions

View File

@ -41,23 +41,23 @@ int manta_write_config(struct MANTA *fluid, struct FluidModifierData *mmd, int f
int manta_write_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_config(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_data(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr,
bool resumable);
int manta_read_noise(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr,
bool resumable);
int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_particles(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_read_particles(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr,
bool resumable);
int manta_read_guiding(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr,
bool sourceDomain);
int manta_update_liquid_structures(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr);
int manta_update_mesh_structures(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_update_particle_structures(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr);
int manta_update_smoke_structures(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_update_noise_structures(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_data(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);
int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int framenr);

File diff suppressed because it is too large Load Diff

View File

@ -60,19 +60,6 @@ struct MANTA {
int flags;
} Triangle;
// Cache helper typedefs
typedef struct GridItem {
void **pointer; /* Array of pointers for this grid.*/
int type;
int *res;
string name;
} GridItem;
typedef struct FileItem {
string filename;
vector<GridItem> grids;
} FileItem;
// Manta step, handling everything
void step(struct FluidModifierData *mmd, int startFrame);
@ -104,10 +91,10 @@ struct MANTA {
// Read cache (via Manta save/load)
bool readConfiguration(FluidModifierData *mmd, int framenr);
bool readData(FluidModifierData *mmd, int framenr);
bool readNoise(FluidModifierData *mmd, int framenr);
bool readData(FluidModifierData *mmd, int framenr, bool resumable);
bool readNoise(FluidModifierData *mmd, int framenr, bool resumable);
bool readMesh(FluidModifierData *mmd, int framenr);
bool readParticles(FluidModifierData *mmd, int framenr);
bool readParticles(FluidModifierData *mmd, int framenr, bool resumable);
bool readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain);
// Read cache (via file read functions in MANTA - e.g. read .bobj.gz meshes, .uni particles)
@ -899,16 +886,6 @@ struct MANTA {
string getRealValue(const string &varName);
string parseLine(const string &line);
string parseScript(const string &setup_string, FluidModifierData *mmd = NULL);
bool updateMeshFromBobj(string filename);
bool updateMeshFromObj(string filename);
bool updateMeshFromUni(string filename);
bool updateParticlesFromUni(string filename, bool isSecondarySys, bool isVelData);
bool updateGridsFromUni(string filename, vector<GridItem> grids);
bool updateGridsFromVDB(string filename, vector<GridItem> grids);
bool updateGridsFromRaw(string filename, vector<GridItem> grids);
bool updateMeshFromFile(string filename);
bool updateParticlesFromFile(string filename, bool isSecondarySys, bool isVelData);
bool updateGridsFromFile(string filename, vector<GridItem> grids);
string getDirectory(struct FluidModifierData *mmd, string subdirectory);
string getFile(struct FluidModifierData *mmd,
string subdirectory,

View File

@ -94,18 +94,18 @@ int manta_read_config(MANTA *fluid, FluidModifierData *mmd, int framenr)
return fluid->readConfiguration(mmd, framenr);
}
int manta_read_data(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_read_data(MANTA *fluid, FluidModifierData *mmd, int framenr, bool resumable)
{
if (!fluid || !mmd)
return 0;
return fluid->readData(mmd, framenr);
return fluid->readData(mmd, framenr, resumable);
}
int manta_read_noise(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_read_noise(MANTA *fluid, FluidModifierData *mmd, int framenr, bool resumable)
{
if (!fluid || !mmd)
return 0;
return fluid->readNoise(mmd, framenr);
return fluid->readNoise(mmd, framenr, resumable);
}
int manta_read_mesh(MANTA *fluid, FluidModifierData *mmd, int framenr)
@ -115,11 +115,11 @@ int manta_read_mesh(MANTA *fluid, FluidModifierData *mmd, int framenr)
return fluid->readMesh(mmd, framenr);
}
int manta_read_particles(MANTA *fluid, FluidModifierData *mmd, int framenr)
int manta_read_particles(MANTA *fluid, FluidModifierData *mmd, int framenr, bool resumable)
{
if (!fluid || !mmd)
return 0;
return fluid->readParticles(mmd, framenr);
return fluid->readParticles(mmd, framenr, resumable);
}
int manta_read_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr, bool sourceDomain)
@ -129,41 +129,6 @@ int manta_read_guiding(MANTA *fluid, FluidModifierData *mmd, int framenr, bool s
return fluid->readGuiding(mmd, framenr, sourceDomain);
}
int manta_update_liquid_structures(MANTA *fluid, FluidModifierData *mmd, int framenr)
{
if (!fluid || !mmd)
return 0;
return fluid->updateFlipStructures(mmd, framenr);
}
int manta_update_mesh_structures(MANTA *fluid, FluidModifierData *mmd, int framenr)
{
if (!fluid || !mmd)
return 0;
return fluid->updateMeshStructures(mmd, framenr);
}
int manta_update_particle_structures(MANTA *fluid, FluidModifierData *mmd, int framenr)
{
if (!fluid || !mmd)
return 0;
return fluid->updateParticleStructures(mmd, framenr);
}
int manta_update_smoke_structures(MANTA *fluid, FluidModifierData *mmd, int framenr)
{
if (!fluid || !mmd)
return 0;
return fluid->updateSmokeStructures(mmd, framenr);
}
int manta_update_noise_structures(MANTA *fluid, FluidModifierData *mmd, int framenr)
{
if (!fluid || !mmd)
return 0;
return fluid->updateNoiseStructures(mmd, framenr);
}
int manta_bake_data(MANTA *fluid, FluidModifierData *mmd, int framenr)
{
if (!fluid || !mmd)

View File

@ -33,7 +33,7 @@ from manta import *\n\
import os.path, shutil, math, sys, gc, multiprocessing, platform, time\n\
\n\
withMPBake = False # Bake files asynchronously\n\
withMPSave = True # Save files asynchronously\n\
withMPSave = False # Save files asynchronously\n\
isWindows = platform.system() != 'Darwin' and platform.system() != 'Linux'\n\
# TODO (sebbas): Use this to simulate Windows multiprocessing (has default mode spawn)\n\
#try:\n\
@ -161,7 +161,19 @@ mantaMsg('scaleSpeed is ' + str(scaleSpeedFrames_s$ID$))\n\
scaleSpeedTime_s$ID$ = ratioResToBLength_s$ID$ * ratioBTimeToTimstep_s$ID$ # [blength/btime] to [cells/frameLength]\n\
mantaMsg('scaleSpeedTime is ' + str(scaleSpeedTime_s$ID$))\n\
\n\
gravity_s$ID$ *= scaleAcceleration_s$ID$ # scale from world acceleration to cell based acceleration\n";
gravity_s$ID$ *= scaleAcceleration_s$ID$ # scale from world acceleration to cell based acceleration\n\
\n\
# OpenVDB options\n\
vdbCompression_s$ID$ = $COMPRESSION_OPENVDB$\n\
vdbPrecisionHalf_s$ID$ = $PRECISION_OPENVDB$\n\
\n\
# Cache file names\n\
file_data_s$ID$ = '$NAME_DATA$'\n\
file_noise_s$ID$ = '$NAME_NOISE$'\n\
file_mesh_s$ID$ = '$NAME_MESH$'\n\
file_meshvel_s$ID$ = '$NAME_MESH$'\n\
file_particles_s$ID$ = '$NAME_PARTICLES$'\n\
file_guiding_s$ID$ = '$NAME_GUIDING$'";
const std::string fluid_variables_noise =
"\n\
@ -282,8 +294,8 @@ phiIn_s$ID$.setConst(9999)\n\
phiOut_s$ID$.setConst(9999)\n\
\n\
# Keep track of important objects in dict to load them later on\n\
fluid_data_dict_final_s$ID$ = dict(vel=vel_s$ID$, velTmp=velTmp_s$ID$)\n\
fluid_data_dict_resume_s$ID$ = dict(phiObs=phiObs_s$ID$, phiIn=phiIn_s$ID$, phiOut=phiOut_s$ID$, flags=flags_s$ID$)\n";
fluid_data_dict_final_s$ID$ = { 'vel' : vel_s$ID$ }\n\
fluid_data_dict_resume_s$ID$ = { 'phiObs' : phiObs_s$ID$, 'phiIn' : phiIn_s$ID$, 'phiOut' : phiOut_s$ID$, 'flags' : flags_s$ID$, 'velTmp' : velTmp_s$ID$ }\n";
const std::string fluid_alloc_obstacle =
"\n\
@ -497,10 +509,12 @@ def fluid_cache_get_framenr_formatted_$ID$(framenr):\n\
const std::string fluid_bake_multiprocessing =
"\n\
def fluid_cache_multiprocessing_start_$ID$(function, framenr, format_data=None, format_noise=None, format_mesh=None, format_particles=None, format_guiding=None, path_data=None, path_noise=None, path_mesh=None, path_particles=None, path_guiding=None, dict=None, do_join=True, resumable=False):\n\
def fluid_cache_multiprocessing_start_$ID$(function, framenr, file_name=None, format_data=None, format_noise=None, format_mesh=None, format_particles=None, format_guiding=None, path_data=None, path_noise=None, path_mesh=None, path_particles=None, path_guiding=None, dict=None, do_join=True, resumable=False):\n\
mantaMsg('Multiprocessing cache')\n\
if __name__ == '__main__':\n\
args = (framenr,)\n\
if file_name:\n\
args += (file_name,)\n\
if format_data:\n\
args += (format_data,)\n\
if format_noise:\n\
@ -531,7 +545,7 @@ def fluid_cache_multiprocessing_start_$ID$(function, framenr, format_data=None,
const std::string fluid_bake_data =
"\n\
def bake_fluid_process_data_$ID$(framenr, format_data, format_particles, format_guiding, path_data, path_guiding):\n\
def bake_fluid_process_data_$ID$(framenr, format_data, path_data):\n\
mantaMsg('Bake fluid data')\n\
\n\
s$ID$.frame = framenr\n\
@ -545,15 +559,15 @@ def bake_fluid_process_data_$ID$(framenr, format_data, format_particles, format_
liquid_adaptive_step_$ID$(framenr)\n\
mantaMsg('--- Step: %s seconds ---' % (time.time() - start_time))\n\
\n\
def bake_fluid_data_$ID$(path_data, path_guiding, framenr, format_data, format_particles, format_guiding):\n\
def bake_fluid_data_$ID$(path_data, framenr, format_data):\n\
if not withMPBake or isWindows:\n\
bake_fluid_process_data_$ID$(framenr, format_data, format_particles, format_guiding, path_data, path_guiding)\n\
bake_fluid_process_data_$ID$(framenr, format_data, path_data)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=bake_fluid_process_data_$ID$, framenr=framenr, format_data=format_data, format_particles=format_particles, format_guiding=format_guiding, path_data=path_data, path_guiding=path_guiding, do_join=False)\n";
fluid_cache_multiprocessing_start_$ID$(function=bake_fluid_process_data_$ID$, framenr=framenr, format_data=format_data, path_data=path_data, do_join=False)\n";
const std::string fluid_bake_noise =
"\n\
def bake_noise_process_$ID$(framenr, format_data, format_noise, path_data, path_noise, resumable):\n\
def bake_noise_process_$ID$(framenr, format_noise, path_noise):\n\
mantaMsg('Bake fluid noise')\n\
\n\
sn$ID$.frame = framenr\n\
@ -563,15 +577,15 @@ def bake_noise_process_$ID$(framenr, format_data, format_noise, path_data, path_
\n\
smoke_step_noise_$ID$(framenr)\n\
\n\
def bake_noise_$ID$(path_data, path_noise, framenr, format_data, format_noise, resumable):\n\
def bake_noise_$ID$(path_noise, framenr, format_noise):\n\
if not withMPBake or isWindows:\n\
bake_noise_process_$ID$(framenr, format_data, format_noise, path_data, path_noise, resumable)\n\
bake_noise_process_$ID$(framenr, format_noise, path_noise)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=bake_noise_process_$ID$, framenr=framenr, format_data=format_data, format_noise=format_noise, path_data=path_data, path_noise=path_noise, resumable=resumable)\n";
fluid_cache_multiprocessing_start_$ID$(function=bake_noise_process_$ID$, framenr=framenr, format_noise=format_noise, path_noise=path_noise)\n";
const std::string fluid_bake_mesh =
"\n\
def bake_mesh_process_$ID$(framenr, format_data, format_mesh, format_particles, path_data, path_mesh):\n\
def bake_mesh_process_$ID$(framenr, format_data, format_mesh, path_mesh):\n\
mantaMsg('Bake fluid mesh')\n\
\n\
sm$ID$.frame = framenr\n\
@ -587,15 +601,15 @@ def bake_mesh_process_$ID$(framenr, format_data, format_mesh, format_particles,
if using_speedvectors_s$ID$:\n\
liquid_save_meshvel_$ID$(path_mesh, framenr, format_data)\n\
\n\
def bake_mesh_$ID$(path_data, path_mesh, framenr, format_data, format_mesh, format_particles):\n\
def bake_mesh_$ID$(path_mesh, framenr, format_data, format_mesh):\n\
if not withMPBake or isWindows:\n\
bake_mesh_process_$ID$(framenr, format_data, format_mesh, format_particles, path_data, path_mesh)\n\
bake_mesh_process_$ID$(framenr, format_data, format_mesh, path_mesh)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=bake_mesh_process_$ID$, framenr=framenr, format_data=format_data, format_mesh=format_mesh, format_particles=format_particles, path_data=path_data, path_mesh=path_mesh)\n";
fluid_cache_multiprocessing_start_$ID$(function=bake_mesh_process_$ID$, framenr=framenr, format_data=format_data, format_mesh=format_mesh, path_mesh=path_mesh)\n";
const std::string fluid_bake_particles =
"\n\
def bake_particles_process_$ID$(framenr, format_data, format_particles, path_data, path_particles, resumable):\n\
def bake_particles_process_$ID$(framenr, format_particles, path_particles, resumable):\n\
mantaMsg('Bake secondary particles')\n\
\n\
sp$ID$.frame = framenr\n\
@ -609,11 +623,11 @@ def bake_particles_process_$ID$(framenr, format_data, format_particles, path_dat
liquid_step_particles_$ID$()\n\
liquid_save_particles_$ID$(path_particles, framenr, format_particles, resumable)\n\
\n\
def bake_particles_$ID$(path_data, path_particles, framenr, format_data, format_particles, resumable):\n\
def bake_particles_$ID$(path_particles, framenr, format_particles, resumable):\n\
if not withMPBake or isWindows:\n\
bake_particles_process_$ID$(framenr, format_data, format_particles, path_data, path_particles, resumable)\n\
bake_particles_process_$ID$(framenr, format_particles, path_particles, resumable)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=bake_particles_process_$ID$, framenr=framenr, format_data=format_data, format_particles=format_particles, path_data=path_data, path_particles=path_particles, resumable=resumable)\n";
fluid_cache_multiprocessing_start_$ID$(function=bake_particles_process_$ID$, framenr=framenr, format_particles=format_particles, path_particles=path_particles, resumable=resumable)\n";
const std::string fluid_bake_guiding =
"\n\
@ -650,43 +664,47 @@ def bake_guiding_$ID$(path_guiding, framenr, format_guiding, resumable):\n\
const std::string fluid_file_import =
"\n\
def fluid_file_import_s$ID$(dict, path, framenr, file_format):\n\
def fluid_file_import_s$ID$(dict, path, framenr, file_format, file_name=None):\n\
mantaMsg('Fluid file import, frame: ' + str(framenr))\n\
try:\n\
framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
for name, object in dict.items():\n\
file = os.path.join(path, name + '_' + framenr + file_format)\n\
# New cache: Try to load the data from a single file\n\
loadCombined = 0\n\
if file_name is not None:\n\
file = os.path.join(path, file_name + '_' + framenr + file_format)\n\
if os.path.isfile(file):\n\
object.load(file)\n\
else:\n\
mantaMsg('Could not load file ' + str(file))\n\
except:\n\
mantaMsg('exception found')\n\
#mantaMsg(str(e))\n\
pass # Just skip file load errors for now\n";
const std::string fluid_load_data =
"\n\
def fluid_load_data_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Fluid load data, frame ' + str(framenr))\n\
fluid_file_import_s$ID$(dict=fluid_data_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
\n\
if resumable:\n\
fluid_file_import_s$ID$(dict=fluid_data_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
if file_format == '.vdb':\n\
loadCombined = load(name=file, objects=list(dict.values()), worldSize=domainSize_s$ID$)\n\
elif file_format == '.bobj.gz' or file_format == '.obj':\n\
for name, object in dict.items():\n\
if os.path.isfile(file):\n\
loadCombined = object.load(file)\n\
\n\
# When adaptive domain bake is resumed we need correct values in xyz vel grids\n\
copyVec3ToReal(source=vel_s$ID$, targetX=x_vel_s$ID$, targetY=y_vel_s$ID$, targetZ=z_vel_s$ID$)\n";
# Old cache: Try to load the data from separate files, i.e. per object with the object based load() function\n\
if not loadCombined:\n\
for name, object in dict.items():\n\
file = os.path.join(path, name + '_' + framenr + file_format)\n\
if os.path.isfile(file):\n\
loadCombined = object.load(file)\n\
\n\
if not loadCombined:\n\
mantaMsg('Could not load file ' + str(file))\n\
\n\
except Exception as e:\n\
mantaMsg('Exception in Python fluid file import: ' + str(e))\n\
pass # Just skip file load errors for now\n";
const std::string fluid_load_guiding =
"\n\
def fluid_load_guiding_$ID$(path, framenr, file_format):\n\
mantaMsg('Fluid load guiding, frame ' + str(framenr))\n\
fluid_file_import_s$ID$(dict=fluid_guiding_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
fluid_file_import_s$ID$(dict=fluid_guiding_dict_s$ID$, path=path, framenr=framenr, file_format=file_format, file_name=file_guiding_s$ID$)\n";
const std::string fluid_load_vel =
"\n\
def fluid_load_vel_$ID$(path, framenr, file_format):\n\
mantaMsg('Fluid load vel, frame ' + str(framenr))\n\
fluid_vel_dict_s$ID$ = dict(vel=guidevel_sg$ID$)\n\
fluid_vel_dict_s$ID$ = { 'vel' : guidevel_sg$ID$ }\n\
fluid_file_import_s$ID$(dict=fluid_vel_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
//////////////////////////////////////////////////////////////////////
@ -695,7 +713,7 @@ def fluid_load_vel_$ID$(path, framenr, file_format):\n\
const std::string fluid_file_export =
"\n\
def fluid_file_export_s$ID$(framenr, file_format, path, dict, mode_override=True, skip_subframes=True):\n\
def fluid_file_export_s$ID$(framenr, file_format, path, dict, file_name=None, mode_override=True, skip_subframes=True):\n\
if skip_subframes and ((timePerFrame_s$ID$ + dt0_s$ID$) < frameLength_s$ID$):\n\
return\n\
mantaMsg('Fluid file export, frame: ' + str(framenr))\n\
@ -703,36 +721,37 @@ def fluid_file_export_s$ID$(framenr, file_format, path, dict, mode_override=True
framenr = fluid_cache_get_framenr_formatted_$ID$(framenr)\n\
if not os.path.exists(path):\n\
os.makedirs(path)\n\
for name, object in dict.items():\n\
file = os.path.join(path, name + '_' + framenr + file_format)\n\
if not os.path.isfile(file) or mode_override: object.save(file)\n\
\n\
# New cache: Try to save the data to a single file\n\
saveCombined = 0\n\
if file_name is not None:\n\
file = os.path.join(path, file_name + '_' + framenr + file_format)\n\
if not os.path.isfile(file) or mode_override:\n\
if file_format == '.vdb':\n\
saveCombined = save(name=file, objects=list(dict.values()), worldSize=domainSize_s$ID$, skipDeletedParts=True, compression=vdbCompression_s$ID$, precisionHalf=vdbPrecisionHalf_s$ID$)\n\
elif file_format == '.bobj.gz' or file_format == '.obj':\n\
for name, object in dict.items():\n\
if not os.path.isfile(file) or mode_override:\n\
saveCombined = object.save(file)\n\
\n\
# Old cache: Try to save the data to separate files, i.e. per object with the object based save() function\n\
if not saveCombined:\n\
for name, object in dict.items():\n\
file = os.path.join(path, name + '_' + framenr + file_format)\n\
if not os.path.isfile(file) or mode_override: object.save(file)\n\
\n\
except Exception as e:\n\
mantaMsg(str(e))\n\
mantaMsg('Exception in Python fluid file export: ' + str(e))\n\
pass # Just skip file save errors for now\n";
const std::string fluid_save_data =
"\n\
def fluid_save_data_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Fluid save data, frame ' + str(framenr))\n\
start_time = time.time()\n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(framenr=framenr, file_format=file_format, path=path, dict=fluid_data_dict_final_s$ID$)\n\
if resumable:\n\
fluid_file_export_s$ID$(framenr=framenr, file_format=file_format, path=path, dict=fluid_data_dict_resume_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=fluid_data_dict_final_s$ID$, do_join=False)\n\
if resumable:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=fluid_data_dict_resume_s$ID$, do_join=False)\n\
mantaMsg('--- Save: %s seconds ---' % (time.time() - start_time))\n";
const std::string fluid_save_guiding =
"\n\
def fluid_save_guiding_$ID$(path, framenr, file_format, resumable):\n\
def fluid_save_guiding_$ID$(path, framenr, file_format):\n\
mantaMsg('Fluid save guiding, frame ' + str(framenr))\n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(dict=fluid_guiding_dict_s$ID$, framenr=framenr, file_format=file_format, path=path)\n\
fluid_file_export_s$ID$(dict=fluid_guiding_dict_s$ID$, framenr=framenr, file_format=file_format, path=path, file_name=file_guiding_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=fluid_guiding_dict_s$ID$, do_join=False)\n";
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_guiding_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=fluid_guiding_dict_s$ID$, do_join=False)\n";
//////////////////////////////////////////////////////////////////////
// STANDALONE MODE

View File

@ -86,16 +86,16 @@ mapWeights_s$ID$ = s$ID$.create(MACGrid, name='$NAME_MAPWEIGHTS$')\n\
fractions_s$ID$ = None # allocated dynamically\n\
curvature_s$ID$ = None\n\
\n\
pp_s$ID$ = s$ID$.create(BasicParticleSystem, name='$NAME_PP$')\n\
pVel_pp$ID$ = pp_s$ID$.create(PdataVec3, name='$NAME_PVEL$')\n\
pp_s$ID$ = s$ID$.create(BasicParticleSystem, name='$NAME_PARTS$')\n\
pVel_pp$ID$ = pp_s$ID$.create(PdataVec3, name='$NAME_PARTSVELOCITY$')\n\
\n\
# Acceleration data for particle nbs\n\
pindex_s$ID$ = s$ID$.create(ParticleIndexSystem, name='$NAME_PINDEX$')\n\
gpi_s$ID$ = s$ID$.create(IntGrid, name='$NAME_GPI$')\n\
\n\
# Keep track of important objects in dict to load them later on\n\
liquid_data_dict_final_s$ID$ = dict(pp=pp_s$ID$, pVel=pVel_pp$ID$)\n\
liquid_data_dict_resume_s$ID$ = dict(phiParts=phiParts_s$ID$, phi=phi_s$ID$, phiTmp=phiTmp_s$ID$)\n";
liquid_data_dict_final_s$ID$ = { 'pVel' : pVel_pp$ID$, 'pp' : pp_s$ID$ }\n\
liquid_data_dict_resume_s$ID$ = { 'phiParts' : phiParts_s$ID$, 'phi' : phi_s$ID$, 'phiTmp' : phiTmp_s$ID$ }\n";
const std::string liquid_alloc_mesh =
"\n\
@ -104,7 +104,7 @@ phiParts_sm$ID$ = sm$ID$.create(LevelsetGrid, name='$NAME_PHIPARTS_MESH$')\n\
phi_sm$ID$ = sm$ID$.create(LevelsetGrid, name='$NAME_PHI_MESH$')\n\
pp_sm$ID$ = sm$ID$.create(BasicParticleSystem, name='$NAME_PP_MESH$')\n\
flags_sm$ID$ = sm$ID$.create(FlagGrid, name='$NAME_FLAGS_MESH$')\n\
mesh_sm$ID$ = sm$ID$.create(Mesh, name='$NAME_LMESH$')\n\
mesh_sm$ID$ = sm$ID$.create(Mesh, name='$NAME_MESH$')\n\
\n\
if using_speedvectors_s$ID$:\n\
mVel_mesh$ID$ = mesh_sm$ID$.create(MdataVec3, name='$NAME_VELOCITYVEC_MESH$')\n\
@ -119,10 +119,10 @@ phiParts_sm$ID$.setConst(9999)\n\
phi_sm$ID$.setConst(9999)\n\
\n\
# Keep track of important objects in dict to load them later on\n\
liquid_mesh_dict_s$ID$ = dict(lMesh=mesh_sm$ID$)\n\
liquid_mesh_dict_s$ID$ = { 'lMesh' : mesh_sm$ID$ }\n\
\n\
if using_speedvectors_s$ID$:\n\
liquid_meshvel_dict_s$ID$ = dict(lVelMesh=mVel_mesh$ID$)\n";
liquid_meshvel_dict_s$ID$ = { 'lVelMesh' : mVel_mesh$ID$ }\n";
const std::string liquid_alloc_curvature =
"\n\
@ -131,10 +131,10 @@ curvature_s$ID$ = s$ID$.create(RealGrid, name='$NAME_CURVATURE$')\n";
const std::string liquid_alloc_particles =
"\n\
ppSnd_sp$ID$ = sp$ID$.create(BasicParticleSystem, name='$NAME_PP_PARTICLES$')\n\
pVelSnd_pp$ID$ = ppSnd_sp$ID$.create(PdataVec3, name='$NAME_PVEL_PARTICLES$')\n\
pForceSnd_pp$ID$ = ppSnd_sp$ID$.create(PdataVec3, name='$NAME_PFORCE_PARTICLES$')\n\
pLifeSnd_pp$ID$ = ppSnd_sp$ID$.create(PdataReal, name='$NAME_PLIFE_PARTICLES$')\n\
ppSnd_sp$ID$ = sp$ID$.create(BasicParticleSystem, name='$NAME_PARTS_PARTICLES$')\n\
pVelSnd_pp$ID$ = ppSnd_sp$ID$.create(PdataVec3, name='$NAME_PARTSVEL_PARTICLES$')\n\
pForceSnd_pp$ID$ = ppSnd_sp$ID$.create(PdataVec3, name='$NAME_PARTSFORCE_PARTICLES$')\n\
pLifeSnd_pp$ID$ = ppSnd_sp$ID$.create(PdataReal, name='$NAME_PARTSLIFE_PARTICLES$')\n\
vel_sp$ID$ = sp$ID$.create(MACGrid, name='$NAME_VELOCITY_PARTICLES$')\n\
flags_sp$ID$ = sp$ID$.create(FlagGrid, name='$NAME_FLAGS_PARTICLES$')\n\
phi_sp$ID$ = sp$ID$.create(LevelsetGrid, name='$NAME_PHI_PARTICLES$')\n\
@ -152,8 +152,8 @@ phiObs_sp$ID$.setConst(9999)\n\
phiOut_sp$ID$.setConst(9999)\n\
\n\
# Keep track of important objects in dict to load them later on\n\
liquid_particles_dict_final_s$ID$ = dict(ppSnd=ppSnd_sp$ID$, pVelSnd=pVelSnd_pp$ID$, pLifeSnd=pLifeSnd_pp$ID$)\n\
liquid_particles_dict_resume_s$ID$ = dict(trappedAir=trappedAir_sp$ID$, waveCrest=waveCrest_sp$ID$, kineticEnergy=kineticEnergy_sp$ID$)\n";
liquid_particles_dict_final_s$ID$ = { 'pVelSnd' : pVelSnd_pp$ID$, 'pLifeSnd' : pLifeSnd_pp$ID$, 'ppSnd' : ppSnd_sp$ID$ }\n\
liquid_particles_dict_resume_s$ID$ = { 'trappedAir' : trappedAir_sp$ID$, 'waveCrest' : waveCrest_sp$ID$, 'kineticEnergy' : kineticEnergy_sp$ID$ }\n";
const std::string liquid_init_phi =
"\n\
@ -401,27 +401,29 @@ const std::string liquid_load_data =
"\n\
def liquid_load_data_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Liquid load data')\n\
fluid_file_import_s$ID$(dict=liquid_data_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
if resumable:\n\
fluid_file_import_s$ID$(dict=liquid_data_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
dict = { **fluid_data_dict_final_s$ID$, **fluid_data_dict_resume_s$ID$, **liquid_data_dict_final_s$ID$, **liquid_data_dict_resume_s$ID$ } if resumable else { **fluid_data_dict_final_s$ID$, **liquid_data_dict_final_s$ID$ }\n\
fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_data_s$ID$)\n\
\n\
copyVec3ToReal(source=vel_s$ID$, targetX=x_vel_s$ID$, targetY=y_vel_s$ID$, targetZ=z_vel_s$ID$)\n";
const std::string liquid_load_mesh =
"\n\
def liquid_load_mesh_$ID$(path, framenr, file_format):\n\
mantaMsg('Liquid load mesh')\n\
fluid_file_import_s$ID$(dict=liquid_mesh_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
dict = liquid_mesh_dict_s$ID$\n\
fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_mesh_s$ID$)\n\
\n\
def liquid_load_meshvel_$ID$(path, framenr, file_format):\n\
mantaMsg('Liquid load meshvel')\n\
fluid_file_import_s$ID$(dict=liquid_meshvel_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
dict = liquid_meshvel_dict_s$ID$\n\
fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_meshvel_s$ID$)\n";
const std::string liquid_load_particles =
"\n\
def liquid_load_particles_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Liquid load particles')\n\
fluid_file_import_s$ID$(dict=liquid_particles_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
if resumable:\n\
fluid_file_import_s$ID$(dict=liquid_particles_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
dict = { **liquid_particles_dict_final_s$ID$, **liquid_particles_dict_resume_s$ID$ } if resumable else { **liquid_particles_dict_final_s$ID$ }\n\
fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_particles_s$ID$)\n";
//////////////////////////////////////////////////////////////////////
// EXPORT
@ -431,43 +433,39 @@ const std::string liquid_save_data =
"\n\
def liquid_save_data_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Liquid save data')\n\
dict = { **fluid_data_dict_final_s$ID$, **fluid_data_dict_resume_s$ID$, **liquid_data_dict_final_s$ID$, **liquid_data_dict_resume_s$ID$ } if resumable else { **fluid_data_dict_final_s$ID$, **liquid_data_dict_final_s$ID$ }\n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(dict=liquid_data_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
if resumable:\n\
fluid_file_export_s$ID$(dict=liquid_data_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
fluid_file_export_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_data_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=liquid_data_dict_final_s$ID$, do_join=False)\n\
if resumable:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=liquid_data_dict_resume_s$ID$, do_join=False)\n";
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_data_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n";
const std::string liquid_save_mesh =
"\n\
def liquid_save_mesh_$ID$(path, framenr, file_format):\n\
mantaMsg('Liquid save mesh')\n\
dict = liquid_mesh_dict_s$ID$\n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(dict=liquid_mesh_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
fluid_file_export_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_mesh_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=liquid_mesh_dict_s$ID$, do_join=False)\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_mesh_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n\
\n\
def liquid_save_meshvel_$ID$(path, framenr, file_format):\n\
mantaMsg('Liquid save mesh vel')\n\
dict = liquid_meshvel_dict_s$ID$\n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(dict=liquid_meshvel_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
fluid_file_export_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=liquid_meshvel_dict_s$ID$, do_join=False)\n";
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n";
const std::string liquid_save_particles =
"\n\
def liquid_save_particles_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Liquid save particles')\n\
dict = { **liquid_particles_dict_final_s$ID$, **liquid_particles_dict_resume_s$ID$ } if resumable else { **liquid_particles_dict_final_s$ID$ }\n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(dict=liquid_particles_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
if resumable:\n\
fluid_file_export_s$ID$(dict=liquid_particles_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
fluid_file_export_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_particles_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=liquid_particles_dict_final_s$ID$, do_join=False)\n\
if resumable:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=liquid_particles_dict_resume_s$ID$, do_join=False)\n";
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_particles_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n";
//////////////////////////////////////////////////////////////////////
// STANDALONE MODE
@ -477,7 +475,6 @@ const std::string liquid_standalone =
"\n\
# Helper function to call cache load functions\n\
def load(frame, cache_resumable):\n\
fluid_load_data_$ID$(os.path.join(cache_dir, 'data'), frame, file_format_data, cache_resumable)\n\
liquid_load_data_$ID$(os.path.join(cache_dir, 'data'), frame, file_format_data, cache_resumable)\n\
if using_sndparts_s$ID$:\n\
liquid_load_particles_$ID$(os.path.join(cache_dir, 'particles'), frame, file_format_particles, cache_resumable)\n\

View File

@ -101,8 +101,8 @@ color_g_in_s$ID$ = None\n\
color_b_in_s$ID$ = None\n\
\n\
# Keep track of important objects in dict to load them later on\n\
smoke_data_dict_final_s$ID$ = dict(density=density_s$ID$, shadow=shadow_s$ID$)\n\
smoke_data_dict_resume_s$ID$ = dict(densityIn=densityIn_s$ID$, emission=emission_s$ID$)\n";
smoke_data_dict_final_s$ID$ = { 'density' : density_s$ID$, 'shadow' : shadow_s$ID$ }\n\
smoke_data_dict_resume_s$ID$ = { 'densityIn' : densityIn_s$ID$, 'emission' : emission_s$ID$ }\n";
const std::string smoke_alloc_noise =
"\n\
@ -213,8 +213,8 @@ if 'heat_s$ID$' in globals(): del heat_s$ID$\n\
if 'heatIn_s$ID$' in globals(): del heatIn_s$ID$\n\
\n\
mantaMsg('Allocating heat')\n\
heat_s$ID$ = s$ID$.create(RealGrid, name='$NAME_HEAT$')\n\
heatIn_s$ID$ = s$ID$.create(RealGrid, name='$NAME_HEATIN$')\n\
heat_s$ID$ = s$ID$.create(RealGrid, name='$NAME_TEMPERATURE$')\n\
heatIn_s$ID$ = s$ID$.create(RealGrid, name='$NAME_TEMPERATUREIN$')\n\
\n\
# Add objects to dict to load them later on\n\
if 'smoke_data_dict_final_s$ID$' in globals():\n\
@ -542,19 +542,19 @@ const std::string smoke_load_data =
"\n\
def smoke_load_data_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Smoke load data')\n\
fluid_file_import_s$ID$(dict=smoke_data_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
if resumable:\n\
fluid_file_import_s$ID$(dict=smoke_data_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
dict = { **fluid_data_dict_final_s$ID$, **fluid_data_dict_resume_s$ID$, **smoke_data_dict_final_s$ID$, **smoke_data_dict_resume_s$ID$ } if resumable else { **fluid_data_dict_final_s$ID$, **smoke_data_dict_final_s$ID$ }\n\
fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_data_s$ID$)\n\
\n\
copyVec3ToReal(source=vel_s$ID$, targetX=x_vel_s$ID$, targetY=y_vel_s$ID$, targetZ=z_vel_s$ID$)\n";
const std::string smoke_load_noise =
"\n\
def smoke_load_noise_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Smoke load noise')\n\
fluid_file_import_s$ID$(dict=smoke_noise_dict_final_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
dict = { **smoke_noise_dict_final_s$ID$, **smoke_data_dict_resume_s$ID$ } if resumable else { **smoke_noise_dict_final_s$ID$ } \n\
fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_noise_s$ID$)\n\
\n\
if resumable:\n\
fluid_file_import_s$ID$(dict=smoke_noise_dict_resume_s$ID$, path=path, framenr=framenr, file_format=file_format)\n\
\n\
# Fill up xyz texture grids, important when resuming a bake\n\
copyVec3ToReal(source=uvGrid0_s$ID$, targetX=texture_u_s$ID$, targetY=texture_v_s$ID$, targetZ=texture_w_s$ID$)\n\
copyVec3ToReal(source=uvGrid1_s$ID$, targetX=texture_u2_s$ID$, targetY=texture_v2_s$ID$, targetZ=texture_w2_s$ID$)\n";
@ -568,28 +568,22 @@ const std::string smoke_save_data =
def smoke_save_data_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Smoke save data')\n\
start_time = time.time()\n\
dict = { **fluid_data_dict_final_s$ID$, **fluid_data_dict_resume_s$ID$, **smoke_data_dict_final_s$ID$, **smoke_data_dict_resume_s$ID$ } if resumable else { **fluid_data_dict_final_s$ID$, **smoke_data_dict_final_s$ID$ } \n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(framenr=framenr, file_format=file_format, path=path, dict=smoke_data_dict_final_s$ID$,)\n\
if resumable:\n\
fluid_file_export_s$ID$(framenr=framenr, file_format=file_format, path=path, dict=smoke_data_dict_resume_s$ID$,)\n\
fluid_file_export_s$ID$(dict=dict, path=path, framenr=framenr, file_format=file_format, file_name=file_data_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=smoke_data_dict_final_s$ID$, do_join=False)\n\
if resumable:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=smoke_data_dict_resume_s$ID$, do_join=False)\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_data_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n\
mantaMsg('--- Save: %s seconds ---' % (time.time() - start_time))\n";
const std::string smoke_save_noise =
"\n\
def smoke_save_noise_$ID$(path, framenr, file_format, resumable):\n\
mantaMsg('Smoke save noise')\n\
dict = { **smoke_noise_dict_final_s$ID$, **smoke_noise_dict_resume_s$ID$ } if resumable else { **smoke_noise_dict_final_s$ID$ } \n\
if not withMPSave or isWindows:\n\
fluid_file_export_s$ID$(dict=smoke_noise_dict_final_s$ID$, framenr=framenr, file_format=file_format, path=path)\n\
if resumable:\n\
fluid_file_export_s$ID$(dict=smoke_noise_dict_resume_s$ID$, framenr=framenr, file_format=file_format, path=path)\n\
fluid_file_export_s$ID$(dict=dict, framenr=framenr, file_format=file_format, path=path, file_name=file_noise_s$ID$)\n\
else:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=smoke_noise_dict_final_s$ID$, do_join=False)\n\
if resumable:\n\
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=smoke_noise_dict_resume_s$ID$, do_join=False)\n";
fluid_cache_multiprocessing_start_$ID$(function=fluid_file_export_s$ID$, file_name=file_noise_s$ID$, framenr=framenr, format_data=file_format, path_data=path, dict=dict, do_join=False)\n";
//////////////////////////////////////////////////////////////////////
// STANDALONE MODE
@ -599,7 +593,6 @@ const std::string smoke_standalone =
"\n\
# Helper function to call cache load functions\n\
def load(frame, cache_resumable):\n\
fluid_load_data_$ID$(os.path.join(cache_dir, 'data'), frame, file_format_data, cache_resumable)\n\
smoke_load_data_$ID$(os.path.join(cache_dir, 'data'), frame, file_format_data, cache_resumable)\n\
if using_noise_s$ID$:\n\
smoke_load_noise_$ID$(os.path.join(cache_dir, 'noise'), frame, file_format_noise, cache_resumable)\n\

View File

@ -399,9 +399,6 @@ class QuickSmoke(ObjectModeOperator, Operator):
if self.style == 'FIRE' or self.style == 'BOTH':
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
# Cycles and Eevee

View File

@ -213,7 +213,7 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
split.enabled = note_flag
bake_incomplete = (domain.cache_frame_pause_data < domain.cache_frame_end)
if domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
if domain.cache_resumable and domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
col = split.column()
col.operator("fluid.bake_data", text="Resume")
col = split.column()
@ -1119,9 +1119,7 @@ class PHYSICS_PT_cache(PhysicButtonsPanel, Panel):
is_baking_any = domain.is_cache_baking_any
has_baked_data = domain.has_cache_baked_data
has_baked_noise = domain.has_cache_baked_noise
has_baked_mesh = domain.has_cache_baked_mesh
has_baked_particles = domain.has_cache_baked_particles
col = layout.column()
col.prop(domain, "cache_directory", text="")
@ -1146,35 +1144,32 @@ class PHYSICS_PT_cache(PhysicButtonsPanel, Panel):
col.separator()
col = flow.column()
col.enabled = not is_baking_any and not has_baked_data
col.prop(domain, "cache_resumable", text="Is Resumable")
row = col.row()
row.enabled = not is_baking_any and not has_baked_data
row.prop(domain, "cache_data_format", text="Data File Format")
row.prop(domain, "cache_data_format", text="Format Volumes")
if md.domain_settings.domain_type in {'GAS'}:
if domain.use_noise:
row = col.row()
row.enabled = not is_baking_any and not has_baked_noise
row.prop(domain, "cache_noise_format", text="Noise File Format")
if md.domain_settings.domain_type in {'LIQUID'}:
# File format for all particle systemes (FLIP and secondary)
if md.domain_settings.domain_type in {'LIQUID'} and domain.use_mesh:
row = col.row()
row.enabled = not is_baking_any and not has_baked_particles and not has_baked_data
row.prop(domain, "cache_particle_format", text="Particle File Format")
row.enabled = not is_baking_any and not has_baked_mesh
row.prop(domain, "cache_mesh_format", text="Meshes")
if domain.use_mesh:
row = col.row()
row.enabled = not is_baking_any and not has_baked_mesh
row.prop(domain, "cache_mesh_format", text="Mesh File Format")
if domain.cache_type == 'FINAL':
if domain.cache_type == 'ALL':
col.separator()
split = layout.split()
if domain.is_cache_baking_data and not domain.has_cache_baked_data:
bake_incomplete = (domain.cache_frame_pause_data < domain.cache_frame_end)
if domain.cache_resumable and domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
col = split.column()
col.operator("fluid.bake_all", text="Resume")
col = split.column()
col.operator("fluid.free_all", text="Free")
elif domain.is_cache_baking_data and not domain.has_cache_baked_data:
split.enabled = False
split.operator("fluid.pause_bake", text="Baking All - ESC to cancel")
split.operator("fluid.pause_bake", text="Baking All - ESC to pause")
elif not domain.has_cache_baked_data and not domain.is_cache_baking_data:
split.operator("fluid.bake_all", text="Bake All")
else:
@ -1189,8 +1184,8 @@ class PHYSICS_PT_export(PhysicButtonsPanel, Panel):
@classmethod
def poll(cls, context):
# Only show the advanced panel to advanced users who know Mantaflow's birthday :)
if not PhysicButtonsPanel.poll_fluid_domain(context) or bpy.app.debug_value != 3001:
domain = context.fluid.domain_settings
if not PhysicButtonsPanel.poll_fluid_domain(context) or (domain.cache_data_format != 'OPENVDB' and bpy.app.debug_value != 3001):
return False
return (context.engine in cls.COMPAT_ENGINES)
@ -1203,12 +1198,24 @@ class PHYSICS_PT_export(PhysicButtonsPanel, Panel):
is_baking_any = domain.is_cache_baking_any
has_baked_any = domain.has_cache_baked_any
has_baked_data = domain.has_cache_baked_data
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
flow.enabled = not is_baking_any and not has_baked_any
col = flow.column()
col.prop(domain, "export_manta_script", text="Export Mantaflow Script")
if domain.cache_data_format == 'OPENVDB':
col.enabled = not is_baking_any and not has_baked_data
col.prop(domain, "openvdb_cache_compress_type", text="Compression Volumes")
col = flow.column()
col.prop(domain, "openvdb_data_depth", text="Precision Volumes")
# Only show the advanced panel to advanced users who know Mantaflow's birthday :)
if bpy.app.debug_value == 3001:
col = flow.column()
col.prop(domain, "export_manta_script", text="Export Mantaflow Script")
class PHYSICS_PT_field_weights(PhysicButtonsPanel, Panel):

View File

@ -3809,6 +3809,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
bubble = mds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE;
floater = mds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM;
bool with_resumable_cache = mds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE;
bool with_script, with_adaptive, with_noise, with_mesh, with_particles, with_guide;
with_script = mds->flags & FLUID_DOMAIN_EXPORT_MANTA_SCRIPT;
with_adaptive = mds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN;
@ -3868,13 +3869,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
/* Cache mode specific settings. */
switch (mode) {
case FLUID_DOMAIN_CACHE_FINAL:
/* Just load the data that has already been baked */
if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) {
read_cache = true;
bake_cache = false;
}
break;
case FLUID_DOMAIN_CACHE_ALL:
case FLUID_DOMAIN_CACHE_MODULAR:
/* Just load the data that has already been baked */
if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) {
@ -3929,6 +3924,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
break;
}
bool read_partial = false, read_all = false;
/* Try to read from cache and keep track of read success. */
if (read_cache) {
@ -3937,20 +3933,16 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
has_config = manta_read_config(mds->fluid, mmd, mesh_frame);
/* Update mesh data from file is faster than via Python (manta_read_mesh()). */
has_mesh = manta_update_mesh_structures(mds->fluid, mmd, mesh_frame);
has_mesh = manta_read_mesh(mds->fluid, mmd, mesh_frame);
}
/* Read particles cache. */
if (with_liquid && with_particles) {
has_config = manta_read_config(mds->fluid, mmd, particles_frame);
if (!baking_data && !baking_particles && next_particles) {
/* Update particle data from file is faster than via Python (manta_read_particles()). */
has_particles = manta_update_particle_structures(mds->fluid, mmd, particles_frame);
}
else {
has_particles = manta_read_particles(mds->fluid, mmd, particles_frame);
}
read_partial = !baking_data && !baking_particles && next_particles;
read_all = !read_partial && with_resumable_cache;
has_particles = manta_read_particles(mds->fluid, mmd, particles_frame, read_all);
}
/* Read guide cache. */
@ -3968,12 +3960,10 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
manta_needs_realloc(mds->fluid, mmd)) {
BKE_fluid_reallocate_fluid(mds, mds->res, 1);
}
if (!baking_data && !baking_noise && next_noise) {
has_noise = manta_update_noise_structures(mds->fluid, mmd, noise_frame);
}
else {
has_noise = manta_read_noise(mds->fluid, mmd, noise_frame);
}
read_partial = !baking_data && !baking_noise && next_noise;
read_all = !read_partial && with_resumable_cache;
has_noise = manta_read_noise(mds->fluid, mmd, noise_frame, read_all);
/* When using the adaptive domain, copy all data that was read to a new fluid object. */
if (with_adaptive && baking_noise) {
@ -3987,12 +3977,10 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
mds, o_res, mds->res, o_min, mds->res_min, o_max, o_shift, mds->shift);
}
}
if (!baking_data && !baking_noise && next_data && next_noise) {
/* Nothing to do here since we already loaded noise grids. */
}
else {
has_data = manta_read_data(mds->fluid, mmd, data_frame);
}
read_partial = !baking_data && !baking_noise && next_data && next_noise;
read_all = !read_partial && with_resumable_cache;
has_data = manta_read_data(mds->fluid, mmd, data_frame, read_all);
}
/* Read data cache only */
else {
@ -4003,28 +3991,17 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
if (has_config && manta_needs_realloc(mds->fluid, mmd)) {
BKE_fluid_reallocate_fluid(mds, mds->res, 1);
}
/* Read data cache */
if (!baking_data && !baking_particles && !baking_mesh && next_data) {
has_data = manta_update_smoke_structures(mds->fluid, mmd, data_frame);
}
else {
has_data = manta_read_data(mds->fluid, mmd, data_frame);
}
}
if (with_liquid) {
if (!baking_data && !baking_particles && !baking_mesh && next_data) {
has_data = manta_update_liquid_structures(mds->fluid, mmd, data_frame);
}
else {
has_data = manta_read_data(mds->fluid, mmd, data_frame);
}
}
read_partial = !baking_data && !baking_particles && !baking_mesh && next_data;
read_all = !read_partial && with_resumable_cache;
has_data = manta_read_data(mds->fluid, mmd, data_frame, read_all);
}
}
/* Cache mode specific settings */
switch (mode) {
case FLUID_DOMAIN_CACHE_FINAL:
case FLUID_DOMAIN_CACHE_ALL:
case FLUID_DOMAIN_CACHE_MODULAR:
if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) {
bake_cache = false;
@ -4987,12 +4964,12 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd)
/* OpenVDB cache options */
#ifdef WITH_OPENVDB_BLOSC
mmd->domain->openvdb_comp = VDB_COMPRESSION_BLOSC;
mmd->domain->openvdb_compression = VDB_COMPRESSION_BLOSC;
#else
mmd->domain->openvdb_comp = VDB_COMPRESSION_ZIP;
mmd->domain->openvdb_compression = VDB_COMPRESSION_ZIP;
#endif
mmd->domain->clipping = 1e-6f;
mmd->domain->data_depth = 0;
mmd->domain->openvdb_data_depth = 0;
}
else if (mmd->type & MOD_FLUID_TYPE_FLOW) {
if (mmd->flow) {
@ -5229,9 +5206,9 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *mmd,
}
/* OpenVDB cache options */
tmds->openvdb_comp = mds->openvdb_comp;
tmds->openvdb_compression = mds->openvdb_compression;
tmds->clipping = mds->clipping;
tmds->data_depth = mds->data_depth;
tmds->openvdb_data_depth = mds->openvdb_data_depth;
}
else if (tmmd->flow) {
FluidFlowSettings *tmfs = tmmd->flow;

View File

@ -1062,7 +1062,7 @@ static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke
FluidModifierData *mmd = (FluidModifierData *)smoke_v;
FluidDomainSettings *mds = mmd->domain;
OpenVDBWriter_set_flags(writer, mds->openvdb_comp, (mds->data_depth == 16));
OpenVDBWriter_set_flags(writer, mds->openvdb_compression, (mds->openvdb_data_depth == 16));
OpenVDBWriter_add_meta_int(writer, "blender/smoke/active_fields", mds->active_fields);
OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/resolution", mds->res);

View File

@ -270,31 +270,31 @@ static void fluid_bake_sequence(FluidJob *job)
*(job->do_update) = true;
}
/* Get current pause frame (pointer) - depending on bake type */
/* Get current pause frame (pointer) - depending on bake type. */
pause_frame = job->pause_frame;
/* Set frame to start point (depending on current pause frame value) */
/* Set frame to start point (depending on current pause frame value). */
is_first_frame = ((*pause_frame) == 0);
frame = is_first_frame ? mds->cache_frame_start : (*pause_frame);
/* Save orig frame and update scene frame */
/* Save orig frame and update scene frame. */
orig_frame = CFRA;
CFRA = frame;
/* Loop through selected frames */
/* Loop through selected frames. */
for (; frame <= mds->cache_frame_end; frame++) {
const float progress = (frame - mds->cache_frame_start) / (float)frames;
/* Keep track of pause frame - needed to init future loop */
/* Keep track of pause frame - needed to init future loop. */
(*pause_frame) = frame;
/* If user requested stop, quit baking */
/* If user requested stop, quit baking. */
if (G.is_break) {
job->success = 0;
return;
}
/* Update progress bar */
/* Update progress bar. */
if (job->do_update) {
*(job->do_update) = true;
}
@ -304,17 +304,17 @@ static void fluid_bake_sequence(FluidJob *job)
CFRA = frame;
/* Update animation system */
/* Update animation system. */
ED_update_for_newframe(job->bmain, job->depsgraph);
/* If user requested stop, quit baking */
/* If user requested stop, quit baking. */
if (G.is_break) {
job->success = 0;
return;
}
}
/* Restore frame position that we were on before bake */
/* Restore frame position that we were on before bake. */
CFRA = orig_frame;
}
@ -355,9 +355,9 @@ static void fluid_bake_endjob(void *customdata)
WM_set_locked_interface(G_MAIN->wm.first, false);
/* Bake was successful:
* Report for ended bake and how long it took */
* Report for ended bake and how long it took. */
if (job->success) {
/* Show bake info */
/* Show bake info. */
WM_reportf(
RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, PIL_check_seconds_timer() - job->start);
}
@ -365,7 +365,7 @@ static void fluid_bake_endjob(void *customdata)
if (mds->error[0] != '\0') {
WM_reportf(RPT_ERROR, "Fluid: %s failed: %s", job->name, mds->error);
}
else { /* User canceled the bake */
else { /* User canceled the bake. */
WM_reportf(RPT_WARNING, "Fluid: %s canceled!", job->name);
}
}

View File

@ -45,6 +45,7 @@ enum {
FLUID_DOMAIN_USE_FRACTIONS = (1 << 13), /* Use second order obstacles. */
FLUID_DOMAIN_DELETE_IN_OBSTACLE = (1 << 14), /* Delete fluid inside obstacles. */
FLUID_DOMAIN_USE_DIFFUSION = (1 << 15), /* Use diffusion (e.g. viscosity, surface tension). */
FLUID_DOMAIN_USE_RESUMABLE_CACHE = (1 << 16), /* Determine if cache should be resumable. */
};
/* Border collisions. */
@ -214,6 +215,7 @@ enum {
#define FLUID_DOMAIN_DIR_SCRIPT "script"
#define FLUID_DOMAIN_SMOKE_SCRIPT "smoke_script.py"
#define FLUID_DOMAIN_LIQUID_SCRIPT "liquid_script.py"
#define FLUID_CACHE_VERSION "C01"
/* Cache file names. */
#define FLUID_NAME_CONFIG "config"
@ -224,24 +226,24 @@ enum {
#define FLUID_NAME_GUIDING "fluid_guiding"
/* Fluid object names.*/
#define FLUID_NAME_FLAGS "flags"
#define FLUID_NAME_VELOCITY "vel"
#define FLUID_NAME_VELOCITYTMP "velocityTmp"
#define FLUID_NAME_FLAGS "flags" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITY "velocity" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITYTMP "velocity_previous" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITYX "x_vel"
#define FLUID_NAME_VELOCITYY "y_vel"
#define FLUID_NAME_VELOCITYZ "z_vel"
#define FLUID_NAME_PRESSURE "pressure"
#define FLUID_NAME_PHIOBS "phiObs"
#define FLUID_NAME_PHIOBS "phi_obstacle" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHISIN "phiSIn"
#define FLUID_NAME_PHIIN "phiIn"
#define FLUID_NAME_PHIOUT "phiOut"
#define FLUID_NAME_PHIIN "phi_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHIOUT "phi_out" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FORCES "forces"
#define FLUID_NAME_FORCE_X "x_force"
#define FLUID_NAME_FORCE_Y "y_force"
#define FLUID_NAME_FORCE_Z "z_force"
#define FLUID_NAME_NUMOBS "numObs"
#define FLUID_NAME_PHIOBSSIN "phiObsSIn"
#define FLUID_NAME_PHIOBSIN "phiObsIn"
#define FLUID_NAME_PHIOBSIN "phi_obstacle_inflow"
#define FLUID_NAME_OBVEL "obvel"
#define FLUID_NAME_OBVELC "obvelC"
#define FLUID_NAME_OBVEL_X "x_obvel"
@ -254,44 +256,48 @@ enum {
#define FLUID_NAME_INVEL_Y "y_invel"
#define FLUID_NAME_INVEL_Z "z_invel"
#define FLUID_NAME_PHIOUTSIN "phiOutSIn"
#define FLUID_NAME_PHIOUTIN "phiOutIn"
#define FLUID_NAME_PHIOUTIN "phi_out_inflow"
/* Smoke object names. */
#define FLUID_NAME_SHADOW "shadow"
#define FLUID_NAME_EMISSION "emission"
#define FLUID_NAME_SHADOW "shadow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_EMISSION "emission" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_EMISSIONIN "emissionIn"
#define FLUID_NAME_DENSITY "density"
#define FLUID_NAME_DENSITYIN "densityIn"
#define FLUID_NAME_DENSITY "density" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_DENSITYIN "density_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_HEAT "heat"
#define FLUID_NAME_HEATIN "heatIn"
#define FLUID_NAME_COLORR "color_r"
#define FLUID_NAME_COLORG "color_g"
#define FLUID_NAME_COLORB "color_b"
#define FLUID_NAME_COLORRIN "color_r_in"
#define FLUID_NAME_COLORGIN "color_g_in"
#define FLUID_NAME_COLORBIN "color_b_in"
#define FLUID_NAME_FLAME "flame"
#define FLUID_NAME_FUEL "fuel"
#define FLUID_NAME_REACT "react"
#define FLUID_NAME_FUELIN "fuelIn"
#define FLUID_NAME_REACTIN "reactIn"
#define FLUID_NAME_TEMPERATURE "temperature" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_TEMPERATUREIN "temperature_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORR "color_r" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORG "color_g" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORB "color_b" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORRIN "color_r_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORGIN "color_g_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORBIN "color_b_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FLAME "flame" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FUEL "fuel" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_REACT "react" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FUELIN "fuel_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_REACTIN "react_inflow" /* == OpenVDB grid attribute name. */
/* Liquid object names. */
#define FLUID_NAME_PHIPARTS "phiParts"
#define FLUID_NAME_PHI "phi"
#define FLUID_NAME_PHITMP "phiTmp"
#define FLUID_NAME_PHIPARTS "phi_particles" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHI "phi" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHITMP "phi_previous" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITYOLD "velOld"
#define FLUID_NAME_VELOCITYPARTS "velParts"
#define FLUID_NAME_MAPWEIGHTS "mapWeights"
#define FLUID_NAME_PP "pp"
#define FLUID_NAME_PVEL "pVel"
#define FLUID_NAME_PARTS "particles" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PARTSVELOCITY "particles_velocity" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PINDEX "pindex"
#define FLUID_NAME_GPI "gpi"
#define FLUID_NAME_CURVATURE "gpi"
/* Noise object names. */
#define FLUID_NAME_VELOCITY_NOISE "velocity_noise"
#define FLUID_NAME_DENSITY_NOISE "density_noise"
#define FLUID_NAME_DENSITY_NOISE "density_noise" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHIIN_NOISE "phiIn_noise"
#define FLUID_NAME_PHIOUT_NOISE "phiOut_noise"
#define FLUID_NAME_PHIOBS_NOISE "phiObs_noise"
@ -306,11 +312,11 @@ enum {
#define FLUID_NAME_TEXTURE_U2 "textureU2"
#define FLUID_NAME_TEXTURE_V2 "textureV2"
#define FLUID_NAME_TEXTURE_W2 "textureW2"
#define FLUID_NAME_UV0 "uvGrid0"
#define FLUID_NAME_UV1 "uvGrid1"
#define FLUID_NAME_COLORR_NOISE "color_r_noise"
#define FLUID_NAME_COLORG_NOISE "color_g_noise"
#define FLUID_NAME_COLORB_NOISE "color_b_noise"
#define FLUID_NAME_UV0 "uv_grid_0" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_UV1 "uv_grid_1" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORR_NOISE "color_r_noise" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORG_NOISE "color_g_noise" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_COLORB_NOISE "color_b_noise" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FLAME_NOISE "flame_noise"
#define FLUID_NAME_FUEL_NOISE "fuel_noise"
#define FLUID_NAME_REACT_NOISE "react_noise"
@ -321,7 +327,8 @@ enum {
#define FLUID_NAME_PP_MESH "pp_mesh"
#define FLUID_NAME_FLAGS_MESH "flags_mesh"
#define FLUID_NAME_LMESH "lMesh"
#define FLUID_NAME_VELOCITYVEC_MESH "lVelMesh"
#define FLUID_NAME_VELOCITYVEC_MESH "vertex_velocities_mesh" /* == OpenVDB grid attribute name. \
*/
#define FLUID_NAME_VELOCITY_MESH "velocity_mesh"
#define FLUID_NAME_PINDEX_MESH "pindex_mesh"
#define FLUID_NAME_GPI_MESH "gpi_mesh"
@ -329,18 +336,27 @@ enum {
/* Particles object names. */
#define FLUID_NAME_PP_PARTICLES "ppSnd"
#define FLUID_NAME_PVEL_PARTICLES "pVelSnd"
#define FLUID_NAME_PFORCE_PARTICLES "pForceSnd"
#define FLUID_NAME_PLIFE_PARTICLES "pLifeSnd"
#define FLUID_NAME_VELOCITY_PARTICLES "velocity_particles"
#define FLUID_NAME_FLAGS_PARTICLES "flags_particles"
#define FLUID_NAME_PHI_PARTICLES "phi_particles"
#define FLUID_NAME_PHIOBS_PARTICLES "phiObs_particles"
#define FLUID_NAME_PHIOUT_PARTICLES "phiOut_particles"
#define FLUID_NAME_NORMAL_PARTICLES "normal_particles"
#define FLUID_NAME_NEIGHBORRATIO_PARTICLES "neighborRatio_particles"
#define FLUID_NAME_TRAPPEDAIR_PARTICLES "trappedAir_particles"
#define FLUID_NAME_WAVECREST_PARTICLES "waveCrest_particles"
#define FLUID_NAME_KINETICENERGY_PARTICLES "kineticEnergy_particles"
#define FLUID_NAME_PFORCE_PARTICLES "pForceSnd"
#define FLUID_NAME_PARTS_PARTICLES "particles_secondary" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PARTSVEL_PARTICLES \
"particles_velocity_secondary" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PARTSLIFE_PARTICLES \
"particles_life_secondary" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PARTSFORCE_PARTICLES "particles_force_secondary"
#define FLUID_NAME_VELOCITY_PARTICLES "velocity_secondary"
#define FLUID_NAME_FLAGS_PARTICLES "flags_secondary"
#define FLUID_NAME_PHI_PARTICLES "phi_secondary"
#define FLUID_NAME_PHIOBS_PARTICLES "phiObs_secondary"
#define FLUID_NAME_PHIOUT_PARTICLES "phiOut_secondary"
#define FLUID_NAME_NORMAL_PARTICLES "normal_secondary"
#define FLUID_NAME_NEIGHBORRATIO_PARTICLES "neighbor_ratio_secondary"
#define FLUID_NAME_TRAPPEDAIR_PARTICLES \
"trapped_air_secondary" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_WAVECREST_PARTICLES "wave_crest_secondary" /* == OpenVDB grid attribute name. \
*/
#define FLUID_NAME_KINETICENERGY_PARTICLES \
"kinetic_energy_secondary" /* == OpenVDB grid attribute name. */
/* Guiding object names. */
#define FLUID_NAME_VELT "velT"
@ -349,9 +365,9 @@ enum {
#define FLUID_NAME_PHIGUIDEIN "phiGuideIn"
#define FLUID_NAME_GUIDEVELC "guidevelC"
#define FLUID_NAME_GUIDEVEL_X "x_guidevel"
#define FLUID_NAME_GUIDEVEL_Y "Y_guidevel"
#define FLUID_NAME_GUIDEVEL_Y "y_guidevel"
#define FLUID_NAME_GUIDEVEL_Z "z_guidevel"
#define FLUID_NAME_GUIDEVEL "guidevel"
#define FLUID_NAME_GUIDEVEL "velocity_guide"
/* Cache file extensions. */
#define FLUID_DOMAIN_EXTENSION_UNI ".uni"
@ -374,7 +390,18 @@ enum {
enum {
FLUID_DOMAIN_CACHE_REPLAY = 0,
FLUID_DOMAIN_CACHE_MODULAR = 1,
FLUID_DOMAIN_CACHE_FINAL = 2,
FLUID_DOMAIN_CACHE_ALL = 2,
};
enum {
VDB_COMPRESSION_BLOSC = 0,
VDB_COMPRESSION_ZIP = 1,
VDB_COMPRESSION_NONE = 2,
};
enum {
VDB_PRECISION_HALF_FLOAT = 0,
VDB_PRECISION_FULL_FLOAT = 1,
};
/* Deprecated values (i.e. all defines and enums below this line up until typedefs). */
@ -391,12 +418,6 @@ enum {
SM_HRES_FULLSAMPLE = 2,
};
enum {
VDB_COMPRESSION_BLOSC = 0,
VDB_COMPRESSION_ZIP = 1,
VDB_COMPRESSION_NONE = 2,
};
typedef struct FluidDomainVertexVelocity {
float vel[3];
} FluidDomainVertexVelocity;
@ -566,7 +587,8 @@ typedef struct FluidDomainSettings {
char cache_directory[1024];
char error[64]; /* Bake error description. */
short cache_type;
char _pad8[2]; /* Unused. */
char cache_id[4]; /* Run-time only */
char _pad8[6];
/* Time options. */
float dt;
@ -591,17 +613,17 @@ typedef struct FluidDomainSettings {
char coba_field; /* Simulation field used for the color mapping. */
char interp_method;
/* OpenVDB cache options. */
int openvdb_compression;
float clipping;
char openvdb_data_depth;
char _pad9[7]; /* Unused. */
/* -- Deprecated / unsed options (below). -- */
/* View options. */
int viewsettings;
char _pad9[4]; /* Unused. */
/* OpenVDB cache options. */
int openvdb_comp;
float clipping;
char data_depth;
char _pad10[7]; /* Unused. */
char _pad10[4]; /* Unused. */
/* Pointcache options. */
/* Smoke uses only one cache from now on (index [0]), but keeping the array for now for reading

View File

@ -557,7 +557,7 @@ static const EnumPropertyItem *rna_Fluid_cachetype_mesh_itemf(bContext *UNUSED(C
}
static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED(C),
PointerRNA *UNUSED(ptr),
PointerRNA *ptr,
PropertyRNA *UNUSED(prop),
bool *r_free)
{
@ -579,11 +579,16 @@ static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED
RNA_enum_item_add(&item, &totitem, &tmp);
# endif
tmp.value = FLUID_DOMAIN_FILE_RAW;
tmp.identifier = "RAW";
tmp.name = "Raw Cache";
tmp.description = "Raw file format (.raw)";
RNA_enum_item_add(&item, &totitem, &tmp);
/* Support for deprecated .raw format. */
FluidDomainSettings *mds = (FluidDomainSettings *)ptr->data;
if (mds->cache_data_format == FLUID_DOMAIN_FILE_RAW ||
mds->cache_noise_format == FLUID_DOMAIN_FILE_RAW) {
tmp.value = FLUID_DOMAIN_FILE_RAW;
tmp.identifier = "RAW";
tmp.name = "Raw Cache";
tmp.description = "Raw file format (.raw)";
RNA_enum_item_add(&item, &totitem, &tmp);
}
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@ -1058,27 +1063,18 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
};
static EnumPropertyItem cache_types[] = {
{FLUID_DOMAIN_CACHE_REPLAY,
"REPLAY",
0,
"Replay",
"Use the timeline to bake the scene. Pausing and resuming possible"},
{FLUID_DOMAIN_CACHE_REPLAY, "REPLAY", 0, "Replay", "Use the timeline to bake the scene"},
{FLUID_DOMAIN_CACHE_MODULAR,
"MODULAR",
0,
"Modular",
"Bake every stage of the simulation separately. Pausing and resuming possible"},
{FLUID_DOMAIN_CACHE_FINAL,
"FINAL",
0,
"Final",
"Bake the entire simulation at once. Only generates the most essential cache files. "
"Pausing and resuming not possible"},
"Bake every stage of the simulation separately"},
{FLUID_DOMAIN_CACHE_ALL, "ALL", 0, "All", "Bake all simulation settings at once"},
{0, NULL, 0, NULL, NULL}};
static const EnumPropertyItem smoke_data_depth_items[] = {
{16, "16", 0, "Float (Half)", "Half float (16 bit data)"},
{0, "32", 0, "Float (Full)", "Full float (32 bit data)"}, /* default */
static const EnumPropertyItem fluid_data_depth_items[] = {
{VDB_PRECISION_HALF_FLOAT, "16", 0, "Half", "Half float (16 bit data)"},
{VDB_PRECISION_FULL_FLOAT, "32", 0, "Full", "Full float (32 bit data)"},
{0, NULL, 0, NULL, NULL},
};
@ -2072,6 +2068,16 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_reset");
prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_RESUMABLE_CACHE);
RNA_def_property_ui_text(
prop,
"Resumable",
"Additional data will be saved so that the bake jobs can be resumed after pausing. Because "
"more data will be written to disk it is recommended to avoid enabling this option when "
"baking at high resolutions");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_maxlength(prop, FILE_MAX);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Fluid_cache_directory_set");
@ -2320,13 +2326,13 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
/* OpenVDB options */
prop = RNA_def_property(srna, "openvdb_cache_compress_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "openvdb_comp");
RNA_def_property_enum_sdna(prop, NULL, "openvdb_compression");
RNA_def_property_enum_items(prop, prop_compression_items);
RNA_def_property_ui_text(prop, "Compression", "Compression method to be used");
RNA_def_property_ui_text(prop, "Compression", "facession method to be used");
prop = RNA_def_property(srna, "data_depth", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "data_depth");
RNA_def_property_enum_items(prop, smoke_data_depth_items);
prop = RNA_def_property(srna, "openvdb_data_depth", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "openvdb_data_depth");
RNA_def_property_enum_items(prop, fluid_data_depth_items);
RNA_def_property_ui_text(prop,
"Data Depth",
"Bit depth for writing all scalar (including vector) "