This is a little standalone python script written for the Tube project to solve some issues with cloth simulation. (code in attachments)
It implements reading/writing of the binary point cache format of Blender point caches to manipulate cached simulation data outside of Blender. The primary function is a low-pass filter being applied to cloth simulation to smooth out small-scale jittering artifacts.
I don’t intend to spend much more time on this, but thought it might be useful if others want to implement their own functionality. With the basic read/write methods in place it is fairly straightforward to add more actions to the script.
Note: The script only supports uncompressed point caches so far - it may be possible to support compression, but i’d rather not invest more time in it. Disk space is cheap!
Usage:
The script is a standalone python script (no bpy imports), which can be run directly in a python interpreter or from a terminal after making it executable (“chmod +x” on *nix). Running it will give you an over view of the command line options.
Note: I recommend making a backup of the point cache files, then go to the backup folder and run the script from there, using the --output argument to make it write back to the original directory where Blender expects the cache data. That way you don’t risk losing baked point cache data and can play around with the settings. The script asks for permission first if you try to overwrite cache files in the same folder.
usage: pointcache_doctor.py [-h] [-i [INPUT]] [-o [OUTPUT]] [-n [INDEX]] [--lowpass_factor [LOWPASS_FACTOR]]
{show,copy,lowpass}
Examine and fix Blender point cache data.
positional arguments:
{show,copy,lowpass} Action to perform on the point cache
optional arguments:
-h, --help show this help message and exit
-i [INPUT], --input [INPUT]
Input directory containing physics point cache files
-o [OUTPUT], --output [OUTPUT]
Output directory for modified point cache files
-n [INDEX], --index [INDEX]
Index of the cache if multiple caches exist in the
directory (default=0)
--lowpass_factor [LOWPASS_FACTOR]
Smoothing factor for the lowpass action
The “lowpass” action can be used to smooth out cloth movement over a few frames:
python pointcache_doctor.py lowpass --lowpass_factor=0.8
It uses exponential smoothing, i.e. the influence of a frame decreases exponentially over time. After N frames the influence of a past frame will mixed in with lowpass_factor^N (check the wikipedia article for in-depth info).
Attachments
pointcache_doctor.py.zip (3.84 KB)