diff options
Diffstat (limited to 'release/scripts/ui/properties_physics_common.py')
-rw-r--r-- | release/scripts/ui/properties_physics_common.py | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index 71bf8ae9590..30b9061e982 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -20,9 +20,60 @@ import bpy -#cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc +class PhysicButtonsPanel(): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "physics" + + @classmethod + def poll(cls, context): + rd = context.scene.render + return (context.object) and (not rd.use_game_engine) + +def physics_add(self, layout, md, name, type, typeicon, toggles): + sub = layout.row(align=True) + if md: + sub.context_pointer_set("modifier", md) + sub.operator("object.modifier_remove", text=name, icon='X') + if(toggles): + sub.prop(md, "show_render", text="") + sub.prop(md, "show_viewport", text="") + else: + sub.operator("object.modifier_add", text=name, icon=typeicon).type = type + +class PHYSICS_PT_add(PhysicButtonsPanel, bpy.types.Panel): + bl_label = "" + bl_options = {'HIDE_HEADER'} + + def draw(self, context): + ob = context.object + + layout = self.layout + layout.label("Enable physics for:") + split = layout.split() + col = split.column() + + if(context.object.field.type == 'NONE'): + col.operator("object.forcefield_toggle", text="Force Field", icon='FORCE_FORCE') + else: + col.operator("object.forcefield_toggle", text="Force Field", icon='X') + + if(ob.type == 'MESH'): + physics_add(self, col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False); + physics_add(self, col, context.cloth, "Cloth", 'CLOTH', 'MOD_CLOTH', True); + + col = split.column() + + if(ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE'): + physics_add(self, col, context.soft_body, "Soft Body", 'SOFT_BODY', 'MOD_SOFT', True); + + if(ob.type == 'MESH'): + physics_add(self, col, context.fluid, "Fluid", 'FLUID_SIMULATION', 'MOD_FLUIDSIM', True); + physics_add(self, col, context.smoke, "Smoke", 'SMOKE', 'MOD_SMOKE', True); +#cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc + def point_cache_ui(self, context, cache, enabled, cachetype): layout = self.layout |