$ show rlguy/Blender-FLIP-Fluids
FLIP Fluids is a production-grade Blender addon for liquid simulation, integrating a custom C++ FLIP (Fluid Implicit Particle) engine with a comprehensive Python UI. The engine implements advanced numerical methods including level sets, variational pressure solvers, PCG with MIC(0) preconditioning, force fields, whitewater particles, and viscosity solvers, all backed by a vendored Eigen linear algebra library. The Blender addon provides property groups, UI panels, preset management, material libraries, and command-line scripts for baking, rendering, and Alembic/USD export. The architecture is a hybrid: the C++ engine is compiled as a shared library and accessed via C bindings and Python ctypes wrappers, while the addon code follows standard Blender patterns (operators, panels, property groups). Key entry points include the baking operators, simulation domain properties, and the engine's Python bindings in `ffengine/`. External dependencies include Blender (4.5+), Eigen, and optionally Mixbox for color blending. The codebase is well-structured with extensive version compatibility layers, but the vendored Eigen and reliance on Blender's evolving API introduce moderate technical drift.
The LLM identified 5 files worth highlighting for reuse:
A thread-safe, bounded producer-consumer queue implemented as a C++ template class. It uses mutexes and condition variables to block on push/pop when full/empty. This is a clean, self-contained utility that can be extracted into any multi-threaded C++ project requiring a bounded buffer pattern.
A memory-efficient dynamic array that stores elements in fixed-size chunks (default 5 MB). It supports push_back, sort with custom comparator, and random access. This is useful for particle systems or any scenario where large, growable arrays are needed without the overhead of contiguous reallocation. The design is isolated and can be reused in other simulation or data-processing projects.
A comprehensive utility module that abstracts Blender API differences across versions 2.79 to 5.2+. It provides functions like `is_blender_52()`, `get_geometry_nodes_modifier_input_keys()`, and `set_geometry_nodes_modifier_value()` with fallbacks. This pattern is directly reusable for any Blender addon that needs to support multiple Blender versions, reducing maintenance burden.
A set of Python decorators for validating function arguments in the ctypes-based engine bindings. Decorators like `check_ge` (greater-or-equal) and `ijk_or_gridindex` (accept either i,j,k tuple or GridIndex) provide clean, reusable input validation that can be applied to any Python wrapper around C libraries.
A C++ header providing safe, exception-handling wrappers for exposing C++ methods via a C API. It defines `safe_execute_method_*` macros that catch exceptions, set an error buffer, and return SUCCESS/FAIL. This pattern is reusable for any project that needs to bridge C++ and C with robust error handling.