Some ui reorganization of the physics tab:

* Before the different simulations all had a panel with an "add this" button making the whole tab look really messy. It also rarely makes sense to have more than one or two physics things enabled for a single object, so having all the panels in the tab just added a great deal of visual clutter.
* Now there is a single "enable physics for" panel at the top that allows for enable/disable of any simulation. All actual physics panels are hidden until a simulation is enabled.
* There was no "add" button for force fields before, but I added a toggle between "none" and "force" to unify the ui even further.
This commit is contained in:
2011-01-23 14:04:31 +00:00
parent eafbb9221e
commit fa38da021c
9 changed files with 102 additions and 87 deletions

View File

@@ -47,7 +47,7 @@ class PhysicButtonsPanel():
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.cloth)
class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel):
@@ -59,21 +59,6 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel):
md = context.cloth
ob = context.object
split = layout.split()
if md:
# remove modifier + settings
split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
row.prop(md, "show_render", text="")
row.prop(md, "show_viewport", text="")
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'CLOTH'
split.label()
if md:
cloth = md.settings

View File

@@ -20,8 +20,59 @@
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

View File

@@ -37,6 +37,12 @@ class PhysicButtonsPanel():
class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Force Fields"
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (not rd.use_game_engine) and (ob.field) and (ob.field.type != 'NONE')
def draw(self, context):
layout = self.layout
@@ -164,7 +170,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel):
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.collision)
def draw(self, context):
layout = self.layout
@@ -173,24 +179,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel):
split = layout.split()
if md:
# remove modifier + settings
split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
col = split.column()
#row = split.row(align=True)
#row.prop(md, "show_render", text="")
#row.prop(md, "show_viewport", text="")
coll = md.settings
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'COLLISION'
split.label()
coll = None
coll = md.settings
if coll:
settings = context.object.collision

View File

@@ -29,7 +29,7 @@ class PhysicButtonsPanel():
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.fluid)
class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel):
@@ -40,25 +40,9 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel):
md = context.fluid
split = layout.split()
if md:
# remove modifier + settings
split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
row.prop(md, "show_render", text="")
row.prop(md, "show_viewport", text="")
fluid = md.settings
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'FLUID_SIMULATION'
split.label()
if md:
row = layout.row()
if fluid is None:
row.label("built without fluids")

View File

@@ -33,7 +33,7 @@ class PhysicButtonsPanel():
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.smoke)
class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel):
@@ -45,22 +45,6 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel):
md = context.smoke
ob = context.object
split = layout.split()
if md:
# remove modifier + settings
split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
row.prop(md, "show_render", text="")
row.prop(md, "show_viewport", text="")
else:
# add modifier
split.operator("object.modifier_add", text="Add").type = 'SMOKE'
split.label()
if md:
layout.prop(md, "smoke_type", expand=True)

View File

@@ -39,7 +39,7 @@ class PhysicButtonsPanel():
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)
return (ob and (ob.type == 'MESH' or ob.type == 'LATTICE'or ob.type == 'CURVE')) and (not rd.use_game_engine) and (context.soft_body)
class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel):
@@ -51,21 +51,6 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel, bpy.types.Panel):
md = context.soft_body
ob = context.object
split = layout.split()
if md:
# remove modifier + settings
split.context_pointer_set("modifier", md)
split.operator("object.modifier_remove", text="Remove")
row = split.row(align=True)
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'
split.column()
if md:
softbody = md.settings

View File

@@ -50,6 +50,7 @@
#include "DNA_property_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_meshdata_types.h"
#include "DNA_vfont_types.h"
@@ -59,6 +60,7 @@
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_effect.h"
#include "BKE_depsgraph.h"
#include "BKE_font.h"
#include "BKE_image.h"
@@ -1500,6 +1502,39 @@ void copy_attr_menu(Main *bmain, Scene *scene, View3D *v3d)
copy_attr(bmain, scene, v3d, event);
}
/* ******************* force field toggle operator ***************** */
static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
if(ob->pd == NULL)
ob->pd = object_add_collision_fields(PFIELD_FORCE);
if(ob->pd->forcefield == 0)
ob->pd->forcefield = PFIELD_FORCE;
else
ob->pd->forcefield = 0;
return OPERATOR_FINISHED;
}
void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Toggle Force Field";
ot->description = "Toggle object's force field";
ot->idname= "OBJECT_OT_forcefield_toggle";
/* api callbacks */
ot->exec= forcefield_toggle_exec;
ot->poll= ED_operator_object_active_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ********************************************** */
/* Motion Paths */

View File

@@ -84,6 +84,7 @@ void OBJECT_OT_shade_smooth(struct wmOperatorType *ot);
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
void OBJECT_OT_paths_calculate(struct wmOperatorType *ot);
void OBJECT_OT_paths_clear(struct wmOperatorType *ot);
void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot);
void OBJECT_OT_game_property_new(struct wmOperatorType *ot);
void OBJECT_OT_game_property_remove(struct wmOperatorType *ot);

View File

@@ -77,6 +77,7 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_shade_flat);
WM_operatortype_append(OBJECT_OT_paths_calculate);
WM_operatortype_append(OBJECT_OT_paths_clear);
WM_operatortype_append(OBJECT_OT_forcefield_toggle);
WM_operatortype_append(OBJECT_OT_parent_set);
WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);