Merging r57962 through r57988 from trunk into soc-2013-depsgraph_mt
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 4 Jul 2013 09:23:21 +0000 (09:23 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 4 Jul 2013 09:23:21 +0000 (09:23 +0000)
24 files changed:
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/rigidbody.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/compositor/operations/COM_WrapOperation.cpp
source/blender/editors/interface/interface_handlers.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_lattice.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_meta.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_keymap.c

index 444002a07025067ee73975666fb1edb301cb16f8..1383775042d97532594a8c8b5f4df2447901495c 100644 (file)
@@ -1115,10 +1115,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
     def draw(self, context):
         layout = self.layout
 
-        ob = context.active_object
-
         col = layout.column()
-        col.active = ob.vertex_groups.active is not None
         col.operator("object.vertex_group_normalize_all", text="Normalize All")
         col.operator("object.vertex_group_normalize", text="Normalize")
         col.operator("object.vertex_group_mirror", text="Mirror")
index 07bdbc1009b52fa292fd29806d14a446e5cb5977..a43a243106d85c45751a720b218c42a34a854370 100644 (file)
@@ -40,6 +40,7 @@ struct ListBase;
 struct bDeformGroup;
 struct MDeformVert;
 
+struct bDeformGroup *BKE_defgroup_new(struct Object *ob, const char *name);
 void                 defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2);
 struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup);
 struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name);
index b82e89d1af65f2fb24b2a34d0ed759acba64199a..a492b227815c630297a1f1ca79eb4c98331f1c5f 100644 (file)
 
 #include "BKE_deform.h"  /* own include */
 
+bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
+{
+       bDeformGroup *defgroup;
+
+       BLI_assert(OB_TYPE_SUPPORT_VGROUP(ob->type));
+
+       defgroup = MEM_callocN(sizeof(bDeformGroup), __func__);
+
+       BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
+
+       BLI_addtail(&ob->defbase, defgroup);
+       defgroup_unique_name(defgroup, ob);
+
+       return defgroup;
+}
+
 void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
 {
        bDeformGroup *defgroup, *defgroupn;
index ee8edfe32ae26855bd4c69cc4bfb91657a831b99..8488fa63e2129211598f544f06d5db5edd2b3d10 100644 (file)
@@ -2301,10 +2301,12 @@ static bNode *node_get_active_id_recursive(bNodeInstanceKey active_key, bNodeIns
                for (node = ntree->nodes.first; node; node = node->next) {
                        if (node->type == NODE_GROUP) {
                                bNodeTree *group = (bNodeTree *)node->id;
-                               bNodeInstanceKey group_key = BKE_node_instance_key(parent_key, ntree, node);
-                               tnode = node_get_active_id_recursive(active_key, group_key, group, idtype);
-                               if (tnode)
-                                       return tnode;
+                               if (group) {
+                                       bNodeInstanceKey group_key = BKE_node_instance_key(parent_key, ntree, node);
+                                       tnode = node_get_active_id_recursive(active_key, group_key, group, idtype);
+                                       if (tnode)
+                                               return tnode;
+                               }
                        }
                }
        }
index 9ddf0cd2d68a807528a5e5be334d71dcb023f64f..a300e2f21562875b8b2cb8e1f76a82ac995a7d97 100644 (file)
@@ -914,12 +914,10 @@ void BKE_rigidbody_remove_object(Scene *scene, Object *ob)
                                if (obt && obt->rigidbody_constraint) {
                                        rbc = obt->rigidbody_constraint;
                                        if (rbc->ob1 == ob) {
-                                               rbc->ob1 = NULL;
-                                               rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
+                                               BKE_rigidbody_remove_constraint(scene, obt);
                                        }
                                        if (rbc->ob2 == ob) {
-                                               rbc->ob2 = NULL;
-                                               rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
+                                               BKE_rigidbody_remove_constraint(scene, obt);
                                        }
                                }
                        }
@@ -938,10 +936,9 @@ void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob)
        RigidBodyWorld *rbw = scene->rigidbody_world;
        RigidBodyCon *rbc = ob->rigidbody_constraint;
 
