Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-02 23:41:31 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-02 23:41:31 +0400
commit093ff8202ced6391a2ef657abe42615672146954 (patch)
tree8b65da58becc4ac56bf81ae7d3adab7c86730d15 /source/blender/editors
parent5a0896e1a3c7f17abd37e3d818585fde8e80ff6d (diff)
2.5: Physics Buttons
All kinds of changes to get it ready for UI layouts. This means RNA and operators should be working correct, but most buttons are still not actually there yet. * Added near empty soft body, fluid, field and collision panels, tweaks to cloth panels. * Fluid bake works, but without escape or showing any progress. * Fluid/Softbody/Cloth/Collision can now be both added as modifiers or in the physics panels. * Missing: fields & soft body for particles. * Missing: proper updating softbodies, guess this code still needs updates after pointcache refactor?
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_markers.c2
-rw-r--r--source/blender/editors/include/ED_fluidsim.h2
-rw-r--r--source/blender/editors/include/ED_markers.h2
-rw-r--r--source/blender/editors/include/ED_object.h3
-rw-r--r--source/blender/editors/include/ED_physics.h (renamed from source/blender/editors/include/ED_pointcache.h)2
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface_layout.c49
-rw-r--r--source/blender/editors/interface/interface_templates.c238
-rw-r--r--source/blender/editors/object/object_intern.h6
-rw-r--r--source/blender/editors/object/object_modifier.c292
-rw-r--r--source/blender/editors/object/object_ops.c6
-rw-r--r--source/blender/editors/physics/ed_fluidsim.c113
-rw-r--r--source/blender/editors/physics/ed_pointcache.c2
-rw-r--r--source/blender/editors/space_api/spacetypes.c9
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c15
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c4
16 files changed, 473 insertions, 273 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 2abec6b831c..d6543b41f47 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -976,7 +976,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
/* ************************** registration **********************************/
/* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_marker_operatortypes(void)
+void ED_operatortypes_marker(void)
{
WM_operatortype_append(MARKER_OT_add);
WM_operatortype_append(MARKER_OT_move);
diff --git a/source/blender/editors/include/ED_fluidsim.h b/source/blender/editors/include/ED_fluidsim.h
index 586f16f42aa..2859ec897bf 100644
--- a/source/blender/editors/include/ED_fluidsim.h
+++ b/source/blender/editors/include/ED_fluidsim.h
@@ -46,6 +46,8 @@ void fluidsimSettingsFree(struct FluidsimSettings* sb);
/* duplicate internal data */
struct FluidsimSettings* fluidsimSettingsCopy(struct FluidsimSettings* sb);
+/* memory estimate */
+void fluidsimEstimateMemory(struct Object *ob, struct FluidsimSettings *fs, char *value);
#endif /* ED_FLUIDSIM_H */
diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h
index 048bbbd7463..4b7a2954206 100644
--- a/source/blender/editors/include/ED_markers.h
+++ b/source/blender/editors/include/ED_markers.h
@@ -54,7 +54,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short sel);
/* Operators ------------------------------ */
/* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_marker_operatortypes(void);
+void ED_operatortypes_marker(void);
/* called in screen_ops.c:ED_keymap_screen() */
void ED_marker_keymap(struct wmWindowManager *wm);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index e4e4b1d0486..9dcdc30a691 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -103,7 +103,8 @@ void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb)
void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
/* object_modifier.c */
-int ED_object_modifier_delete(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type);
+int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_convert(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
diff --git a/source/blender/editors/include/ED_pointcache.h b/source/blender/editors/include/ED_physics.h
index dc50e274fa9..b04bfb992dc 100644
--- a/source/blender/editors/include/ED_pointcache.h
+++ b/source/blender/editors/include/ED_physics.h
@@ -31,7 +31,9 @@
#define ED_PHYSICS_H
/* operators */
+
void ED_operatortypes_pointcache(void);
+void ED_operatortypes_fluid(void);
//void ED_keymap_pointcache(struct wmWindowManager *wm);
#endif /* ED_PHYSICS_H */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index cc8b936b04f..c0612c3524e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -635,6 +635,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct ID
void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle);
void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle);
void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value);
+void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value);
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index f9816235b88..2e30c5f1cb7 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -615,14 +615,13 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
/* for getting the enum */
PropertyRNA *prop;
const EnumPropertyItem *item;
- int totitem;
int value;
WM_operator_properties_create(&ptr, opname);
/* enum lookup */
if((prop= RNA_struct_find_property(&ptr, propname))) {
- RNA_property_enum_items(&ptr, prop, &item, &totitem);
+ RNA_property_enum_items(&ptr, prop, &item, NULL);
if(RNA_enum_value_from_id(item, value_str, &value)==0) {
printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
return;
@@ -695,14 +694,17 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
PropertySubType subtype;
int len, w, h;
- w= ui_text_icon_width(layout, name, icon);
- h= UI_UNIT_Y;
-
/* arbitrary extended width by type */
type= RNA_property_type(prop);
subtype= RNA_property_subtype(prop);
len= RNA_property_array_length(prop);
+ if(type == PROP_STRING && strcmp(name, "") == 0)
+ name= "non-empty";
+
+ w= ui_text_icon_width(layout, name, icon);
+ h= UI_UNIT_Y;
+
/* increase height for arrays */
if(index == RNA_NO_INDEX && len > 0) {
if(strcmp(name, "") == 0 && icon == 0)
@@ -827,15 +829,48 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
prop= RNA_struct_find_property(ptr, propname);
- if(!prop) {
+ if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
- printf("uiItemEnumR: property not found: %s\n", propname);
+ printf("uiItemEnumR: enum property not found: %s\n", propname);
return;
}
uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0);
}
+void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
+{
+ PropertyRNA *prop;
+ const EnumPropertyItem *item;
+ int ivalue, a;
+
+ if(!ptr->data || !propname)
+ return;
+
+ prop= RNA_struct_find_property(ptr, propname);
+
+ if(!prop || RNA_property_type(prop) != PROP_ENUM) {
+ ui_item_disabled(layout, propname);
+ printf("uiItemEnumR: enum property not found: %s\n", propname);
+ return;
+ }
+
+ RNA_property_enum_items(ptr, prop, &item, NULL);
+
+ if(!RNA_enum_value_from_id(item, value, &ivalue)) {
+ ui_item_disabled(layout, propname);
+ printf("uiItemEnumR: enum property value not found: %s\n", value);
+ return;
+ }
+
+ for(a=0; item[a].identifier; a++) {
+ if(item[a].value == ivalue) {
+ uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0);
+ break;
+ }
+ }
+}
+
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
{
PropertyRNA *prop;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 8f1d57b28ed..d9bc2d4d426 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -320,134 +320,6 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
#include "ED_object.h"
-static void modifiers_del(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_delete(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Delete modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_activate(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
-
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-}
-
-static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_move_up(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Move modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_move_down(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Move modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= obv;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_convert(&reports, scene, obv, mdv)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Convert particles to mesh object(s).");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= obv;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_apply(&reports, scene, obv, mdv)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Apply modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_copy(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
- ED_undo_push(C, "Copy modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
@@ -490,15 +362,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
static int modifier_can_delete(ModifierData *md)
{
- // deletion over the deflection panel
// fluid particle modifier can't be deleted here
-
- if(md->type==eModifierType_Fluidsim)
- return 0;
- if(md->type==eModifierType_Collision)
- return 0;
- if(md->type==eModifierType_Surface)
- return 0;
if(md->type == eModifierType_ParticleSystem)
if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
return 0;
@@ -512,12 +376,12 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
PointerRNA ptr;
uiBut *but;
uiBlock *block;
- uiLayout *column, *row, *subrow, *result= NULL;
- int isVirtual = md->mode&eModifierMode_Virtual;
+ uiLayout *column, *row, *result= NULL;
+ int isVirtual = md->mode & eModifierMode_Virtual;
// XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
- short width = 295, buttonWidth = width-120-10;
char str[128];
+ /* create RNA pointer */
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
column= uiLayoutColumn(layout, 1);
@@ -528,57 +392,57 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
/* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
row= uiLayoutRow(uiLayoutBox(column), 0);
- block= uiLayoutGetBlock(row);
+ uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
- subrow= uiLayoutRow(row, 0);
- uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
+ block= uiLayoutGetBlock(row);
//uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0,
- // (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, "");
+ // (!isVirtual && (md->mode & eModifierMode_Expanded))?3:15, 20, "");
/* XXX uiBlockSetCol(block, TH_AUTO); */
/* open/close icon */
- if (!isVirtual) {
+ if(!isVirtual) {
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
}
/* modifier-type icon */
- uiDefIconBut(block, BUT, 0, RNA_struct_ui_icon(ptr.type), 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Current Modifier Type");
+ uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
uiBlockSetEmboss(block, UI_EMBOSS);
- if (isVirtual) {
+ if(isVirtual) {
+ /* virtual modifier */
sprintf(str, "%s parent deform", md->name);
uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name");
but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
uiButSetFunc(but, modifiers_convertToReal, ob, md);
- } else {
+ }
+ else {
+ /* real modifier */
uiBlockBeginAlign(block);
- uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-40, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name");
+ uiItemR(row, "", 0, &ptr, "name", 0, 0, 0);
/* Softbody not allowed in this situation, enforce! */
- if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
- uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
- but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
- uiButSetFunc(but, modifiers_activate, ob, md);
- if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
- but= uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
- uiButSetFunc(but, modifiers_activate, ob, md);
- }
+ if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
+ uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0);
+ uiItemR(row, "", ICON_VIEW3D, &ptr, "realtime", 0, 0, 0);
+
+ if(mti->flags & eModifierTypeFlag_SupportsEditmode)
+ uiItemR(row, "", ICON_VIEW3D, &ptr, "editmode", 0, 0, 0);
}
uiBlockEndAlign(block);
/* XXX uiBlockSetEmboss(block, UI_EMBOSSR); */
- if (ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
+ if(ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
int icon; //, color;
- if (index==cageIndex) {
+ if(index==cageIndex) {
// XXX color = TH_BUT_SETTING;
icon = VICON_EDITMODE_HLT;
- } else if (index<cageIndex) {
+ } else if(index<cageIndex) {
// XXX color = TH_BUT_NEUTRAL;
icon = VICON_EDITMODE_DEHLT;
} else {
@@ -592,67 +456,55 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
}
}
- subrow= uiLayoutRow(row, 0);
- uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
-
+ /* up/down/delete */
if(!isVirtual) {
/* XXX uiBlockSetCol(block, TH_BUT_ACTION); */
-
- but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
- uiButSetFunc(but, modifiers_moveUp, ob, md);
-
- but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
- uiButSetFunc(but, modifiers_moveDown, ob, md);
+ uiItemO(row, "", VICON_MOVE_UP, "OBJECT_OT_modifier_move_up");
+ uiItemO(row, "", VICON_MOVE_DOWN, "OBJECT_OT_modifier_move_down");
uiBlockSetEmboss(block, UI_EMBOSSN);
-
- if(modifier_can_delete(md)) {
- but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
- uiButSetFunc(but, modifiers_del, ob, md);
- }
+
+ if(modifier_can_delete(md))
+ uiItemO(row, "", VICON_X, "OBJECT_OT_modifier_remove");
+
/* XXX uiBlockSetCol(block, TH_AUTO); */
}
uiBlockSetEmboss(block, UI_EMBOSS);
- if(!isVirtual && (md->mode&eModifierMode_Expanded)) {
+ if(!isVirtual && (md->mode & eModifierMode_Expanded)) {
+ /* apply/convert/copy */
uiLayout *box;
box= uiLayoutBox(column);
row= uiLayoutRow(box, 1);
- if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
- uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */
+ if(!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
+ /* only here obdata, the rest of modifiers is ob level */
+ uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if (md->type==eModifierType_ParticleSystem) {
+ if(md->type==eModifierType_ParticleSystem) {
ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys;
- if(!(G.f & G_PARTICLEEDIT)) {
- if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) {
- but = uiDefBut(block, BUT, 0, "Convert", 0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
- uiButSetFunc(but, modifiers_convertParticles, ob, md);
- }
- }
- }
- else{
- but = uiDefBut(block, BUT, 0, "Apply", 0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
- uiButSetFunc(but, modifiers_applyModifier, ob, md);
+ if(!(G.f & G_PARTICLEEDIT))
+ if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache)
+ uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert");
}
+ else
+ uiItemO(row, "Apply", 0, "OBJECT_OT_modifier_apply");
uiBlockClearButLock(block);
uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
- if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) {
- but = uiDefBut(block, BUT, 0, "Copy", 0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
- uiButSetFunc(but, modifiers_copyModifier, ob, md);
- }
+ if(!ELEM4(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth))
+ uiItemO(row, "Copy", 0, "OBJECT_OT_modifier_copy");
}
result= uiLayoutColumn(box, 0);
block= uiLayoutFreeBlock(box);
}
- if (md->error) {
+ if(md->error) {
row = uiLayoutRow(uiLayoutBox(column), 0);
/* XXX uiBlockSetCol(block, color); */
@@ -694,7 +546,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr)
for(i=0; vmd; i++, vmd=vmd->next) {
if(md == vmd)
return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex);
- else if(vmd->mode&eModifierMode_Virtual)
+ else if(vmd->mode & eModifierMode_Virtual)
i--;
}
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index a52acdd4e1e..6ec5f029148 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -86,6 +86,12 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot);
/* object_modifier.c */
void OBJECT_OT_modifier_add(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_remove(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_move_up(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_move_down(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_apply(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_convert(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_copy(struct wmOperatorType *ot);
void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot);
void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 4bcfcc4d5ab..bda3e4e8f79 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -25,6 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -35,6 +36,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
+#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
@@ -44,6 +46,7 @@
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_mesh.h"
@@ -52,6 +55,7 @@
#include "BKE_report.h"
#include "BKE_object.h"
#include "BKE_particle.h"
+#include "BKE_softbody.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -67,31 +71,97 @@
/******************************** API ****************************/
-int ED_object_modifier_delete(ReportList *reports, Object *ob, ModifierData *md)
+int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
+{
+ ModifierData *md;
+ ModifierTypeInfo *mti = modifierType_getInfo(type);
+
+ if(mti->flags&eModifierTypeFlag_Single) {
+ if(modifiers_findByType(ob, type)) {
+ BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed.");
+ return 0;
+ }
+ }
+
+ if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
+ md = ob->modifiers.first;
+
+ while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
+ md = md->next;
+
+ BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
+ }
+ else
+ BLI_addtail(&ob->modifiers, modifier_new(type));
+
+ /* special cases */
+ if(type == eModifierType_Softbody) {
+ if(!ob->soft) {
+ ob->soft= sbNew(scene);
+ ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
+ }
+ }
+ else if(type == eModifierType_Collision) {
+ if(!ob->pd)
+ ob->pd= object_add_collision_fields();
+
+ ob->pd->deflect= 1;
+ DAG_scene_sort(scene);
+ }
+ else if(type == eModifierType_Surface)
+ DAG_scene_sort(scene);
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+ return 1;
+}
+
+int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
{
ModifierData *obmd;
/* It seems on rapid delete it is possible to
* get called twice on same modifier, so make
* sure it is in list. */
- for (obmd=ob->modifiers.first; obmd; obmd=obmd->next)
- if (obmd==md)
+ for(obmd=ob->modifiers.first; obmd; obmd=obmd->next)
+ if(obmd==md)
break;
- if (!obmd)
+ if(!obmd)
return 0;
+ /* special cases */
if(md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd=(ParticleSystemModifierData*)md;
BLI_remlink(&ob->particlesystem, psmd->psys);
psys_free(ob, psmd->psys);
}
+ else if(md->type == eModifierType_Softbody) {
+ if(ob->soft) {
+ sbFree(ob->soft);
+ ob->soft= NULL;
+ ob->softflag= 0;
+ }
+ }
+ else if(md->type == eModifierType_Collision) {
+ if(ob->pd)
+ ob->pd->deflect= 0;
- BLI_remlink(&ob->modifiers, md);
+ DAG_scene_sort(scene);
+ }
+ else if(md->type == eModifierType_Surface) {
+ if(ob->pd)
+ ob->pd->flag &= ~PFIELD_SURFACE;
+ DAG_scene_sort(scene);
+ }
+
+ BLI_remlink(&ob->modifiers, md);
modifier_free(md);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
return 1;
}
@@ -103,9 +173,10 @@ int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md
if(mti->type!=eModifierTypeType_OnlyDeform) {
ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type);
- if(nmti->flags&eModifierTypeFlag_RequiresOriginalData)
+ if(nmti->flags&eModifierTypeFlag_RequiresOriginalData) {
BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data.");
return 0;
+ }
}
BLI_remlink(&ob->modifiers, md);
@@ -329,22 +400,11 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ModifierData *md;
int type= RNA_enum_get(op->ptr, "type");
- ModifierTypeInfo *mti = modifierType_getInfo(type);
- if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
- md = ob->modifiers.first;
+ if(!ED_object_modifier_add(op->reports, scene, ob, type))
+ return OPERATOR_CANCELLED;
- while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
- md = md->next;
-
- BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
- }
- else
- BLI_addtail(&ob->modifiers, modifier_new(type));
-
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -370,13 +430,198 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", "");
}
+/************************ remove modifier operator *********************/
+
+static int modifier_remove_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md))
+ return OPERATOR_CANCELLED;
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_remove(wmOperatorType *ot)
+{
+ ot->name= "Remove Modifier";
+ ot->description= "Remove a modifier from the active object.";
+ ot->idname= "OBJECT_OT_modifier_remove";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_remove_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ move up modifier operator *********************/
+
+static int modifier_move_up_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
+{
+ ot->name= "Move Up Modifier";
+ ot->description= "Move modifier up in the stack.";
+ ot->idname= "OBJECT_OT_modifier_move_up";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_move_up_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ move down modifier operator *********************/
+
+static int modifier_move_down_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
+{
+ ot->name= "Move Down Modifier";
+ ot->description= "Move modifier down in the stack.";
+ ot->idname= "OBJECT_OT_modifier_move_down";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_move_down_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ apply modifier operator *********************/
+
+static int modifier_apply_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_apply(wmOperatorType *ot)
+{
+ ot->name= "Apply Modifier";
+ ot->description= "Apply modifier and remove from the stack.";
+ ot->idname= "OBJECT_OT_modifier_apply";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_apply_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ convert modifier operator *********************/
+
+static int modifier_convert_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_convert(op->reports, scene, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_convert(wmOperatorType *ot)
+{
+ ot->name= "Convert Modifier";
+ ot->description= "Convert particles to a mesh object.";
+ ot->idname= "OBJECT_OT_modifier_convert";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_convert_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ copy modifier operator *********************/
+
+static int modifier_copy_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_copy(wmOperatorType *ot)
+{
+ ot->name= "Copy Modifier";
+ ot->description= "Duplicate modifier at the same position in the stack.";
+ ot->idname= "OBJECT_OT_modifier_copy";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_copy_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/****************** multires subdivide operator *********************/
static int multires_subdivide_exec(bContext *C, wmOperator *op)
{
- Object *ob = CTX_data_active_object(C);
- PointerRNA ptr = CTX_data_pointer_get(C, "modifier");
- MultiresModifierData *mmd = (RNA_struct_is_a(ptr.type, &RNA_Modifier))? ptr.data: NULL;
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_MultiresModifier);
+ Object *ob= ptr.id.data;
+ MultiresModifierData *mmd= ptr.data;
if(mmd) {
multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple);
@@ -403,8 +648,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
static int modifier_mdef_bind_poll(bContext *C)
{
- PointerRNA ptr= CTX_data_pointer_get(C, "modifier");
- return RNA_struct_is_a(ptr.type, &RNA_MeshDeformModifier);
+ return CTX_data_pointer_get_type(C, "modifier", &RNA_MeshDeformModifier).data != NULL;
}
static int modifier_mdef_bind_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 6fa78a53840..6248d826ad4 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -100,6 +100,12 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_primitive_add);
WM_operatortype_append(OBJECT_OT_modifier_add);
+ WM_operatortype_append(OBJECT_OT_modifier_remove);
+ WM_operatortype_append(OBJECT_OT_modifier_move_up);
+ WM_operatortype_append(OBJECT_OT_modifier_move_down);
+ WM_operatortype_append(OBJECT_OT_modifier_apply);
+ WM_operatortype_append(OBJECT_OT_modifier_convert);
+ WM_operatortype_append(OBJECT_OT_modifier_copy);
WM_operatortype_append(OBJECT_OT_multires_subdivide);
WM_operatortype_append(OBJECT_OT_modifier_mdef_bind);
diff --git a/source/blender/editors/physics/ed_fluidsim.c b/source/blender/editors/physics/ed_fluidsim.c
index 215a72d6927..3990521bd1b 100644
--- a/source/blender/editors/physics/ed_fluidsim.c
+++ b/source/blender/editors/physics/ed_fluidsim.c
@@ -67,18 +67,19 @@
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
+#include "BKE_DerivedMesh.h"
#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_fluidsim.h"
#include "BKE_global.h"
-#include "BKE_modifier.h"
-#include "BKE_main.h"
+#include "BKE_ipo.h"
#include "BKE_key.h"
-#include "BKE_scene.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_softbody.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_ipo.h"
#include "PIL_time.h"
@@ -89,6 +90,9 @@
#include "ED_fluidsim.h"
#include "ED_screen.h"
+#include "WM_api.h"
+#include "WM_types.h"
+
/* XXX */
/* from header info.c */
static int start_progress_bar(void) {return 0;};
@@ -124,7 +128,7 @@ char* fluidsimViscosityPresetString[6] = {
/* ********************** fluid sim settings struct functions ********************** */
/* helper function */
-void fluidsimGetGeometryObjFilename(struct Object *ob, char *dst) { //, char *srcname) {
+void fluidsimGetGeometryObjFilename(Object *ob, char *dst) { //, char *srcname) {
//snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name);
snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name);
}
@@ -337,14 +341,14 @@ int runSimulationCallback(void *data, int status, int frame) {
/* ********************** write fluidsim config to file ************************* */
/* ******************************************************************************** */
-void fluidsimBake(bContext *C, struct Object *ob)
+int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
{
Scene *scene= CTX_data_scene(C);
FILE *fileCfg;
int i;
- struct Object *fsDomain = NULL;
+ Object *fsDomain = NULL;
FluidsimSettings *domainSettings;
- struct Object *obit = NULL; /* object iterator */
+ Object *obit = NULL; /* object iterator */
Base *base;
int origFrame = scene->r.cfra;
char debugStrBuffer[256];
@@ -412,8 +416,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
// old: noFrames = scene->r.efra - scene->r.sfra +1;
noFrames = scene->r.efra - 0;
if(noFrames<=0) {
- pupmenu("Fluidsim Bake Error%t|No frames to export - check your animation range settings. Aborted%x0");
- return;
+ BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings.");
+ return 0;
}
/* no object pointer, find in selected ones.. */
@@ -434,7 +438,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
}
// no domains found?
- if(!ob) return;
+ if(!ob) return 0;
}
channelObjCount = 0;
@@ -452,8 +456,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
if (channelObjCount>=255) {
- pupmenu("Fluidsim Bake Error%t|Cannot bake with more then 256 objects");
- return;
+ BKE_report(reports, RPT_ERROR, "Cannot bake with more then 256 objects.");
+ return 0;
}
/* check if there's another domain... */
@@ -467,8 +471,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
{
if(obit != ob)
{
- pupmenu("Fluidsim Bake Error%t|There should be only one domain object! Aborted%x0");
- return;
+ BKE_report(reports, RPT_ERROR, "There should be only one domain object.");
+ return 0;
}
}
}
@@ -490,8 +494,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
}
if(!haveSomeFluid) {
- pupmenu("Fluidsim Bake Error%t|No fluid objects in scene... Aborted%x0");
- return;
+ BKE_report(reports, RPT_ERROR, "No fluid objects in scene.");
+ return 0;
}
/* these both have to be valid, otherwise we wouldnt be here */
@@ -585,7 +589,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
// ask user if thats what he/she wants...
selection = pupmenu(dispmsg);
- if(selection<1) return; // 0 from menu, or -1 aborted
+ if(selection<1) return 0; // 0 from menu, or -1 aborted
strcpy(targetDir, newSurfdataPath);
strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR);
BLI_convertstringcode(targetDir, G.sce); // fixed #frame-no
@@ -710,6 +714,10 @@ void fluidsimBake(bContext *C, struct Object *ob)
// check & init loc,rot,size
for(j=0; j<3; j++) {
for(k=0; k<3; k++) {
+ // XXX prevent invalid memory access until this works
+ icuex[j][k]= NULL;
+ icudex[j][k]= NULL;
+
// XXX icuex[j][k] = find_ipocurve(obit->ipo, icuIds[j][k] );
// XXX icudex[j][k] = find_ipocurve(obit->ipo, icudIds[j][k] );
// XXX lines below were already disabled!
@@ -812,12 +820,12 @@ void fluidsimBake(bContext *C, struct Object *ob)
if(!Mat4Invert(invDomMat, domainMat)) {
snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n");
elbeemDebugOut(debugStrBuffer);
+ BKE_report(reports, RPT_ERROR, "Invalid object matrix.");
// FIXME add fatal msg
FS_FREE_CHANNELS;
- return;
+ return 0;
}
-
// --------------------------------------------------------------------------------------------
// start writing / exporting
strcpy(targetFile, targetDir);
@@ -1001,7 +1009,6 @@ void fluidsimBake(bContext *C, struct Object *ob)
} // valid mesh
} // objects
//domainSettings->type = OB_FLUIDSIM_DOMAIN; // enable for bake display again
- //fsDomain->fluidsimFlag = OB_FLUIDSIM_ENABLE; // disable during bake
// set to neutral, -1 means user abort, -2 means init error
globalBakeState = 0;
@@ -1080,7 +1087,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
// --------------------------------------------------------------------------------------------
else
{ // write config file to be run with command line simulator
- pupmenu("Fluidsim Bake Message%t|Config file export not supported.%x0");
+ BKE_report(reports, RPT_WARNING, "Config file export not supported.");
} // config file export done!
// --------------------------------------------------------------------------------------------
@@ -1099,51 +1106,81 @@ void fluidsimBake(bContext *C, struct Object *ob)
ED_update_for_newframe(C, 1);
if(!simAborted) {
- char fsmessage[512];
char elbeemerr[256];
- strcpy(fsmessage,"Fluidsim Bake Error: ");
+
// check if some error occurred
if(globalBakeState==-2) {
- strcat(fsmessage,"Failed to initialize [Msg: ");
-
elbeemGetErrorString(elbeemerr);
- strcat(fsmessage,elbeemerr);
-
- strcat(fsmessage,"] |OK%x0");
- pupmenu(fsmessage);
+ BKE_reportf(reports, RPT_ERROR, "Failed to initialize [Msg: %s]", elbeemerr);
+ return 0;
} // init error
}
// elbeemFree();
+ return 1;
}
-void fluidsimFreeBake(struct Object *ob)
+void fluidsimFreeBake(Object *ob)
{
/* not implemented yet */
}
-
#else /* DISABLE_ELBEEM */
/* compile dummy functions for disabled fluid sim */
-FluidsimSettings *fluidsimSettingsNew(struct Object *srcob) {
+FluidsimSettings *fluidsimSettingsNew(Object *srcob)
+{
return NULL;
}
-void fluidsimSettingsFree(FluidsimSettings *fss) {
+void fluidsimSettingsFree(FluidsimSettings *fss)
+{
}
-FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *fss) {
+FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *fss)
+{
return NULL;
}
/* only compile dummy functions */
-void fluidsimBake(bContext *C, struct Object *ob) {
+int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
+{
+ return 0;
}
-void fluidsimFreeBake(struct Object *ob) {
+void fluidsimFreeBake(Object *ob)
+{
}
#endif /* DISABLE_ELBEEM */
+/***************************** Operators ******************************/
+
+static int fluid_bake_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+
+ // XXX TODO redraw, escape, non-blocking, ..
+ if(!fluidsimBake(C, op->reports, ob))
+ return OPERATOR_CANCELLED;
+
+ return OPERATOR_FINISHED;
+}
+
+void FLUID_OT_bake(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Fluid Simulation Bake";
+ ot->idname= "FLUID_OT_bake";
+
+ /* api callbacks */
+ ot->exec= fluid_bake_exec;
+ ot->poll= ED_operator_object_active;
+}
+
+void ED_operatortypes_fluid(void)
+{
+ WM_operatortype_append(FLUID_OT_bake);
+}
+
diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c
index 893c59a521d..edd668b46bb 100644
--- a/source/blender/editors/physics/ed_pointcache.c
+++ b/source/blender/editors/physics/ed_pointcache.c
@@ -45,7 +45,7 @@
#include "BLI_blenlib.h"
#include "ED_screen.h"
-#include "ED_pointcache.h"
+#include "ED_physics.h"
#include "UI_interface.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 510103895f4..c8df9bb9741 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -42,15 +42,15 @@
#include "ED_anim_api.h"
#include "ED_armature.h"
#include "ED_curve.h"
-#include "ED_mesh.h"
#include "ED_markers.h"
+#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_particle.h"
-#include "ED_sculpt.h"
+#include "ED_physics.h"
#include "ED_screen.h"
+#include "ED_sculpt.h"
#include "ED_space_api.h"
#include "ED_uvedit.h"
-#include "ED_pointcache.h"
/* only call once on startup, storage is global in BKE kernel listbase */
void ED_spacetypes_init(void)
@@ -89,8 +89,9 @@ void ED_spacetypes_init(void)
ED_operatortypes_particle();
ED_operatortypes_curve();
ED_operatortypes_armature();
- ED_marker_operatortypes();
+ ED_operatortypes_marker();
ED_operatortypes_pointcache();
+ ED_operatortypes_fluid();
ui_view2d_operatortypes();
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 01794d1bba8..02179f347f5 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -497,7 +497,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
"world", "object", "meshe", "armature", "lattice", "curve",
"meta_ball", "lamp", "camera", "material", "material_slot",
"texture", "texture_slot", "bone", "edit_bone", "particle_system",
- "cloth", "soft_body", "fluid", NULL};
+ "cloth", "soft_body", "fluid", "collision", NULL};
CTX_data_dir_set(result, dir);
return 1;
@@ -615,7 +615,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if(ptr && ptr->data) {
Object *ob= ptr->data;
- CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodySettings, ob->soft);
+ ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody);
+ CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md);
return 1;
}
}
@@ -629,6 +630,16 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
}
+ else if(CTX_data_equals(member, "collision")) {
+ PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
+
+ if(ptr && ptr->data) {
+ Object *ob= ptr->data;
+ ModifierData *md= modifiers_findByType(ob, eModifierType_Collision);
+ CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md);
+ return 1;
+ }
+ }
return 0;
}
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index df3e8c62d37..2bc3bdaa613 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -41,6 +41,7 @@
#include "BKE_depsgraph.h"
#include "BKE_font.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_particle.h"
#include "BKE_texture.h"
@@ -471,6 +472,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
static int new_particle_settings_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
+ Main *bmain= CTX_data_main(C);
ParticleSettings *part= CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings).data;
Object *ob;
PointerRNA ptr;
@@ -479,7 +481,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op)
if(part)
part= psys_copy_settings(part);
else
- part= psys_new_settings("PSys", NULL);
+ part= psys_new_settings("PSys", bmain);
/* attempt to assign to material slot */
ptr= CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);