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-07-02 19:41:31 +00:00
|
|
|
import bpy
|
|
|
|
|
2009-11-19 12:58:19 +00:00
|
|
|
narrowui = 180
|
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-10-31 19:57:59 +00:00
|
|
|
from properties_physics_common import point_cache_ui
|
|
|
|
from properties_physics_common import 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 softbody_panel_enabled(md):
|
2009-11-22 17:41:35 +00:00
|
|
|
return (md.point_cache.baked is False)
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-08-29 15:20:36 +00:00
|
|
|
|
2009-07-02 19:41:31 +00:00
|
|
|
class PhysicButtonsPanel(bpy.types.Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "physics"
|
|
|
|
|
|
|
|
def poll(self, context):
|
|
|
|
ob = context.object
|
2010-02-23 12:48:35 +00:00
|
|
|
rd = context.scene.render
|
2010-03-13 22:53:03 +00:00
|
|
|
# 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)
|
2010-03-13 22:53:03 +00:00
|
|
|
return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine)
|
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-07-02 19:41:31 +00:00
|
|
|
class PHYSICS_PT_softbody(PhysicButtonsPanel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
md = context.soft_body
|
|
|
|
ob = context.object
|
2009-11-19 13:26:51 +00:00
|
|
|
wide_ui = context.region.width > narrowui
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
split = layout.split()
|
2009-11-16 13:59:27 +00:00
|
|
|
split.operator_context = 'EXEC_DEFAULT'
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
if md:
|
|
|
|
# remove modifier + settings
|
|
|
|
split.set_context_pointer("modifier", md)
|
2009-11-23 00:27:30 +00:00
|
|
|
split.operator("object.modifier_remove", text="Remove")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
row = split.row(align=True)
|
2009-11-23 00:27:30 +00:00
|
|
|
row.prop(md, "render", text="")
|
|
|
|
row.prop(md, "realtime", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
else:
|
|
|
|
# add modifier
|
2009-11-23 11:43:38 +00:00
|
|
|
split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY'
|
2009-11-19 13:26:51 +00:00
|
|
|
if wide_ui:
|
2009-11-19 12:58:19 +00:00
|
|
|
split.column()
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
if md:
|
|
|
|
softbody = md.settings
|
|
|
|
|
|
|
|
# General
|
|
|
|
split = layout.split()
|
|
|
|
split.enabled = softbody_panel_enabled(md)
|
|
|
|
|
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Object:")
|
|
|
|
col.prop(softbody, "friction")
|
|
|
|
col.prop(softbody, "mass")
|
2009-11-23 11:43:38 +00:00
|
|
|
col.prop_object(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2009-11-19 13:26:51 +00:00
|
|
|
if wide_ui:
|
2009-11-19 13:22:10 +00:00
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Simulation:")
|
|
|
|
col.prop(softbody, "speed")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-08-02 19:39:33 +00:00
|
|
|
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body Cache"
|
|
|
|
bl_default_closed = True
|
|
|
|
|
|
|
|
def poll(self, context):
|
|
|
|
return context.soft_body
|
2009-08-02 19:39:33 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
md = context.soft_body
|
2009-11-18 21:57:13 +00:00
|
|
|
point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 0, 0)
|
2009-08-02 19:39:33 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-07-03 20:03:24 +00:00
|
|
|
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
|
2009-10-31 19:31:45 +00:00
|
|
|
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)
|
2009-11-23 00:27:30 +00:00
|
|
|
self.layout.prop(softbody, "use_goal", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
md = context.soft_body
|
|
|
|
softbody = md.settings
|
|
|
|
ob = context.object
|
2009-11-19 13:26:51 +00:00
|
|
|
wide_ui = context.region.width > narrowui
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
layout.active = softbody.use_goal and softbody_panel_enabled(md)
|
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
# Goal
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Goal Strengths:")
|
|
|
|
col.prop(softbody, "goal_default", text="Default")
|
2009-10-31 19:31:45 +00:00
|
|
|
sub = col.column(align=True)
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.prop(softbody, "goal_min", text="Minimum")
|
|
|
|
sub.prop(softbody, "goal_max", text="Maximum")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2009-11-19 13:26:51 +00:00
|
|
|
if wide_ui:
|
2009-11-19 13:22:10 +00:00
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Goal Settings:")
|
|
|
|
col.prop(softbody, "goal_spring", text="Stiffness")
|
|
|
|
col.prop(softbody, "goal_friction", text="Damping")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-11-23 11:43:38 +00:00
|
|
|
layout.prop_object(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
|
2009-07-03 20:03:24 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-07-03 20:03:24 +00:00
|
|
|
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
|
2009-10-31 19:31:45 +00:00
|
|
|
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)
|
2009-11-23 00:27:30 +00:00
|
|
|
self.layout.prop(softbody, "use_edges", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
md = context.soft_body
|
|
|
|
softbody = md.settings
|
|
|
|
ob = context.object
|
2009-11-19 13:26:51 +00:00
|
|
|
wide_ui = context.region.width > narrowui
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
layout.active = softbody.use_edges and softbody_panel_enabled(md)
|
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
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")
|
2009-11-23 11:43:38 +00:00
|
|
|
col.prop_object(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2009-11-19 13:26:51 +00:00
|
|
|
if wide_ui:
|
2009-11-19 13:22:10 +00:00
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(softbody, "stiff_quads")
|
2009-10-31 19:31:45 +00:00
|
|
|
sub = col.column()
|
|
|
|
sub.active = softbody.stiff_quads
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.prop(softbody, "shear")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(softbody, "new_aero", text="Aero")
|
2009-10-31 19:31:45 +00:00
|
|
|
sub = col.column()
|
|
|
|
sub.enabled = softbody.new_aero
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.prop(softbody, "aero", text="Factor")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Collision:")
|
|
|
|
col.prop(softbody, "edge_collision", text="Edge")
|
|
|
|
col.prop(softbody, "face_collision", text="Face")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-07-03 20:03:24 +00:00
|
|
|
class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
|
2009-10-31 19:31:45 +00:00
|
|
|
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)
|
2009-11-23 00:27:30 +00:00
|
|
|
self.layout.prop(softbody, "self_collision", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
md = context.soft_body
|
|
|
|
softbody = md.settings
|
2009-11-19 13:26:51 +00:00
|
|
|
wide_ui = context.region.width > narrowui
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
layout.active = softbody.self_collision and softbody_panel_enabled(md)
|
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.label(text="Collision Type:")
|
2009-11-19 13:26:51 +00:00
|
|
|
if wide_ui:
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.prop(softbody, "collision_type", expand=True)
|
2009-11-19 13:22:10 +00:00
|
|
|
else:
|
2009-11-23 00:27:30 +00:00
|
|
|
layout.prop(softbody, "collision_type", text="")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
col = layout.column(align=True)
|
2009-11-23 00:27:30 +00:00
|
|
|
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")
|
2009-07-03 20:03:24 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2009-07-03 20:03:24 +00:00
|
|
|
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
|
2009-10-31 19:31:45 +00:00
|
|
|
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
|
2009-11-19 13:26:51 +00:00
|
|
|
wide_ui = context.region.width > narrowui
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
layout.active = softbody_panel_enabled(md)
|
|
|
|
|
|
|
|
# Solver
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
col = split.column(align=True)
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Step Size:")
|
|
|
|
col.prop(softbody, "minstep")
|
|
|
|
col.prop(softbody, "maxstep")
|
|
|
|
col.prop(softbody, "auto_step", text="Auto-Step")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2009-11-19 13:26:51 +00:00
|
|
|
if wide_ui:
|
2009-11-19 13:22:10 +00:00
|
|
|
col = split.column()
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(softbody, "error_limit")
|
|
|
|
col.label(text="Helpers:")
|
|
|
|
col.prop(softbody, "choke")
|
|
|
|
col.prop(softbody, "fuzzy")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
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
|
|
|
|
2009-10-31 23:35:56 +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):
|
2009-10-31 19:31:45 +00:00
|
|
|
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
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2009-11-18 21:57:13 +00:00
|
|
|
effector_weights_ui(self, context, softbody.effector_weights)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-02-14 11:21:21 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2010-02-22 23:32:58 +00:00
|
|
|
|
2010-02-14 11:21:21 +00:00
|
|
|
def unregister():
|
|
|
|
unregister = bpy.types.unregister
|
|
|
|
for cls in classes:
|
|
|
|
unregister(cls)
|
2010-02-16 09:55:07 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
register()
|