diff options
Diffstat (limited to 'release/scripts/ui/properties_physics_common.py')
-rw-r--r-- | release/scripts/ui/properties_physics_common.py | 136 |
1 files changed, 102 insertions, 34 deletions
diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index 68b93386099..e6900b162ba 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -20,9 +20,63 @@ 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 @@ -46,37 +100,49 @@ def point_cache_ui(self, context, cache, enabled, cachetype): row = layout.row() row.label(text="File Path:") row.prop(cache, "use_library_path", "Use Lib Path") - + layout.prop(cache, "filepath", text="") layout.label(text=cache.info) else: - layout.prop(cache, "name", text="File Name") + if cachetype == 'SMOKE': + if bpy.data.is_dirty: + layout.label(text="Cache is disabled until the file is saved") + layout.enabled = False - split = layout.split() - col = split.column(align=True) + if cache.use_disk_cache: + layout.prop(cache, "name", text="File Name") + else: + layout.prop(cache, "name", text="Cache Name") + + row = layout.row(align=True) if cachetype != 'PSYS': - col.enabled = enabled - col.prop(cache, "frame_start") - col.prop(cache, "frame_end") + row.enabled = enabled + row.prop(cache, "frame_start") + row.prop(cache, "frame_end") + if cachetype not in ('SMOKE', 'CLOTH'): + row.prop(cache, "frame_step") + row.prop(cache, "use_quick_cache") if cachetype != 'SMOKE': - col.prop(cache, "frame_step") - - col = split.column() + layout.label(text=cache.info) if cachetype != 'SMOKE': - sub = col.column() - sub.enabled = enabled - sub.prop(cache, "use_quick_cache") + split = layout.split() + split.enabled = enabled and (not bpy.data.is_dirty) - sub = col.column() - sub.enabled = (not bpy.data.is_dirty) - sub.prop(cache, "use_disk_cache") - col.label(text=cache.info) + col = split.column() + col.prop(cache, "use_disk_cache") - sub = col.column() - sub.prop(cache, "use_library_path", "Use Lib Path") + col = split.column() + col.active = cache.use_disk_cache + col.prop(cache, "use_library_path", "Use Lib Path") + + row = layout.row() + row.enabled = enabled and (not bpy.data.is_dirty) + row.active = cache.use_disk_cache + row.label(text="Compression:") + row.prop(cache, "compression", expand=True) layout.separator() @@ -97,7 +163,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype): sub.enabled = enabled sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake") - col = split.column() col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True col.operator("ptcache.free_bake_all", text="Free All Bakes") @@ -107,7 +172,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype): def effector_weights_ui(self, context, weights): layout = self.layout - layout.prop(weights, "group") split = layout.split() @@ -142,7 +206,6 @@ def effector_weights_ui(self, context, weights): def basic_force_field_settings_ui(self, context, field): layout = self.layout - split = layout.split() if not field or field.type == 'NONE': @@ -169,8 +232,9 @@ def basic_force_field_settings_ui(self, context, field): col.prop(field, "flow") col = split.column() - col.prop(field, "noise") - col.prop(field, "seed") + sub = col.column(align=True) + sub.prop(field, "noise") + sub.prop(field, "seed") if field.type == 'TURBULENCE': col.prop(field, "use_global_coords", text="Global") elif field.type == 'HARMONIC': @@ -191,7 +255,6 @@ def basic_force_field_settings_ui(self, context, field): def basic_force_field_falloff_ui(self, context, field): layout = self.layout - # XXX: This doesn't update for some reason. #split = layout.split() split = layout.split(percentage=0.35) @@ -201,27 +264,32 @@ def basic_force_field_falloff_ui(self, context, field): col = split.column() col.prop(field, "z_direction", text="") - col.prop(field, "use_min_distance", text="Use Minimum") - col.prop(field, "use_max_distance", text="Use Maximum") col = split.column() col.prop(field, "falloff_power", text="Power") - sub = col.column() + split = layout.split() + col = split.column() + row = col.row(align=True) + row.prop(field, "use_min_distance", text="") + sub = row.row() sub.active = field.use_min_distance - sub.prop(field, "distance_min", text="Distance") + sub.prop(field, "distance_min", text="Minimum") - sub = col.column() + col = split.column() + row = col.row(align=True) + row.prop(field, "use_max_distance", text="") + sub = row.row() sub.active = field.use_max_distance - sub.prop(field, "distance_max", text="Distance") + sub.prop(field, "distance_max", text="Maximum") def register(): - pass + bpy.utils.register_module(__name__) def unregister(): - pass + bpy.utils.unregister_module(__name__) if __name__ == "__main__": register() |