blender/release/scripts/startup/bl_ui/properties_physics_softbody.py

264 lines
7.7 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
from bpy.types import Panel
2011-11-11 03:28:46 +00:00
from .properties_physics_common import (
point_cache_ui,
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):
2010-08-18 08:26:18 +00:00
return (md.point_cache.is_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():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine) and (context.soft_body)
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
bl_label = "Soft Body"
def draw(self, context):
layout = self.layout
md = context.soft_body
ob = context.object
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_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Mass:")
col = split.column()
col.label(text="Simulation:")
col.prop(softbody, "speed")
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Cache"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.soft_body
def draw(self, context):
md = context.soft_body
2010-05-11 20:06:20 +00:00
point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Goal"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, 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
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")
col = split.column()
col.label(text="Goal Settings:")
col.prop(softbody, "goal_spring", text="Stiffness")
col.prop(softbody, "goal_friction", text="Damping")
layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group")
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Edges"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, 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
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")
2010-08-21 04:51:00 +00:00
col.prop(softbody, "damping")
col.prop(softbody, "plastic")
col.prop(softbody, "bend")
col.prop(softbody, "spring_length", text="Length")
col.prop_search(softbody, "vertex_group_spring", ob, "vertex_groups", text="Springs:")
col = split.column()
col.prop(softbody, "use_stiff_quads")
sub = col.column()
sub.active = softbody.use_stiff_quads
sub.prop(softbody, "shear")
col.label(text="Aerodynamics:")
col.row().prop(softbody, "aerodynamics_type", expand=True)
col.prop(softbody, "aero", text="Factor")
#sub = col.column()
#sub.enabled = softbody.aero > 0
col.label(text="Collision:")
col.prop(softbody, "use_edge_collision", text="Edge")
col.prop(softbody, "use_face_collision", text="Face")
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Self Collision"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, 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_self_collision", text="")
def draw(self, context):
layout = self.layout
md = context.soft_body
softbody = md.settings
layout.active = softbody.use_self_collision and softbody_panel_enabled(md)
layout.label(text="Collision Ball Size Calculation:")
layout.prop(softbody, "collision_type", expand=True)
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, Panel):
bl_label = "Soft Body Solver"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.soft_body
def draw(self, context):
layout = self.layout
md = context.soft_body
softbody = md.settings
layout.active = softbody_panel_enabled(md)
# Solver
split = layout.split()
col = split.column(align=True)
col.label(text="Step Size:")
col.prop(softbody, "step_min")
col.prop(softbody, "step_max")
col.prop(softbody, "use_auto_step", text="Auto-Step")
col = split.column()
col.prop(softbody, "error_threshold")
col.label(text="Helpers:")
col.prop(softbody, "choke")
col.prop(softbody, "fuzzy")
layout.label(text="Diagnostics:")
layout.prop(softbody, "use_diagnose")
layout.prop(softbody, "use_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
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
bl_label = "Soft Body Field Weights"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return (context.soft_body)
def draw(self, context):
md = context.soft_body
softbody = md.settings
effector_weights_ui(self, context, softbody.effector_weights)
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)