use set as a suffix (matches operators)
[blender-staging.git] / release / scripts / ui / properties_physics_softbody.py
index 4cecb7ee087efbb59e9716121bc2b9eb4dc4be41..08abf048c50126e37f6c02ad4c93a85399f0a264 100644 (file)
 #
 #  You should have received a copy of the GNU General Public License
 #  along with this program; if not, write to the Free Software Foundation,
 #
 #  You should have received a copy of the GNU General Public License
 #  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
 import bpy
 
 #
 # ##### 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
 
 
 def softbody_panel_enabled(md):
 
 from properties_physics_common import point_cache_ui
 from properties_physics_common import effector_weights_ui
 
 
 def softbody_panel_enabled(md):
-    return (md.point_cache.baked is False)
+    return (md.point_cache.is_baked is False)
 
 
 
 
-class PhysicButtonsPanel(bpy.types.Panel):
+class PhysicButtonsPanel():
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "physics"
 
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = "physics"
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         ob = context.object
         ob = context.object
-        rd = context.scene.render_data
-        return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
+        rd = context.scene.render
+#        return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
+# 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):
+class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Soft Body"
 
     def draw(self, context):
     bl_label = "Soft Body"
 
     def draw(self, context):
@@ -49,24 +50,21 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
 
         md = context.soft_body
         ob = context.object
 
         md = context.soft_body
         ob = context.object
-        wide_ui = context.region.width > narrowui
 
         split = layout.split()
 
         split = layout.split()
-        split.operator_context = 'EXEC_DEFAULT'
 
         if md:
             # remove modifier + settings
 
         if md:
             # remove modifier + settings
-            split.set_context_pointer("modifier", md)
+            split.context_pointer_set("modifier", md)
             split.operator("object.modifier_remove", text="Remove")
 
             row = split.row(align=True)
             split.operator("object.modifier_remove", text="Remove")
 
             row = split.row(align=True)
-            row.prop(md, "render", text="")
-            row.prop(md, "realtime", text="")
+            row.prop(md, "show_render", text="")
+            row.prop(md, "show_viewport", text="")
         else:
             # add modifier
             split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY'
         else:
             # add modifier
             split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY'
-            if wide_ui:
-                split.column()
+            split.column()
 
         if md:
             softbody = md.settings
 
         if md:
             softbody = md.settings
@@ -79,31 +77,32 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
             col.label(text="Object:")
             col.prop(softbody, "friction")
             col.prop(softbody, "mass")
             col.label(text="Object:")
             col.prop(softbody, "friction")
             col.prop(softbody, "mass")
-            col.prop_object(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
+            col.prop_search(softbody, "vertex_group_mass", ob, "vertex_groups", text="Mass:")
 
 
-            if wide_ui:
-                col = split.column()
+            col = split.column()
             col.label(text="Simulation:")
             col.prop(softbody, "speed")
 
 
             col.label(text="Simulation:")
             col.prop(softbody, "speed")
 
 
-class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
+class PHYSICS_PT_softbody_cache(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Soft Body Cache"
     bl_label = "Soft Body Cache"
-    bl_default_closed = True
+    bl_options = {'DEFAULT_CLOSED'}
 
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return context.soft_body
 
     def draw(self, context):
         md = context.soft_body
         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)
+        point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY')
 
 
 
 
-class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
+class PHYSICS_PT_softbody_goal(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Soft Body Goal"
     bl_label = "Soft Body Goal"
-    bl_default_closed = True
+    bl_options = {'DEFAULT_CLOSED'}
 
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return context.soft_body
 
     def draw_header(self, context):
         return context.soft_body
 
     def draw_header(self, context):
@@ -118,7 +117,6 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
         md = context.soft_body
         softbody = md.settings
         ob = context.object
         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)
 
 
         layout.active = softbody.use_goal and softbody_panel_enabled(md)
 
@@ -134,20 +132,20 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
         sub.prop(softbody, "goal_min", text="Minimum")
         sub.prop(softbody, "goal_max", text="Maximum")
 
         sub.prop(softbody, "goal_min", text="Minimum")
         sub.prop(softbody, "goal_max", text="Maximum")
 
-        if wide_ui:
-            col = split.column()
+        col = split.column()
         col.label(text="Goal Settings:")
         col.prop(softbody, "goal_spring", text="Stiffness")
         col.prop(softbody, "goal_friction", text="Damping")
 
         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")
+        layout.prop_search(softbody, "vertex_group_goal", ob, "vertex_groups", text="Vertex Group")
 
 
 
 
-class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
+class PHYSICS_PT_softbody_edge(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Soft Body Edges"
     bl_label = "Soft Body Edges"
-    bl_default_closed = True
+    bl_options = {'DEFAULT_CLOSED'}
 
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return context.soft_body
 
     def draw_header(self, context):
         return context.soft_body
 
     def draw_header(self, context):
@@ -162,7 +160,6 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
         md = context.soft_body
         softbody = md.settings
         ob = context.object
         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)
 
 
         layout.active = softbody.use_edges and softbody_panel_enabled(md)
 
@@ -172,57 +169,55 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
         col.label(text="Springs:")
         col.prop(softbody, "pull")
         col.prop(softbody, "push")
         col.label(text="Springs:")
         col.prop(softbody, "pull")
         col.prop(softbody, "push")
-        col.prop(softbody, "damp")
+        col.prop(softbody, "damping")
         col.prop(softbody, "plastic")
         col.prop(softbody, "plastic")
-        col.prop(softbody, "bending")
+        col.prop(softbody, "bend")
         col.prop(softbody, "spring_length", text="Length")
         col.prop(softbody, "spring_length", text="Length")
-        col.prop_object(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
-        col.item_pointerR(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
+        col.prop_search(softbody, "vertex_group_spring", ob, "vertex_groups", text="Springs:")
 
 
-        if wide_ui:
-            col = split.column()
-        col.prop(softbody, "stiff_quads")
+        col = split.column()
+        col.prop(softbody, "use_stiff_quads")
         sub = col.column()
         sub = col.column()
-        sub.active = softbody.stiff_quads
+        sub.active = softbody.use_stiff_quads
         sub.prop(softbody, "shear")
 
         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="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.label(text="Collision:")
-        col.prop(softbody, "edge_collision", text="Edge")
-        col.prop(softbody, "face_collision", text="Face")
+        col.prop(softbody, "use_edge_collision", text="Edge")
+        col.prop(softbody, "use_face_collision", text="Face")
 
 
 
 
-class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
-    bl_label = "Soft Body Collision"
-    bl_default_closed = True
+class PHYSICS_PT_softbody_collision(PhysicButtonsPanel, bpy.types.Panel):
+    bl_label = "Soft Body Self Collision"
+    bl_options = {'DEFAULT_CLOSED'}
 
 
-    def poll(self, context):
+    @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)
         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="")
+        self.layout.prop(softbody, "use_self_collision", text="")
 
     def draw(self, context):
         layout = self.layout
 
         md = context.soft_body
         softbody = md.settings
 
     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.active = softbody.use_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="")