-       if (rbw) {
-               /* remove from rigidbody world, free object won't do this */
-               if (rbw && rbw->physics_world && rbc->physics_constraint)
-                       RB_dworld_remove_constraint(rbw->physics_world, rbc->physics_constraint);
+       /* remove from rigidbody world, free object won't do this */
+       if (rbw && rbw->physics_world && rbc->physics_constraint) {
+               RB_dworld_remove_constraint(rbw->physics_world, rbc->physics_constraint);
        }
        /* remove object's settings */
        BKE_rigidbody_free_constraint(ob);
index 85fbdb383fdf3f16d4ba5aa8b4764c501fc81766..d7073ef61be2ea3e3f9d43dc617c73fd6edebfdf 100644 (file)
@@ -268,8 +268,8 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv,
                }
                f = BM_face_create(bm, vert_arr, ee, totv, 0);
        }
-       if ((facerep || face_arr) && f) {
-               BM_elem_attrs_copy(bm, bm, facerep, f);
+       if ((facerep || (face_arr && face_arr[0])) && f) {
+               BM_elem_attrs_copy(bm, bm, facerep ? facerep : face_arr[0], f);
                if (do_interp) {
                        i = 0;
                        BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
@@ -281,7 +281,8 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv,
                                else {
                                        interp_f = facerep;
                                }
-                               BM_loop_interp_from_face(bm, l, interp_f, TRUE, TRUE);
+                               if (interp_f)
+                                       BM_loop_interp_from_face(bm, l, interp_f, TRUE, TRUE);
                                i++;
                        }
                }
@@ -404,7 +405,8 @@ static BMFace *bev_create_quad_straddle(BMesh *bm, BMVert *v1, BMVert *v2, BMVer
                        facerep = f1;
                else
                        facerep = f2;
-               BM_loop_interp_from_face(bm, l, facerep, TRUE, TRUE);
+               if (facerep)
+                       BM_loop_interp_from_face(bm, l, facerep, TRUE, TRUE);
        }
        return f;
 }
index 37a93520c7c7d0220f7094f2bb97a78d09954451..68c3e74a237f14445f5426bdfdab1e9661f4a943 100644 (file)
@@ -42,12 +42,14 @@ void WrapOperation::deinitExecution()
 
 inline float WrapOperation::getWrappedOriginalXPos(float x)
 {
+       if (this->getWidth() == 0) return 0;
        while (x < 0) x += this->m_width;
        return fmodf(x, this->getWidth());
 }
 
 inline float WrapOperation::getWrappedOriginalYPos(float y)
 {
+       if (this->getHeight() == 0) return 0;
        while (y < 0) y += this->m_height;
        return fmodf(y, this->getHeight());
 }
index d86f22df4a798fb2cf097420c9dfba8d599b1b6a..4c1ad2e41c441388b8b5488230640f797f0a7662 100644 (file)
@@ -5317,7 +5317,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
                /* this should become disabled button .. */
                if (but->lock == true) {
                        if (but->lockstr) {
-                               BKE_report(NULL, RPT_WARNING, but->lockstr);
+                               WM_report(C, RPT_INFO, but->lockstr);
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                return WM_UI_HANDLER_BREAK;
                        }
@@ -5740,6 +5740,10 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
        }
        else if (data->state == BUTTON_STATE_NUM_EDITING) {
                ui_numedit_end(but, data);
+
+               if (but->flag & UI_BUT_DRIVEN)
+                       WM_report(C, RPT_INFO, "Can't edit driven number value, see graph editor for the driver setup.");
+
                if (ui_is_a_warp_but(but)) {
 
 #ifdef USE_CONT_MOUSE_CORRECT
index 3d2266d0cb816711a093f31f8fbdd4d9ba324155..75c1f956f1b12e7b6fcd9063054298da740d735b 100644 (file)
@@ -1476,11 +1476,13 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
                                                break;
                                        case MAKE_LINKS_ANIMDATA:
                                                BKE_copy_animdata_id((ID *)ob_dst, (ID *)ob_src, FALSE);
-                                               if (obdata_id->lib) {
-                                                       is_lib = true;
-                                                       break;
+                                               if (ob_dst->data && ob_src->data) {
+                                                       if (obdata_id->lib) {
+                                                               is_lib = true;
+                                                               break;
+                                                       }
+                                                       BKE_copy_animdata_id((ID *)ob_dst->data, (ID *)ob_src->data, FALSE);
                                                }
-                                               BKE_copy_animdata_id((ID *)ob_dst->data, (ID *)ob_src->data, FALSE);
                                                DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
                                                break;
                                        case MAKE_LINKS_GROUP:
@@ -1499,6 +1501,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
                                                                is_cycle = TRUE;
                                                        }
                                                }
+                                               break;
                                        }
                                        case MAKE_LINKS_DUPLIGROUP:
                                                ob_dst->dup_group = ob_src->dup_group;
