2009-11-01 15:21:20 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2009-11-03 07:23:02 +00:00
|
|
|
#
|
2009-11-01 15:21:20 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2009-11-03 07:23:02 +00:00
|
|
|
#
|
2009-11-01 15:21:20 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-11-01 15:21:20 +00:00
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
2009-10-31 20:16:59 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
# <pep8 compliant>
|
2009-05-25 18:32:28 +00:00
|
|
|
import bpy
|
2011-08-12 06:57:00 +00:00
|
|
|
from bpy.types import Menu, Panel
|
2009-11-19 12:58:19 +00:00
|
|
|
|
2012-10-08 08:28:05 +00:00
|
|
|
from bl_ui.properties_physics_common import (point_cache_ui,
|
|
|
|
effector_weights_ui)
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-08-29 15:20:36 +00:00
|
|
|
def cloth_panel_enabled(md):
|
2010-08-18 08:26:18 +00:00
|
|
|
return md.point_cache.is_baked is False
|
2009-11-28 23:37:56 +00:00
|
|
|
|
2009-11-22 10:32:37 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class CLOTH_MT_presets(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Cloth Presets"
|
2009-11-22 11:23:19 +00:00
|
|
|
preset_subdir = "cloth"
|
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
|
|
|
preset_operator = "script.execute_preset"
|
2011-08-12 06:57:00 +00:00
|
|
|
draw = Menu.draw_preset
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2010-08-02 02:55:12 +00:00
|
|
|
class PhysicButtonsPanel():
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "physics"
|
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
ob = context.object
|
2010-02-23 12:48:35 +00:00
|
|
|
rd = context.scene.render
|
2011-01-23 14:04:31 +00:00
|
|
|
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.cloth)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Cloth"
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
md = context.cloth
|
|
|
|
ob = context.object
|
2011-11-10 19:10:23 +00:00
|
|
|
cloth = md.settings
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
split = layout.split()
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
split.active = cloth_panel_enabled(md)
|
2009-12-04 17:54:48 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col = split.column()
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col.label(text="Presets:")
|
|
|
|
sub = col.row(align=True)
|
|
|
|
sub.menu("CLOTH_MT_presets", text=bpy.types.CLOTH_MT_presets.bl_label)
|
|
|
|
sub.operator("cloth.preset_add", text="", icon='ZOOMIN')
|
|
|
|
sub.operator("cloth.preset_add", text="", icon='ZOOMOUT').remove_active = True
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col.label(text="Quality:")
|
|
|
|
col.prop(cloth, "quality", text="Steps", slider=True)
|
2009-11-19 12:58:19 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col.label(text="Material:")
|
|
|
|
col.prop(cloth, "mass")
|
|
|
|
col.prop(cloth, "structural_stiffness", text="Structural")
|
|
|
|
col.prop(cloth, "bending_stiffness", text="Bending")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col = split.column()
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col.label(text="Damping:")
|
|
|
|
col.prop(cloth, "spring_damping", text="Spring")
|
|
|
|
col.prop(cloth, "air_damping", text="Air")
|
2012-01-23 01:35:14 +00:00
|
|
|
col.prop(cloth, "vel_damping", text="Velocity")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col.prop(cloth, "use_pin_cloth", text="Pinning")
|
|
|
|
sub = col.column()
|
|
|
|
sub.active = cloth.use_pin_cloth
|
|
|
|
sub.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="")
|
|
|
|
sub.prop(cloth, "pin_stiffness", text="Stiffness")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col.label(text="Pre roll:")
|
|
|
|
col.prop(cloth, "pre_roll", text="Frame")
|
2009-11-19 12:58:19 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
# Disabled for now
|
|
|
|
"""
|
|
|
|
if cloth.vertex_group_mass:
|
|
|
|
layout.label(text="Goal:")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
col = layout.column_flow()
|
|
|
|
col.prop(cloth, "goal_default", text="Default")
|
|
|
|
col.prop(cloth, "goal_spring", text="Stiffness")
|
|
|
|
col.prop(cloth, "goal_friction", text="Friction")
|
|
|
|
"""
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
key = ob.data.shape_keys
|
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
|
|
|
|
2011-11-10 19:10:23 +00:00
|
|
|
if key:
|
|
|
|
col.label(text="Rest Shape Key:")
|
|
|
|
col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="")
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2010-04-04 14:52:15 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Cloth Cache"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
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
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
md = context.cloth
|
2010-05-11 20:06:20 +00:00
|
|
|
point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Cloth Collision"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
cloth = context.cloth.collision_settings
|
|
|
|
|
|
|
|
self.layout.active = cloth_panel_enabled(context.cloth)
|
2010-08-20 06:09:58 +00:00
|
|
|
self.layout.prop(cloth, "use_collision", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
cloth = context.cloth.collision_settings
|
|
|
|
md = context.cloth
|
2012-06-06 13:30:05 +00:00
|
|
|
ob = context.object
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-20 06:09:58 +00:00
|
|
|
layout.active = cloth.use_collision and cloth_panel_enabled(md)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
col = split.column()
|
2011-09-21 15:18:38 +00:00
|
|
|
col.prop(cloth, "collision_quality", slider=True, text="Quality")
|
|
|
|
col.prop(cloth, "distance_min", slider=True, text="Distance")
|
|
|
|
col.prop(cloth, "repel_force", slider=True, text="Repel")
|
|
|
|
col.prop(cloth, "distance_repel", slider=True, text="Repel Distance")
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(cloth, "friction")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
col = split.column()
|
2011-09-21 15:18:38 +00:00
|
|
|
col.prop(cloth, "use_self_collision", text="Self Collision")
|
2009-10-31 19:31:45 +00:00
|
|
|
sub = col.column()
|
2010-08-20 06:09:58 +00:00
|
|
|
sub.active = cloth.use_self_collision
|
2011-09-21 15:18:38 +00:00
|
|
|
sub.prop(cloth, "self_collision_quality", slider=True, text="Quality")
|
|
|
|
sub.prop(cloth, "self_distance_min", slider=True, text="Distance")
|
2012-06-06 13:30:05 +00:00
|
|
|
sub.prop_search(cloth, "vertex_group_self_collisions", ob, "vertex_groups", text="")
|
2009-05-25 18:32:28 +00:00
|
|
|
|
2010-03-26 10:52:55 +00:00
|
|
|
layout.prop(cloth, "group")
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2010-04-04 14:52:15 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Cloth Stiffness Scaling"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
cloth = context.cloth.settings
|
|
|
|
|
|
|
|
self.layout.active = cloth_panel_enabled(context.cloth)
|
2010-08-20 06:09:58 +00:00
|
|
|
self.layout.prop(cloth, "use_stiffness_scale", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
md = context.cloth
|
|
|
|
ob = context.object
|
|
|
|
cloth = context.cloth.settings
|
|
|
|
|
2012-10-08 08:28:05 +00:00
|
|
|
layout.active = (cloth.use_stiffness_scale and cloth_panel_enabled(md))
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
col = split.column()
|
2011-09-21 15:18:38 +00:00
|
|
|
col.label(text="Structural Stiffness:")
|
2010-09-02 07:00:34 +00:00
|
|
|
col.prop_search(cloth, "vertex_group_structural_stiffness", ob, "vertex_groups", text="")
|
2011-09-21 15:18:38 +00:00
|
|
|
col.prop(cloth, "structural_stiffness_max", text="Max")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
col = split.column()
|
2011-09-21 15:18:38 +00:00
|
|
|
col.label(text="Bending Stiffness:")
|
2010-09-02 07:00:34 +00:00
|
|
|
col.prop_search(cloth, "vertex_group_bending", ob, "vertex_groups", text="")
|
2011-09-21 15:18:38 +00:00
|
|
|
col.prop(cloth, "bending_stiffness_max", text="Max")
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Cloth Field Weights"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
cloth = context.cloth.settings
|
2012-10-10 13:18:07 +00:00
|
|
|
effector_weights_ui(self, context, cloth.effector_weights, 'CLOTH')
|
2011-04-04 10:13:04 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
bpy.utils.register_module(__name__)
|