+        layout.label(text="Collision Ball Size Calculation:")
+        layout.prop(softbody, "collision_type", expand=True)
 
         col = layout.column(align=True)
         col.label(text="Ball:")
 
         col = layout.column(align=True)
         col.label(text="Ball:")
@@ -231,11 +226,12 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
         col.prop(softbody, "ball_damp", text="Dampening")
 
 
         col.prop(softbody, "ball_damp", text="Dampening")
 
 
-class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
+class PHYSICS_PT_softbody_solver(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Soft Body Solver"
     bl_label = "Soft Body Solver"
-    bl_default_closed = True
+    bl_options = {'DEFAULT_CLOSED'}
 
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return context.soft_body
 
     def draw(self, context):
         return context.soft_body
 
     def draw(self, context):
@@ -243,7 +239,6 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
 
         md = context.soft_body
         softbody = md.settings
 
         md = context.soft_body
         softbody = md.settings
-        wide_ui = context.region.width > narrowui
 
         layout.active = softbody_panel_enabled(md)
 
 
         layout.active = softbody_panel_enabled(md)
 
@@ -252,26 +247,27 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
 
         col = split.column(align=True)
         col.label(text="Step Size:")
 
         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")
+        col.prop(softbody, "step_min")
+        col.prop(softbody, "step_max")
+        col.prop(softbody, "use_auto_step", text="Auto-Step")
 
 
-        if wide_ui:
-            col = split.column()
-        col.prop(softbody, "error_limit")
+        col = split.column()
+        col.prop(softbody, "error_threshold")
         col.label(text="Helpers:")
         col.prop(softbody, "choke")
         col.prop(softbody, "fuzzy")
 
         layout.label(text="Diagnostics:")
         col.label(text="Helpers:")
         col.prop(softbody, "choke")
         col.prop(softbody, "fuzzy")
 
         layout.label(text="Diagnostics:")
-        layout.prop(softbody, "diagnose")
+        layout.prop(softbody, "use_diagnose")
+        layout.prop(softbody, "use_estimate_matrix")
 
 
 
 
-class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
+class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Soft Body Field Weights"
     bl_label = "Soft Body Field Weights"
-    bl_default_closed = True
+    bl_options = {'DEFAULT_CLOSED'}
 
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return (context.soft_body)
 
     def draw(self, context):
         return (context.soft_body)
 
     def draw(self, context):
@@ -280,10 +276,13 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
 
         effector_weights_ui(self, context, softbody.effector_weights)
 
 
         effector_weights_ui(self, context, softbody.effector_weights)
 
-bpy.types.register(PHYSICS_PT_softbody)
-bpy.types.register(PHYSICS_PT_softbody_cache)
-bpy.types.register(PHYSICS_PT_softbody_goal)
-bpy.types.register(PHYSICS_PT_softbody_edge)
-bpy.types.register(PHYSICS_PT_softbody_collision)
-bpy.types.register(PHYSICS_PT_softbody_solver)
-bpy.types.register(PHYSICS_PT_softbody_field_weights)
+
+def register():
+    pass
+
+
+def unregister():
+    pass
+
+if __name__ == "__main__":
+    register()