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
|
2011-08-12 06:57:00 +00:00
|
|
|
from bpy.types import Panel
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-03-21 12:35:49 +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 softbody_panel_enabled(md):
|
2010-08-18 08:26:18 +00:00
|
|
|
return (md.point_cache.is_baked is False)
|
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
|
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)
|
2011-01-23 14:04:31 +00:00
|
|
|
return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine) and (context.soft_body)
|
2010-03-13 22:53:03 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_softbody(PhysicButtonsPanel, Panel):
|
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
|
|
|
|
|
|
|
|
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")
|
2010-09-02 07:00:34 +00:00
|
|
|
col.prop_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Mass:")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2010-08-06 15:17:44 +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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body Cache"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
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
|
2010-05-11 20:06:20 +00:00
|
|
|
point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
|
2009-08-02 19:39:33 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body Goal"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-08-06 15:17:44 +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
|
|
|
|
2010-09-02 07:00:34 +00:00
|
|
|
layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group")
|
2009-07-03 20:03:24 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body Edges"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
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")
|
2010-08-21 04:51:00 +00:00
|
|
|
col.prop(softbody, "damping")
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(softbody, "plastic")
|
2010-08-20 06:09:58 +00:00
|
|
|
col.prop(softbody, "bend")
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(softbody, "spring_length", text="Length")
|
2010-09-02 07:00:34 +00:00
|
|
|
col.prop_search(softbody, "vertex_group_spring", ob, "vertex_groups", text="Springs:")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
col = split.column()
|
2010-08-20 06:09:58 +00:00
|
|
|
col.prop(softbody, "use_stiff_quads")
|
2009-10-31 19:31:45 +00:00
|
|
|
sub = col.column()
|
2010-08-20 06:09:58 +00:00
|
|
|
sub.active = softbody.use_stiff_quads
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.prop(softbody, "shear")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-06-30 02:34:34 +00:00
|
|
|
col.label(text="Aerodynamics:")
|
|
|
|
col.row().prop(softbody, "aerodynamics_type", expand=True)
|
2010-06-29 22:30:55 +00:00
|
|
|
col.prop(softbody, "aero", text="Factor")
|
2010-07-05 22:22:22 +00:00
|
|
|
|
2010-06-30 02:34:34 +00:00
|
|
|
#sub = col.column()
|
|
|
|
#sub.enabled = softbody.aero > 0
|
2010-07-05 22:22:22 +00:00
|
|
|
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Collision:")
|
2010-08-20 06:09:58 +00:00
|
|
|
col.prop(softbody, "use_edge_collision", text="Edge")
|
|
|
|
col.prop(softbody, "use_face_collision", text="Face")
|
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_softbody_collision(PhysicButtonsPanel, Panel):
|
2010-06-16 00:42:18 +00:00
|
|
|
bl_label = "Soft Body Self Collision"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
return context.soft_body
|
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
softbody = context.soft_body.settings
|
|
|
|
|
|
|
|
self.layout.active = softbody_panel_enabled(context.soft_body)
|
2010-08-20 06:09:58 +00:00
|
|
|
self.layout.prop(softbody, "use_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
|
|
|
|
|
2010-08-20 06:09:58 +00:00
|
|
|
layout.active = softbody.use_self_collision and softbody_panel_enabled(md)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-06-16 00:42:18 +00:00
|
|
|
layout.label(text="Collision Ball Size Calculation:")
|
2010-08-06 15:17:44 +00:00
|
|
|
layout.prop(softbody, "collision_type", expand=True)
|
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
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body Solver"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
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)
|
2009-11-23 00:27:30 +00:00
|
|
|
col.label(text="Step Size:")
|
2010-08-20 06:09:58 +00:00
|
|
|
col.prop(softbody, "step_min")
|
|
|
|
col.prop(softbody, "step_max")
|
2010-08-18 08:58:37 +00:00
|
|
|
col.prop(softbody, "use_auto_step", text="Auto-Step")
|
2009-11-21 00:05:43 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
col = split.column()
|
2010-08-20 06:09:58 +00:00
|
|
|
col.prop(softbody, "error_threshold")
|
2009-11-23 00:27:30 +00:00
|
|
|
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:")
|
2010-08-20 06:09:58 +00:00
|
|
|
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
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = "Soft Body Field Weights"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
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)
|
2011-04-04 10:13:04 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
bpy.utils.register_module(__name__)
|