index 89989d73049ce89a071fac8071bdbdc200ded2f3..909b70c8d3c4164a9e299e3b70b589f3068ac35b 100644 (file)
@@ -67,6 +67,7 @@
 #include "BKE_object.h"
 #include "BKE_lattice.h"
 
+#include "DNA_armature_types.h"
 #include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
@@ -124,13 +125,8 @@ bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name)
 
        if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
                return NULL;
-       
-       defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
-
-       BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
 
-       BLI_addtail(&ob->defbase, defgroup);
-       defgroup_unique_name(defgroup, ob);
+       defgroup = BKE_defgroup_new(ob, name);
 
        ob->actdef = BLI_countlist(&ob->defbase);
 
@@ -755,13 +751,10 @@ static bool ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGro
        const int use_vert_sel = vertex_group_use_vert_sel(ob_dst);
 
        /* Ensure vertex group on target.*/
-       if (!defgroup_find_name(ob_dst, dg_src->name)) {
-               ED_vgroup_add_name(ob_dst, dg_src->name);
+       if ((dg_dst = defgroup_find_name(ob_dst, dg_src->name)) == NULL) {
+               dg_dst = BKE_defgroup_new(ob_dst, dg_src->name);
        }
 
-       /* Get destination deformgroup.*/
-       dg_dst = defgroup_find_name(ob_dst, dg_src->name);
-
        /* Get meshes.*/
        dmesh_src = mesh_get_derived_deform(scene, ob_src, CD_MASK_BAREMESH);
        me_dst = ob_dst->data;
@@ -2913,6 +2906,17 @@ static bool vgroup_remove_verts(Object *ob, int allverts)
 /********************** vertex group operators *********************/
 
 static int vertex_group_poll(bContext *C)
+{
+       Object *ob = ED_object_context(C);
+       ID *data = (ob) ? ob->data : NULL;
+
+       return (ob && !ob->id.lib 
+               && data && !data->lib
+               && OB_TYPE_SUPPORT_VGROUP(ob->type) 
+               && BLI_countlist(&ob->defbase) > 0 );
+}
+
+static int vertex_group_can_add_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
@@ -2920,12 +2924,24 @@ static int vertex_group_poll(bContext *C)
 }
 
 static int vertex_group_mesh_poll(bContext *C)
+{
+       Object *ob = ED_object_context(C);
+       ID *data = (ob) ? ob->data : NULL;
+
+       return (ob && !ob->id.lib
+               && data && !data->lib
+               && ob->type == OB_MESH
+               && BLI_countlist(&ob->defbase) > 0 );
+}
+
+static int vertex_group_mesh_can_add_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
        return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib);
 }
 
+
 static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
 {
        Object *ob = ED_object_context(C);
@@ -3010,7 +3026,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot)
        ot->description = "Add a new vertex group to the active object";
        
        /* api callbacks */
-       ot->poll = vertex_group_poll;
+       ot->poll = vertex_group_can_add_poll;
        ot->exec = vertex_group_add_exec;
 
        /* flags */
