blender/release/scripts/ui/properties_physics_softbody.py

309 lines
8.9 KiB
Python
Raw Normal View History

# ##### 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.
#
# 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.
#
# 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.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
narrowui = 180
from properties_physics_common import point_cache_ui
from properties_physics_common import effector_weights_ui
Point cache editing: - Baked point caches for particles, cloth and softbody can now be edited in particle mode. * This overwrites the old cloth/sb cache editmode editing. * The type of editable system is chosen from a menu. * For particles the current particle system and it's current cache are used. - Currently this only works for caches that are in memory, but some automatic conversion from disk to memory and back can be implemented later. - All tools from hair editing can't be applied to point caches and are hidden in the tool panel and specials menu. Some functionality like subdividing paths can be later implemented in a slightly different way from how it works for hair. - Code is not yet optimized for speed, so editing might be slow sometimes. Known issues: - Cloth doesn't update properly while in particle mode, due to the way cloth modifier currently works. Daniel can you check on this? - As "particle mode" is not only for particles any more some other name would be in place? - Better icons are needed for the path, point, and tip-modes as the current icons from mesh edit mode are quite misleading. - Direct editing of point velocities is not yet implemented, but will be in the future. Other changes: - Hair editing doesn't require a "make editable" button press any more. - Multiple caches in single particle system disables changing emission properties. - Unified ui code for all point cache panels. * Defined in buttons_particle.py and imported for cloth, smoke & softbody. - Proper disabling of properties in ui after baking point caches. (Daniel could you please make needed disable code for smoke panels as their functionality is not familiar to me.) - Hair weight brush has been removed. Once hair dynamics is re-implemented I'll code a more useable alternative to the functionality. Bug fixes: - Unlinking particle settings crashed. - Deleting the active object with particles in the scene crashed. - Softbody didn't write point caches correctly on save.
2009-08-29 15:20:36 +00:00
Point cache editing: - Baked point caches for particles, cloth and softbody can now be edited in particle mode. * This overwrites the old cloth/sb cache editmode editing. * The type of editable system is chosen from a menu. * For particles the current particle system and it's current cache are used. - Currently this only works for caches that are in memory, but some automatic conversion from disk to memory and back can be implemented later. - All tools from hair editing can't be applied to point caches and are hidden in the tool panel and specials menu. Some functionality like subdividing paths can be later implemented in a slightly different way from how it works for hair. - Code is not yet optimized for speed, so editing might be slow sometimes. Known issues: - Cloth doesn't update properly while in particle mode, due to the way cloth modifier currently works. Daniel can you check on this? - As "particle mode" is not only for particles any more some other name would be in place? - Better icons are needed for the path, point, and tip-modes as the current icons from mesh edit mode are quite misleading. - Direct editing of point velocities is not yet implemented, but will be in the future. Other changes: - Hair editing doesn't require a "make editable" button press any more. - Multiple caches in single particle system disables changing emission properties. - Unified ui code for all point cache panels. * Defined in buttons_particle.py and imported for cloth, smoke & softbody. - Proper disabling of properties in ui after baking point caches. (Daniel could you please make needed disable code for smoke panels as their functionality is not familiar to me.) - Hair weight brush has been removed. Once hair dynamics is re-implemented I'll code a more useable alternative to the functionality. Bug fixes: - Unlinking particle settings crashed. - Deleting the active object with particles in the scene crashed. - Softbody didn't write point caches correctly on save.
2009-08-29 15:20:36 +00:00
def softbody_panel_enabled(md):
return (md.point_cache.baked is False)
Point cache editing: - Baked point caches for particles, cloth and softbody can now be edited in particle mode. * This overwrites the old cloth/sb cache editmode editing. * The type of editable system is chosen from a menu. * For particles the current particle system and it's current cache are used. - Currently this only works for caches that are in memory, but some automatic conversion from disk to memory and back can be implemented later. - All tools from hair editing can't be applied to point caches and are hidden in the tool panel and specials menu. Some functionality like subdividing paths can be later implemented in a slightly different way from how it works for hair. - Code is not yet optimized for speed, so editing might be slow sometimes. Known issues: - Cloth doesn't update properly while in particle mode, due to the way cloth modifier currently works. Daniel can you check on this? - As "particle mode" is not only for particles any more some other name would be in place? - Better icons are needed for the path, point, and tip-modes as the current icons from mesh edit mode are quite misleading. - Direct editing of point velocities is not yet implemented, but will be in the future. Other changes: - Hair editing doesn't require a "make editable" button press any more. - Multiple caches in single particle system disables changing emission properties. - Unified ui code for all point cache panels. * Defined in buttons_particle.py and imported for cloth, smoke & softbody. - Proper disabling of properties in ui after baking point caches. (Daniel could you please make needed disable code for smoke panels as their functionality is not familiar to me.) - Hair weight brush has been removed. Once hair dynamics is re-implemented I'll code a more useable alternative to the functionality. Bug fixes: - Unlinking particle settings crashed. - Deleting the active object with particles in the scene crashed. - Softbody didn't write point caches correctly on save.
2009-08-29 15:20:36 +00:00
class PhysicButtonsPanel(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
def poll(self, context):
ob = context.object
rd = context.scene.render
# return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
2010-03-14 23:26:17 +00:00
# i really hate touching things i do not understand completely .. but i think this should read (bjornmose)
return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine)
class PHYSICS_PT_softbody(PhysicButtonsPanel):
bl_label = "Soft Body"
def draw(self, context):
layout = self.layout
md = context.soft_body
ob = context.object
wide_ui = context.region.width > narrowui
split = layout.split()
split.operator_context = 'EXEC_DEFAULT'
if md:
# remove modifier + settings
split.set_context_pointer("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
row.prop(md, "render", text="")
row.prop(md, "realtime", text="")
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY'
if wide_ui:
split.column()
if md:
softbody = md.settings
# General
split = layout.split()
split.enabled = softbody_panel_enabled(md)
col = split.column()
col.label(text="Object:")
col.prop(softbody, "friction")
col.prop(softbody, "mass")
col.prop_object(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
if wide_ui:
col = split.column()
col.label(text="Simulation:")
col.prop(softbody, "speed")
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
bl_label = "Soft Body Cache"
bl_default_closed = True
def poll(self, context):
return context.soft_body
def draw(self, context):
md = context.soft_body
point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 0, 0)
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
bl_label = "Soft Body Goal"
bl_default_closed = True
def poll(self, context):
return context.soft_body
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_goal", text="")
def draw(self, context):
layout = self.layout
md = context.soft_body
softbody = md.settings
ob = context.object
wide_ui = context.region.width > narrowui
layout.active = softbody.use_goal and softbody_panel_enabled(md)
split = layout.split()
# Goal
split = layout.split()
col = split.column()
col.label(text="Goal Strengths:")
col.prop(softbody, "goal_default", text="Default")
sub = col.column(align=True)
sub.prop(softbody, "goal_min", text="Minimum")
sub.prop(softbody, "goal_max", text="Maximum")
if wide_ui:
col = split.column()
col.label(text="Goal Settings:")
col.prop(softbody, "goal_spring", text="Stiffness")
col.prop(softbody, "goal_friction", text="Damping")
layout.prop_object(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
bl_label = "Soft Body Edges"
bl_default_closed = True
def poll(self, context):
return context.soft_body
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "use_edges", text="")
def draw(self, context):
layout = self.layout
md = context.soft_body
softbody = md.settings
ob = context.object
wide_ui = context.region.width > narrowui
layout.active = softbody.use_edges and softbody_panel_enabled(md)
split = layout.split()
col = split.column()
col.label(text="Springs:")
col.prop(softbody, "pull")
col.prop(softbody, "push")
col.prop(softbody, "damp")
col.prop(softbody, "plastic")
col.prop(softbody, "bending")
col.prop(softbody, "spring_length", text="Length")
col.prop_object(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
if wide_ui:
col = split.column()
col.prop(softbody, "stiff_quads")
sub = col.column()
sub.active = softbody.stiff_quads
sub.prop(softbody, "shear")
col.prop(softbody, "new_aero", text="Aero")
sub = col.column()
sub.enabled = softbody.new_aero
sub.prop(softbody, "aero", text="Factor")
col.label(text="Collision:")
col.prop(softbody, "edge_collision", text="Edge")
col.prop(softbody, "face_collision", text="Face")
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
bl_label = "Soft Body Collision"
bl_default_closed = True
def poll(self, context):
return context.soft_body
def draw_header(self, context):
softbody = context.soft_body.settings
self.layout.active = softbody_panel_enabled(context.soft_body)
self.layout.prop(softbody, "self_collision", text="")
def draw(self, context):
layout = self.layout
md = context.soft_body
softbody = md.settings
wide_ui = context.region.width > narrowui
layout.active = softbody.self_collision and softbody_panel_enabled(md)
layout.label(text="Collision Type:")
if wide_ui:
layout.prop(softbody, "collision_type", expand=True)
else:
layout.prop(softbody, "collision_type", text="")
col = layout.column(align=True)
col.label(text="Ball:")
col.prop(softbody, "ball_size", text="Size")
col.prop(softbody, "ball_stiff", text="Stiffness")
col.prop(softbody, "ball_damp", text="Dampening")
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
bl_label = "Soft Body Solver"
bl_default_closed = True
def poll(self, context):
return context.soft_body
def draw(self, context):
layout = self.layout
md = context.soft_body
softbody = md.settings
wide_ui = context.region.width > narrowui
layout.active = softbody_panel_enabled(md)
# Solver
split = layout.split()
col = split.column(align=True)
col.label(text="Step Size:")
col.prop(softbody, "minstep")
col.prop(softbody, "maxstep")
col.prop(softbody, "auto_step", text="Auto-Step")
if wide_ui:
col = split.column()
col.prop(softbody, "error_limit")
col.label(text="Helpers:")
col.prop(softbody, "choke")
col.prop(softbody, "fuzzy")
layout.label(text="Diagnostics:")
layout.prop(softbody, "diagnose")
2009-12-28 00:07:24 +00:00
layout.prop(softbody, "estimate_matrix")
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
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
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
bl_label = "Soft Body Field Weights"
bl_default_closed = True
def poll(self, context):
return (context.soft_body)
def draw(self, context):
md = context.soft_body
softbody = md.settings
effector_weights_ui(self, context, softbody.effector_weights)
classes = [
PHYSICS_PT_softbody,
PHYSICS_PT_softbody_cache,
PHYSICS_PT_softbody_goal,
PHYSICS_PT_softbody_edge,
PHYSICS_PT_softbody_collision,
PHYSICS_PT_softbody_solver,
PHYSICS_PT_softbody_field_weights]
def register():
register = bpy.types.register
for cls in classes:
register(cls)
def unregister():
unregister = bpy.types.unregister
for cls in classes:
unregister(cls)
if __name__ == "__main__":
register()