blender/release/ui/buttons_physic_cloth.py
Janne Karhu 912c2f440b Pointcache refresh part 2
* Based on what happens during simulation the cache is marked (also in cache panel, this could possibly be extended to 3d view as well) as:
	- exact (not marked)
	- outdated (simulation is not done completely with current settings)
	- non-exact (frames were skipped during simulation)

* The parameter "cache step" effects the number of frames between saved cache frames.
	- This can save a lot of memory (or disk space) if absolutely frame accurate simulation is not required.
	- Speeds up the "quick caching" very much.
	- Frames between cached frames are interpolated from the cached frames.
	- Current default value of 10 frames works nicely with up/down-arrows (skip 10 frames forwards/backwards on timeline), but can be changed if wanted.

* The caching can work in normal or "quick" mode:
	[Normal cache]
	- Basic: Calculate what even happens (settings change, big frame steps etc.) and cache results, if possible try to use "cache step" when saving cache frames.
	- Becomes non-exact: After larger than 1 frame steps.
	- Becomes outdated: After any change effecting the simulation other than frame steps.
	- Pros/cons: Freedom of doing anything and playing with particles, but exact results have to calculated from the beginning.

	[Quick cache]
	- Basic: Calculate simulation up to current frame automatically on changes with cache step sized jumps in simulation. With multiple "quick cached" simulations the smallest cache step is used.
	- Becomes non-exact: Always from frame 1 (unless cache step = 1).
	- Becomes outdated: Never.
	- Pros/cons: Not very accurate, but super fast!
	- Todo: Transform of any animated (non-autokeyed) object is locked! Probably needs some tinkering with anim sys overrides.

* The simulation can be run forwards or backwards even if it's cache is outdated or non-exact, the following rules apply in these situations:
	- step forwards (to unknown) -> simulate from last exact frame, store result
	- step backwards (to known) -> result is interpolated from existing frames, store result, clear cache forwards if current frame is after last exact frame

* "Calculate to current frame" runs the simulation from start to current frame with a frame steps of 1.
	- Baking does the same, but runs the simulation all the way to the end of simulation.
	- Rendering does this automatically if the simulation is outdated of non-exact, so all rendered simulations will always be updated and exact.
	
* Every cache panel also holds buttons to "Bake all dynamics", "Free all dynamics" and "Update all dynamics to current frame".

* Cloth simulation supports the new cache too.
2009-06-27 15:28:58 +00:00

155 lines
4.3 KiB
Python

import bpy
class PhysicButtonsPanel(bpy.types.Panel):
__space_type__ = "BUTTONS_WINDOW"
__region_type__ = "WINDOW"
__context__ = "physics"
def poll(self, context):
return (context.cloth != None)
class Physic_PT_cloth(PhysicButtonsPanel):
__idname__ = "Physic_PT_cloth"
__label__ = "Cloth"
def draw(self, context):
layout = self.layout
cloth = context.cloth.settings
split = layout.split()
col = split.column()
col.itemR(cloth, "quality", slider=True)
col.itemR(cloth, "gravity")
col.itemR(cloth, "mass")
col.itemR(cloth, "mass_vertex_group", text="Vertex Group")
col = split.column()
col.itemL(text="Stiffness:")
col.itemR(cloth, "structural_stiffness", text="Structural")
col.itemR(cloth, "bending_stiffness", text="Bending")
col.itemL(text="Damping:")
col.itemR(cloth, "spring_damping", text="Spring")
col.itemR(cloth, "air_damping", text="Air")
# Disabled for now
"""
if cloth.mass_vertex_group:
layout.itemL(text="Goal:")
col = layout.column_flow()
col.itemR(cloth, "goal_default", text="Default")
col.itemR(cloth, "goal_spring", text="Stiffness")
col.itemR(cloth, "goal_friction", text="Friction")
"""
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
__idname__= "PHYSICS_PT_cloth_cache"
__label__ = "Cache"
__default_closed__ = True
def draw(self, context):
layout = self.layout
cache = context.cloth.point_cache
row = layout.row()
row.itemR(cache, "name")
row = layout.row()
row.itemR(cache, "start_frame")
row.itemR(cache, "end_frame")
row = layout.row()
if cache.baked == True:
row.itemO("PTCACHE_OT_free_bake_cloth", text="Free Bake")
else:
row.item_booleanO("PTCACHE_OT_cache_cloth", "bake", True, text="Bake")
subrow = row.row()
subrow.enabled = cache.frames_skipped or cache.outdated
subrow.itemO("PTCACHE_OT_cache_cloth", text="Calculate to Current Frame")
row = layout.row()
#row.enabled = particle_panel_enabled(psys)
row.itemO("PTCACHE_OT_bake_from_cloth_cache", text="Current Cache to Bake")
row.itemR(cache, "step");
row = layout.row()
#row.enabled = particle_panel_enabled(psys)
row.itemR(cache, "quick_cache")
row.itemR(cache, "disk_cache")
layout.itemL(text=cache.info)
layout.itemS()
row = layout.row()
row.itemO("PTCACHE_OT_bake_all", "bake", True, text="Bake All Dynamics")
row.itemO("PTCACHE_OT_free_bake_all", text="Free All Bakes")
layout.itemO("PTCACHE_OT_bake_all", text="Update All Dynamics to current frame")
class Physic_PT_cloth_collision(PhysicButtonsPanel):
__idname__ = "Physic_PT_clothcollision"
__label__ = "Cloth Collision"
def draw_header(self, context):
layout = self.layout
cloth = context.cloth.collision_settings
layout.itemR(cloth, "enable_collision", text="")
def draw(self, context):
layout = self.layout
cloth = context.cloth.collision_settings
layout.active = cloth.enable_collision
col = layout.column_flow()
col.itemR(cloth, "collision_quality", slider=True)
col.itemR(cloth, "friction")
col.itemR(cloth, "min_distance", text="MinDistance")
layout.itemR(cloth, "enable_self_collision", text="Self Collision")
col = layout.column_flow()
col.active = cloth.enable_self_collision
col.itemR(cloth, "self_collision_quality", slider=True)
col.itemR(cloth, "self_min_distance", text="MinDistance")
class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
__idname__ = "Physic_PT_stiffness"
__label__ = "Cloth Stiffness Scaling"
def draw_header(self, context):
layout = self.layout
cloth = context.cloth.settings
layout.itemR(cloth, "stiffness_scaling", text="")
def draw(self, context):
layout = self.layout
cloth = context.cloth.settings
layout.active = cloth.stiffness_scaling
split = layout.split()
sub = split.column()
sub.itemL(text="Structural Stiffness:")
sub.column().itemR(cloth, "structural_stiffness_vertex_group", text="VGroup")
sub.itemR(cloth, "structural_stiffness_max", text="Max")
sub = split.column()
sub.itemL(text="Bending Stiffness:")
sub.column().itemR(cloth, "bending_vertex_group", text="VGroup")
sub.itemR(cloth, "bending_stiffness_max", text="Max")
bpy.types.register(Physic_PT_cloth)
bpy.types.register(PHYSICS_PT_cloth_cache)
bpy.types.register(Physic_PT_cloth_collision)
bpy.types.register(Physic_PT_cloth_stiffness)