@@ -3748,55 +3764,73 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op)
 {
        Scene *scene = CTX_data_scene(C);
        Object *ob_act = CTX_data_active_object(C);
-       bDeformGroup *dg_src;
        int fail = 0;
+       bool change = false;
 
-       WT_VertexGroupMode vertex_group_mode = RNA_enum_get(op->ptr, "WT_vertex_group_mode");
-       WT_Method method = RNA_enum_get(op->ptr, "WT_method");
-       WT_ReplaceMode replace_mode = RNA_enum_get(op->ptr, "WT_replace_mode");
+       WT_VertexGroupMode vertex_group_mode = RNA_enum_get(op->ptr, "group_select_mode");
+       WT_Method method = RNA_enum_get(op->ptr, "method");
+       WT_ReplaceMode replace_mode = RNA_enum_get(op->ptr, "replace_mode");
 
        /* Macro to loop through selected objects and perform operation depending on function, option and method.*/
-       CTX_DATA_BEGIN (C, Object *, ob_slc, selected_editable_objects)
+       CTX_DATA_BEGIN (C, Object *, ob_src, selected_editable_objects)
        {
+               if (ob_act != ob_src) {
+
+                       if (ob_src->defbase.first == NULL) {
+                               BKE_reportf(op->reports, RPT_WARNING,
+                                           "Skipping object '%s' it has no vertex groups", ob_src->id.name + 2);
+                               continue;
+                       }
+                       else if (ob_src->type != OB_MESH) {
+                               BKE_reportf(op->reports, RPT_WARNING,
+                                           "Skipping object '%s' only copying from meshes is supported", ob_src->id.name + 2);
+                               continue;
+                       }
 
-               if (ob_act != ob_slc && ob_slc->defbase.first) {
                        switch (vertex_group_mode) {
 
                                case WT_REPLACE_ACTIVE_VERTEX_GROUP:
-                                       if (!ed_vgroup_transfer_weight(ob_act, ob_slc, BLI_findlink(&ob_slc->defbase, ob_slc->actdef - 1),
-                                                                      scene, method, replace_mode, op))
-                                       {
+                               {
+                                       bDeformGroup *dg_src;
+                                       dg_src = BLI_findlink(&ob_src->defbase, ob_src->actdef - 1);
+                                       if (ed_vgroup_transfer_weight(ob_act, ob_src, dg_src, scene, method, replace_mode, op)) {
+                                               change = true;
+                                       }
+                                       else {
                                                fail++;
                                        }
                                        break;
-
+                               }
                                case WT_REPLACE_ALL_VERTEX_GROUPS:
-                                       for (dg_src = ob_slc->defbase.first; dg_src; dg_src = dg_src->next) {
-                                               if (!ed_vgroup_transfer_weight(ob_act, ob_slc, dg_src, scene, method, replace_mode, op)) {
+                               {
+                                       bDeformGroup *dg_src;
+                                       for (dg_src = ob_src->defbase.first; dg_src; dg_src = dg_src->next) {
+                                               if (ed_vgroup_transfer_weight(ob_act, ob_src, dg_src, scene, method, replace_mode, op)) {
+                                                       change = true;
+                                               }
+                                               else {
                                                        fail++;
                                                }
                                        }
                                        break;
-
+                               }
                                default:
                                        BLI_assert(0);
                                        break;
                        }
                }
        }
-
-       /* Event notifiers for correct display of data.*/
-       DAG_id_tag_update(&ob_slc->id, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_slc);
-       WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob_slc->data);
-
        CTX_DATA_END;
 
-       if (fail != 0) {
-               return OPERATOR_CANCELLED;
+       if (change) {
+               /* Event notifiers for correct display of data.*/
+               DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+               WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob_act);
+               return OPERATOR_FINISHED;
        }
        else {
-               return OPERATOR_FINISHED;
+               BKE_report(op->reports, RPT_WARNING, "Failed, no other selected objects with vertex groups found.");
+               return OPERATOR_CANCELLED;
        }
 }
 
@@ -3809,16 +3843,17 @@ void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot)
        ot->description = "Transfer weight paint to active from selected mesh";
 
        /* API callbacks.*/
-       ot->poll = vertex_group_poll;
+       ot->poll = vertex_group_mesh_can_add_poll;
        ot->exec = vertex_group_transfer_weight_exec;
 
        /* Flags.*/
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* Properties.*/
-       ot->prop = RNA_def_enum(ot->srna, "WT_vertex_group_mode", WT_vertex_group_mode_item, 1, "Group", "");
-       ot->prop = RNA_def_enum(ot->srna, "WT_method", WT_method_item, 3, "Method", "");
-       ot->prop = RNA_def_enum(ot->srna, "WT_replace_mode", WT_replace_mode_item, 1, "Replace", "");
+       /* TODO, use vgroup_operator_subset_select_props for group_select_mode */
+       ot->prop = RNA_def_enum(ot->srna, "group_select_mode", WT_vertex_group_mode_item, WT_REPLACE_ACTIVE_VERTEX_GROUP, "Group", "");
+       ot->prop = RNA_def_enum(ot->srna, "method", WT_method_item, WT_BY_NEAREST_FACE, "Method", "");
+       ot->prop = RNA_def_enum(ot->srna, "replace_mode", WT_replace_mode_item, WT_REPLACE_ALL_WEIGHTS, "Replace", "");
 }
 
 static int set_active_group_exec(bContext *C, wmOperator *op)
index 173a76a54e89a163f80a3c251dc987f7258ead18..a891524b5c6f30db1229150005425335d385fe55 100644 (file)
@@ -380,11 +380,9 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
                flip_side_name(name, defgroup->name, FALSE);
                mirrdef = defgroup_name_index(ob, name);
                if (mirrdef == -1) {
-                       int olddef = ob->actdef;  /* tsk, ED_vgroup_add sets the active defgroup */
-                       if (ED_vgroup_add_name(ob, name)) {
+                       if (BKE_defgroup_new(ob, name)) {
                                mirrdef = BLI_countlist(&ob->defbase) - 1;
                        }
-                       ob->actdef = olddef;
                }
 
                /* curdef should never be NULL unless this is
index 3b769761dfb6aa67c8ce5085a73e6b31c2470b3c..cfcc4641afdac07889a7d48b761f3fa5a1a635fa 100644 (file)
@@ -1252,8 +1252,6 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
                                }
                                break;
                        }
-                       case TSE_SCRIPT_BASE:
-                               UI_icon_draw(x, y, ICON_TEXT); break;
                        case TSE_POSE_BASE:
                                UI_icon_draw(x, y, ICON_ARMATURE_DATA); break;
                        case TSE_POSE_CHANNEL:
index 0a1d3a63f2c68614b8ac7ca007d5b6b78b2ff585..2f97108c5ee55c9ca423aaa9a280d8a356937e7a 100644 (file)
@@ -219,7 +219,7 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem,
                /* do nothing */;
        }
        else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE,
-                       TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS))
+                       TSE_DRIVER_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS))
        {
                BKE_report(reports, RPT_WARNING, "Cannot edit builtin name");
        }
