Dev:Source/Physics/Point Cache

提供: wiki
< Dev:Source‎ | Physics
2018年6月29日 (金) 02:54時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Point Cache

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.

User Interface

  • Bake + Free Cache / Free Bake
  • First frame
  • Last frame

Rules

  • 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.

Logic

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