Below is an attempt to define a clear set of rules to make working with baking and caching for physics systems usable. Everything is subject to change as this is implemented and tested to actually work or not.
- Bake + Free Cache / Free Bake
- First frame
- Last frame
- The user should never see outdated simulation results without manually pressing a Bake.
- Any change to the object or it's data, direct or indirect will clear it's point cache unless it is protected.
- Before the start time, the modifier does nothing. After the end time, the modifier displays the last frame, if it is cached. Otherwise, it does nothing.
- Avoid settings flags to do some operation like clearing a point cache or resetting a simulation later. If something has to be done, it should be done immediately.
sim frame is set to INVALID on creation, clear and file load
if mesh structure changed compared to simulation data: sim frame = INVALID else if current frame < first frame: sim frame = INVALID else: if current frame > last frame: current frame = last frame if simulation not initialized: initialize simulation if read current frame from cache: sim frame = current frame else if baked/protected: sim frame = INVALID else if current frame == first frame: sim frame = current frame write to cache else if current frame - sim frame == 1: sim frame = current frame simulate 1 frame write to cache else: sim frame = INVALID