index 3ab412f0ddca724a4d967909a8abef2d73d77072..fe07a7dae9f8829ac1a89efb18fc5637d26bcf77 100644 (file)
@@ -77,7 +77,7 @@ typedef struct TreeElement {
 #define TSE_MODIFIER_BASE   9
 #define TSE_MODIFIER        10
 #define TSE_LINKED_OB       11
-#define TSE_SCRIPT_BASE     12
+// #define TSE_SCRIPT_BASE     12  // UNUSED
 #define TSE_POSE_BASE       13
 #define TSE_POSE_CHANNEL    14
 #define TSE_ANIM_DATA       15
index 11a4dcfab8aa3c5744ffff94be729cd4e39e6307..af14e959c11ffbeea47a1498a8cb887aa931165e 100644 (file)
 # Generated code has some unused vars we can ignore.
 remove_strict_flags()
 
+if(CMAKE_COMPILER_IS_GNUCC)
+       # add here so we fail early.
+       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
+endif()
+
 # message(STATUS "Configuring makesrna")
 
 # files rna_access.c rna_define.c makesrna.c intentionally excluded.
index b222dd9148bdf5b25cea69c513eee1fa02493301..fd151ccebb9cff6e75d0582335116da689dcb236 100644 (file)
@@ -472,6 +472,12 @@ static void rna_Armature_bones_next(CollectionPropertyIterator *iter)
        iter->valid = (internal->link != NULL);
 }
 
+static int rna_Armature_is_editmode_get(PointerRNA *ptr)
+{
+       bArmature *arm = (bArmature *)ptr->id.data;
+       return (arm->edbo != NULL);
+}
+
 #else
 
 static int rna_matrix_dimsize_4x4[] = {4, 4};
@@ -1071,6 +1077,12 @@ static void rna_def_armature(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
        RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
 /* XXX deprecated ....... old animviz for armatures only */
+
+
+       prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_Armature_is_editmode_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
 }
 
 void RNA_def_armature(BlenderRNA *brna)
index c97345452452201f43d8ab8f6f340cfb0878644c..21bf2ec6719a09e3cab3f1a696f446fff37e1234 100644 (file)
@@ -683,6 +683,18 @@ static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA
        rna_iterator_listbase_begin(iter, BKE_curve_nurbs_get(cu), NULL);
 }
 
+static int rna_Curve_is_editmode_get(PointerRNA *ptr)
+{
+       Curve *cu = (Curve *)ptr->id.data;
+       const short type = BKE_curve_type_get(cu);
+       if (type == OB_FONT) {
+               return (cu->editfont != NULL);
+       }
+       else {
+               return (cu->editnurb != NULL);
+       }
+}
+
 #else
 
 static void rna_def_bpoint(BlenderRNA *brna)
@@ -1485,6 +1497,11 @@ static void rna_def_curve(BlenderRNA *brna)
        RNA_def_property_range(prop, 0, 1.0);
        RNA_def_property_ui_text(prop, "End Bevel Factor", "Factor that defines to where beveling of spline happens (0=to the very beginning, 1=to the very end)");
        RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
+       prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_Curve_is_editmode_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
 }
 
 static void rna_def_curve_nurb(BlenderRNA *brna)
index e7b122068711519765e1ce7e8a050eaeca3fb485..3bb0071630224de0df4b4300310156c1fce0e494 100644 (file)
@@ -234,6 +234,11 @@ static char *rna_LatticePoint_path(PointerRNA *ptr)
        return BLI_strdup("");
 }
 
+static int rna_Lattice_is_editmode_get(PointerRNA *ptr)
+{
+       Lattice *lt = (Lattice *)ptr->id.data;
+       return (lt->editlatt != NULL);
+}
 
 #else
 
@@ -350,6 +355,11 @@ static void rna_def_lattice(BlenderRNA *brna)
                                          "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
        RNA_def_property_ui_text(prop, "Points", "Points of the lattice");
 
+       prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_Lattice_is_editmode_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
+
        /* pointers */
        rna_def_animdata_common(srna);
 }
index 85a669adcc070c3445f04c92271d45e007ebaa69..3a0e52aa3f255c82613532e7d0b5769cd2921739 100644 (file)
@@ -1556,6 +1556,13 @@ static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, ReportList *
        return ptr;
 }
 
+
+static int rna_Mesh_is_editmode_get(PointerRNA *ptr)
+{
+       Mesh *me = rna_mesh(ptr);
+       return (me->edit_btmesh != NULL);
+}
+
 /* only to quiet warnings */
 static void UNUSED_FUNCTION(rna_mesh_unused)(void)
 {
@@ -3211,6 +3218,11 @@ static void rna_def_mesh(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Selected Face Total", "Selected face count in editmode");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
+       prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_Mesh_is_editmode_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
+
        /* pointers */
        rna_def_animdata_common(srna);
        rna_def_texmat_common(srna, "rna_Mesh_texspace_editable");
index f38151fd7212118c6017ed445a228e7052705bf3..898825820ac013298ce8ffae9c3246dea692057a 100644 (file)
@@ -158,6 +158,12 @@ static void rna_MetaBall_elements_clear(MetaBall *mb)
        }
 }
 
+static int rna_Meta_is_editmode_get(PointerRNA *ptr)
+{
+       MetaBall *mb = ptr->id.data;
+       return (mb->editelems != NULL);
+}
+
 #else
 
 static void rna_def_metaelement(BlenderRNA *brna)
@@ -350,6 +356,11 @@ static void rna_def_metaball(BlenderRNA *brna)
        RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
        RNA_def_property_collection_funcs(prop, 0, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
        
+       prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_funcs(prop, "rna_Meta_is_editmode_get", NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
+
        /* anim */
        rna_def_animdata_common(srna);
 
index 070585245cf9f635f9216cdd97255146e80e8679..f7d347e8a5a0c472b4d0000cca1f9ba8c9523b95 100644 (file)
@@ -468,6 +468,30 @@ void RE_FreePersistentData(void)
 
 /* ********* initialize state ******** */
 
+/* clear full sample and tile flags if needed */
+static int check_mode_full_sample(RenderData *rd)
+{
+       int scemode = rd->scemode;
+
+       if ((rd->mode & R_OSA) == 0)
+               scemode &= ~R_FULL_SAMPLE;
+
+#ifdef WITH_OPENEXR
+       if (scemode & R_FULL_SAMPLE)
+               scemode |= R_EXR_TILE_FILE;   /* enable automatic */
+
+       /* Until use_border is made compatible with save_buffers/full_sample, render without the later instead of not rendering at all.*/
+       if (rd->mode & R_BORDER) {
+               scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
+       }
+
+#else
+       /* can't do this without openexr support */
+       scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
+#endif
+
+       return scemode;
+}
 
 /* what doesn't change during entire render sequence */
 /* disprect is optional, if NULL it assumes full window render */
@@ -533,22 +557,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
                return;
        }
 
-       if ((re->r.mode & (R_OSA)) == 0)
-               re->r.scemode &= ~R_FULL_SAMPLE;
-
-#ifdef WITH_OPENEXR
-       if (re->r.scemode & R_FULL_SAMPLE)
-               re->r.scemode |= R_EXR_TILE_FILE;   /* enable automatic */
-
-       /* Until use_border is made compatible with save_buffers/full_sample, render without the later instead of not rendering at all.*/
-       if (re->r.mode & R_BORDER) {
-               re->r.scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
-       }
-
-#else
-       /* can't do this without openexr support */
-       re->r.scemode &= ~(R_EXR_TILE_FILE | R_FULL_SAMPLE);
-#endif
+       re->r.scemode = check_mode_full_sample(&re->r);
        
        /* fullsample wants uniform osa levels */
        if (source && (re->r.scemode & R_FULL_SAMPLE)) {
@@ -2222,6 +2231,7 @@ static int check_composite_output(Scene *scene)
 int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *reports)
 {
        SceneRenderLayer *srl;
+       int scemode = check_mode_full_sample(&scene->r);
        
        if (scene->r.mode & R_BORDER) {
                if (scene->r.border.xmax <= scene->r.border.xmin ||
@@ -2232,7 +2242,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
                }
        }
        
-       if (scene->r.scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) {
+       if (scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) {
                char str[FILE_MAX];
                
                render_result_exr_file_path(scene, "", 0, str);
@@ -2243,16 +2253,14 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
                }
                
                /* no fullsample and edge */
-               if ((scene->r.scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) {
+               if ((scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) {
                        BKE_report(reports, RPT_ERROR, "Full sample does not support edge enhance");
                        return 0;
                }
                
        }
-       else
-               scene->r.scemode &= ~R_FULL_SAMPLE;  /* clear to be sure */
        
-       if (scene->r.scemode & R_DOCOMP) {
+       if (scemode & R_DOCOMP) {
                if (scene->use_nodes) {
                        if (!scene->nodetree) {
                                BKE_report(reports, RPT_ERROR, "No node tree in scene");
@@ -2264,7 +2272,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
                                return 0;
                        }
                        
-                       if (scene->r.scemode & R_FULL_SAMPLE) {
+                       if (scemode & R_FULL_SAMPLE) {
                                if (composite_needs_render(scene, 0) == 0) {
                                        BKE_report(reports, RPT_ERROR, "Full sample AA not supported without 3D rendering");
                                        return 0;
@@ -2298,7 +2306,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r
        }
 
        /* layer flag tests */
-       if (scene->r.scemode & R_SINGLE_LAYER) {
+       if (scemode & R_SINGLE_LAYER) {
                srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
                /* force layer to be enabled */
                srl->layflag &= ~SCE_LAY_DISABLE;
@@ -2322,7 +2330,6 @@ static void validate_render_settings(Render *re)
                if (re->r.osa == 0)
                        re->r.scemode &= ~R_FULL_SAMPLE;
        }
-       else re->r.scemode &= ~R_FULL_SAMPLE;   /* clear to be sure */
 
        if (RE_engine_is_external(re)) {
                /* not supported yet */
index fb9b8b8f10b37bca5477137bc8ffa38d3fd15310..5225a6dfa370ff46414c38ab196b3fd8f3d9632c 100644 (file)
@@ -178,6 +178,14 @@ void               WM_event_add_notifier(const struct bContext *C, unsigned int type, void *r
 void           WM_main_add_notifier(unsigned int type, void *reference);
 void           WM_main_remove_notifier_reference(const void *reference);
 
+                       /* reports */
+void        WM_report(const struct bContext *C, ReportType type, const char *message);
+void        WM_reportf(const struct bContext *C, ReportType type, const char *format, ...)
+#ifdef __GNUC__
+__attribute__ ((format(printf, 3, 4)))
+#endif
+;
+
 void           wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add);
 
                        /* at maximum, every timestep seconds it triggers event_type events */
index 0ed6e64346326f760529a2126e3a1663d625f311..4df3557b3eaf500f20f981c8b82aac65003fe67c 100644 (file)
@@ -43,6 +43,7 @@
 #include "GHOST_C-api.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_dynstr.h"
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
 
@@ -533,6 +534,56 @@ void WM_event_print(const wmEvent *event)
 
 #endif /* NDEBUG */
 
+static void wm_add_reports(const bContext *C, ReportList *reports)
+{
+       /* if the caller owns them, handle this */
+       if (reports->list.first && (reports->flag & RPT_OP_HOLD) == 0) {
+
+               wmWindowManager *wm = CTX_wm_manager(C);
+               ReportList *wm_reports = CTX_wm_reports(C);
+               ReportTimerInfo *rti;
+
+               /* add reports to the global list, otherwise they are not seen */
+               BLI_movelisttolist(&wm_reports->list, &reports->list);
+               
+               /* After adding reports to the global list, reset the report timer. */
+               WM_event_remove_timer(wm, NULL, wm_reports->reporttimer);
+               
+               /* Records time since last report was added */
+               wm_reports->reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05);
+               
+               rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
+               wm_reports->reporttimer->customdata = rti;
+       }
+}
+
+void WM_report(const bContext *C, ReportType type, const char *message)
+{
+       ReportList reports;
+
+       BKE_reports_init(&reports, RPT_STORE);
+       BKE_report(&reports, type, message);
+
+       wm_add_reports(C, &reports);
+
+       BKE_reports_clear(&reports);
+}
+
+void WM_reportf(const bContext *C, ReportType type, const char *format, ...)
+{
+       DynStr *ds;
+       va_list args;
+
+       ds = BLI_dynstr_new();
+       va_start(args, format);
+       BLI_dynstr_vappendf(ds, format, args);
+       va_end(args);
+
+       WM_report(C, type, BLI_dynstr_get_cstring(ds));
+
+       BLI_dynstr_free(ds);
+}
+
 /* (caller_owns_reports == TRUE) when called from python */
 static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int caller_owns_reports)
 {
@@ -575,24 +626,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
        }
 
        /* if the caller owns them, handle this */
-       if (op->reports->list.first && (op->reports->flag & RPT_OP_HOLD) == 0) {
-
-               wmWindowManager *wm = CTX_wm_manager(C);
-               ReportList *wm_reports = CTX_wm_reports(C);
-               ReportTimerInfo *rti;
-
-               /* add reports to the global list, otherwise they are not seen */
-               BLI_movelisttolist(&wm_reports->list, &op->reports->list);
-               
-               /* After adding reports to the global list, reset the report timer. */
-               WM_event_remove_timer(wm, NULL, wm_reports->reporttimer);
-               
-               /* Records time since last report was added */
-               wm_reports->reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05);
-               
-               rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
-               wm_reports->reporttimer->customdata = rti;
-       }
+       wm_add_reports(C, op->reports);
 }
 
 /* this function is mainly to check that the rules for freeing
index 6a2611592f164aa95d27458587c86dde65a0bf57..13230f48a15db909219dbc4b88b49fb0ace703e3 100644 (file)
@@ -1297,7 +1297,11 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
                km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
        }
        else if (strstr(opname, "OBJECT_OT")) {
-               km = WM_keymap_find_all(C, "Object Mode", 0, 0);
+               /* exception, this needs to work outside object mode too */
+               if (strstr(opname, "OBJECT_OT_mode_set"))
+                       km = WM_keymap_find_all(C, "Object Non-modal", 0, 0);
+               else
+                       km = WM_keymap_find_all(C, "Object Mode", 0, 0);
        }