Merging r49667 through r49680 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 8 Aug 2012 08:21:58 +0000 (08:21 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 8 Aug 2012 08:21:58 +0000 (08:21 +0000)
intern/ghost/intern/GHOST_SystemX11.cpp
source/blender/blenlib/intern/rct.c
source/blender/compositor/nodes/COM_MuteNode.cpp
source/blender/editors/mask/mask_add.c
source/blender/editors/mask/mask_select.c
source/blender/editors/object/object_select.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_node/node_view.c
source/blender/makesrna/intern/rna_access.c
source/blender/python/intern/bpy_rna.c

index e8f172f8b1c84603d62c95d25d1f7e61b4601a76..7ac9b0c3c2447545c34a0d19b648edf5d0e39000 100644 (file)
@@ -152,7 +152,9 @@ GHOST_SystemX11::
 ~GHOST_SystemX11()
 {
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
-       XCloseIM(m_xim);
+       if (m_xim) {
+               XCloseIM(m_xim);
+       }
 #endif
 
        XCloseDisplay(m_display);
index 658d45ad171334da16f97ceadf2a2871c8c413ea..68a00d814441a85249776fd765e66a0d7943ccf4 100644 (file)
@@ -206,19 +206,19 @@ void BLI_rcti_init(rcti *rect, int xmin, int xmax, int ymin, int ymax)
        }
 }
 
-void BLI_rcti_init_minmax(struct rcti *rect)
+void BLI_rcti_init_minmax(rcti *rect)
 {
        rect->xmin = rect->ymin = INT_MAX;
        rect->xmax = rect->ymax = INT_MIN;
 }
 
-void BLI_rctf_init_minmax(struct rctf *rect)
+void BLI_rctf_init_minmax(rctf *rect)
 {
-       rect->xmin = rect->ymin = FLT_MAX;
-       rect->xmax = rect->ymax = FLT_MIN;
+       rect->xmin = rect->ymin =  FLT_MAX;
+       rect->xmax = rect->ymax = -FLT_MAX;
 }
 
-void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
+void BLI_rcti_do_minmax_v(rcti *rect, const int xy[2])
 {
        if (xy[0] < rect->xmin) rect->xmin = xy[0];
        if (xy[0] > rect->xmax) rect->xmax = xy[0];
@@ -226,7 +226,7 @@ void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
        if (xy[1] > rect->ymax) rect->ymax = xy[1];
 }
 
-void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
+void BLI_rctf_do_minmax_v(rctf *rect, const float xy[2])
 {
        if (xy[0] < rect->xmin) rect->xmin = xy[0];
        if (xy[0] > rect->xmax) rect->xmax = xy[0];
index 2c96473a556b2b88a4fd8749b98a7fb8171afe56..eb2da147ecab14972df1ae9e3926e0f0e36e6069 100644 (file)
@@ -110,6 +110,7 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
         */
        if ((editorNode->flag & NODE_MUTED) && editorNode->typeinfo->internal_connect) {
                vector<InputSocket *> &inputsockets = this->getInputSockets();
+               vector<OutputSocket *> relinkedsockets;
                bNodeTree *editorTree = (bNodeTree *) context->getbNodeTree();
                SocketMap socketMap;
                ListBase intlinks;
@@ -132,10 +133,37 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
                                        else {
                                                createDefaultOutput(graph, toSocket);
                                        }
+
+                                       relinkedsockets.push_back(toSocket);
                                }
                        }
                }
 
+               /* in some cases node could be marked as muted, but it wouldn't have internal connections
+                * this happens in such cases as muted render layer node
+                *
+                * to deal with such cases create default operation for not-relinked output sockets
+                */
+
+               for (unsigned int index = 0; index < outputsockets.size(); index++) {
+                       OutputSocket *output = outputsockets[index];
+
+                       if (output->isConnected()) {
+                               bool relinked = false;
+                               vector<OutputSocket *>::iterator it;
+
+                               for (it = relinkedsockets.begin(); it != relinkedsockets.end(); it++) {
+                                       if (*it == output) {
+                                               relinked = true;
+                                               break;
+                                       }
+                               }
+
+                               if (!relinked)
+                                       createDefaultOutput(graph, output);
+                       }
+               }
+
                BLI_freelistN(&intlinks);
        }
        else {
index e20a7b51d13020b2c60878cb1497716ae9df7f3f..e9b31b8df1ac67acd5c823fe7e3a854f353d3b15 100644 (file)
@@ -646,7 +646,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
+       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
                             "Location", "Location of vertex in normalized space", -1.0f, 1.0f);
 }
 
@@ -720,6 +720,6 @@ void MASK_OT_add_feather_vertex(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
+       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
                             "Location", "Location of vertex in normalized space", -1.0f, 1.0f);
 }
index e746f4258a5d7d35358efb3b1b98659cce7faa20..b4b2a4ec4f0cf2b6a1fda8891f1abb4a15c8b7c6 100644 (file)
@@ -392,7 +392,7 @@ void MASK_OT_select(wmOperatorType *ot)
        /* properties */
        WM_operator_properties_mouse_select(ot);
 
-       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
+       RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX,
                             "Location", "Location of vertex in normalized space", -1.0f, 1.0f);
 }
 
index 79ee57d3f91bd35b22c4038b0ac2b040974b67b3..ac3210348de62924b364287fdf5c98323760ca14 100644 (file)
@@ -236,11 +236,13 @@ static int object_select_all_by_obdata(bContext *C, void *obdata)
 
        CTX_DATA_BEGIN (C, Base *, base, visible_bases)
        {
-               if (base->object->data == obdata) {
-                       base->flag |= SELECT;
-                       base->object->flag = base->flag;
+               if ((base->flag & SELECT) == 0) {
+                       if (base->object->data == obdata) {
+                               base->flag |= SELECT;
+                               base->object->flag = base->flag;
 
-                       changed = TRUE;
+                               changed = TRUE;
+                       }
                }
        }
        CTX_DATA_END;
@@ -254,50 +256,56 @@ static int object_select_all_by_material_texture(bContext *C, int use_texture, M
 
        CTX_DATA_BEGIN (C, Base *, base, visible_bases)
        {
-               Object *ob = base->object;
-               Material *mat1;
-               int a, b;
+               if ((base->flag & SELECT) == 0) {
+                       Object *ob = base->object;
+                       Material *mat1;
+                       int a, b;
 
-               for (a = 1; a <= ob->totcol; a++) {
-                       mat1 = give_current_material(ob, a);
+                       for (a = 1; a <= ob->totcol; a++) {
+                               mat1 = give_current_material(ob, a);
 
-                       if (!use_texture) {
-                               if (mat1 == mat) {
-                                       base->flag |= SELECT;
-                                       changed = TRUE;
+                               if (!use_texture) {
+                                       if (mat1 == mat) {
+                                               base->flag |= SELECT;
+                                               changed = TRUE;
+                                       }
                                }
-                       }
-                       else if (mat1 && use_texture) {
-                               for (b = 0; b < MAX_MTEX; b++) {
-                                       if (mat1->mtex[b]) {
-                                               if (tex == mat1->mtex[b]->tex) {
-                                                       base->flag |= SELECT;
-                                                       changed = TRUE;
-                                                       break;
+                               else if (mat1 && use_texture) {
+                                       for (b = 0; b < MAX_MTEX; b++) {
+                                               if (mat1->mtex[b]) {
+                                                       if (tex == mat1->mtex[b]->tex) {
+                                                               base->flag |= SELECT;
+                                                               changed = TRUE;
+                                                               break;
+                                                       }
                                                }
                                        }
                                }
                        }
-               }
 
-               base->object->flag = base->flag;
+                       base->object->flag = base->flag;
+               }
        }
        CTX_DATA_END;
 
        return changed;
 }
 
-static int object_select_all_by_dup_group(bContext *C, Group *dup_group)
+static int object_select_all_by_dup_group(bContext *C, Object *ob)
 {
        int changed = FALSE;
+       Group *dup_group = (ob->transflag & OB_DUPLIGROUP) ? ob->dup_group : NULL;
 
        CTX_DATA_BEGIN (C, Base *, base, visible_bases)
        {
-               if (base->object->dup_group == dup_group) {
-                       base->flag |= SELECT;
-                       base->object->flag = base->flag;
+               if ((base->flag & SELECT) == 0) {
+                       Group *dup_group_other = (base->object->transflag & OB_DUPLIGROUP) ? base->object->dup_group : NULL;
+                       if (dup_group == dup_group_other) {
+                               base->flag |= SELECT;
+                               base->object->flag = base->flag;
 
-                       changed = TRUE;
+                               changed = TRUE;
+                       }
                }
        }
        CTX_DATA_END;
@@ -311,25 +319,27 @@ static int object_select_all_by_particle(bContext *C, Object *ob)
 
        CTX_DATA_BEGIN (C, Base *, base, visible_bases)
        {
-               /* loop through other, then actives particles*/
-               ParticleSystem *psys;
-               ParticleSystem *psys_act;
-
-               for (psys = base->object->particlesystem.first; psys; psys = psys->next) {
-                       for (psys_act = ob->particlesystem.first; psys_act; psys_act = psys_act->next) {
-                               if (psys->part == psys_act->part) {
-                                       base->flag |= SELECT;
-                                       changed = TRUE;
+               if ((base->flag & SELECT) == 0) {
+                       /* loop through other, then actives particles*/
+                       ParticleSystem *psys;
+                       ParticleSystem *psys_act;
+
+                       for (psys = base->object->particlesystem.first; psys; psys = psys->next) {
+                               for (psys_act = ob->particlesystem.first; psys_act; psys_act = psys_act->next) {
+                                       if (psys->part == psys_act->part) {
+                                               base->flag |= SELECT;
+                                               changed = TRUE;
+                                               break;
+                                       }
+                               }
+
+                               if (base->flag & SELECT) {
                                        break;
                                }
                        }
 
-                       if (base->flag & SELECT) {
-                               break;
-                       }
+                       base->object->flag = base->flag;
                }
-
-               base->object->flag = base->flag;
        }
        CTX_DATA_END;
 
@@ -342,11 +352,13 @@ static int object_select_all_by_library(bContext *C, Library *lib)
 
        CTX_DATA_BEGIN (C, Base *, base, visible_bases)
        {
-               if (lib == base->object->id.lib) {
-                       base->flag |= SELECT;
-                       base->object->flag = base->flag;
+               if ((base->flag & SELECT) == 0) {
+                       if (lib == base->object->id.lib) {
+                               base->flag |= SELECT;
+                               base->object->flag = base->flag;
 
-                       changed = TRUE;
+                               changed = TRUE;
+                       }
                }
        }
        CTX_DATA_END;
@@ -360,11 +372,13 @@ static int object_select_all_by_library_obdata(bContext *C, Library *lib)
 
        CTX_DATA_BEGIN (C, Base *, base, visible_bases)
        {
-               if (base->object->data && lib == ((ID *)base->object->data)->lib) {
-                       base->flag |= SELECT;
-                       base->object->flag = base->flag;
+               if ((base->flag & SELECT) == 0) {
+                       if (base->object->data && lib == ((ID *)base->object->data)->lib) {
+                               base->flag |= SELECT;
+                               base->object->flag = base->flag;
 
-                       changed = TRUE;
+                               changed = TRUE;
+                       }
                }
        }
        CTX_DATA_END;
@@ -446,7 +460,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
                if (ob->dup_group == NULL)
                        return OPERATOR_CANCELLED;
 
-               changed = object_select_all_by_dup_group(C, ob->dup_group);
+               changed = object_select_all_by_dup_group(C, ob);
        }
        else if (nr == OBJECT_SELECT_LINKED_PARTICLE) {
                if (ob->particlesystem.first == NULL)
index 62aebcb4edc44206e35b065fd6fdab3fca8ae8fe..d54e3694f07b808527b708118c8dbd4da4b44033 100644 (file)
@@ -179,7 +179,7 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot)
 
        /* rna */
        RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
-       RNA_def_float(ot->srna, "value", 0, FLT_MIN, FLT_MAX, "Value", "", -100.0f, 100.0f);
+       RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Value", "", -100.0f, 100.0f);
 }
 
 /* ************************** registration - operator types **********************************/
index 77f24302af383886c7050ed8454d6ea519a359aa..7ad283b986995715394d523ebd656312fcbc2c79 100644 (file)
@@ -36,6 +36,7 @@
 #include "BKE_context.h"
 #include "BKE_image.h"
 #include "BKE_screen.h"
+#include "BKE_node.h"
 
 #include "ED_node.h"  /* own include */
 #include "ED_screen.h"
 
 /* **************** View All Operator ************** */
 
-static int snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode *snode, const int node_flag)
+static int space_node_view_flag(SpaceNode *snode, ARegion *ar, const int node_flag)
 {
        bNode *node;
        rctf cur_new;
        float oldwidth, oldheight, width, height;
-       int change = FALSE;
-       
+       int tot = 0;
+       int has_frame = FALSE;
        
        oldwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin;
        oldheight = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
@@ -77,44 +78,63 @@ static int snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode *snode, const
                for (node = snode->edittree->nodes.first; node; node = node->next) {
                        if ((node->flag & node_flag) == node_flag) {
                                BLI_rctf_union(&cur_new, &node->totr);
-                               change = TRUE;
+                               tot++;
+
+                               if (node->type == NODE_FRAME) {
+                                       has_frame = TRUE;
+                               }
                        }
                }
        }
 
-       if (change) {
-               snode->xof = 0;
-               snode->yof = 0;
+       if (tot) {
                width = cur_new.xmax - cur_new.xmin;
                height = cur_new.ymax - cur_new.ymin;
 
-               if (width > height) {
-                       float newheight;
-                       newheight = oldheight * width / oldwidth;
-                       cur_new.ymin = cur_new.ymin - newheight / 4;
-                       cur_new.ymax = cur_new.ymax + newheight / 4;
+               /* for single non-frame nodes, don't zoom in, just pan view,
+                * but do allow zooming out, this allows for big nodes to be zoomed out */
+               if ((tot == 1) &&
+                   (has_frame == FALSE) &&
+                   ((oldwidth * oldheight) > (width * height)))
+               {
+                       /* center, don't zoom */
+                       BLI_rctf_resize(&cur_new, oldwidth, oldheight);
                }
                else {
-                       float newwidth;
-                       newwidth = oldwidth * height / oldheight;
-                       cur_new.xmin = cur_new.xmin - newwidth / 4;
-                       cur_new.xmax = cur_new.xmax + newwidth / 4;
+                       width = cur_new.xmax - cur_new.xmin;
+                       height = cur_new.ymax - cur_new.ymin;
+
+                       if (width > height) {
+                               float newheight;
+                               newheight = oldheight * width / oldwidth;
+                               cur_new.ymin = cur_new.ymin - newheight / 4;
+                               cur_new.ymax = cur_new.ymax + newheight / 4;
+                       }
+                       else {
+                               float newwidth;
+                               newwidth = oldwidth * height / oldheight;
+                               cur_new.xmin = cur_new.xmin - newwidth / 4;
+                               cur_new.xmax = cur_new.xmax + newwidth / 4;
+                       }
                }
 
                ar->v2d.tot = ar->v2d.cur = cur_new;
                UI_view2d_curRect_validate(&ar->v2d);
        }
 
-       return change;
+       return (tot != 0);
 }
 
 static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = CTX_wm_region(C);
        SpaceNode *snode = CTX_wm_space_node(C);
-       
-       if (snode_home(sa, ar, snode, 0)) {
+
+       /* is this really needed? */
+       snode->xof = 0;
+       snode->yof = 0;
+
+       if (space_node_view_flag(snode, ar, 0)) {
                ED_region_tag_redraw(ar);
 
                return OPERATOR_FINISHED;
@@ -141,11 +161,10 @@ void NODE_OT_view_all(wmOperatorType *ot)
 
 static int node_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = CTX_wm_region(C);
        SpaceNode *snode = CTX_wm_space_node(C);
 
-       if (snode_home(sa, ar, snode, NODE_SELECT)) {
+       if (space_node_view_flag(snode, ar, NODE_SELECT)) {
                ED_region_tag_redraw(ar);
 
                return OPERATOR_FINISHED;
index 5b5367654eb4b4fc1a301743960208670e5e7989..ec4da31168687464ff3bf66dda6e689d7e83a2f6 100644 (file)
@@ -1031,7 +1031,7 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft
                        IDProperty *item;
 
                        item = IDP_GetPropertyTypeFromGroup(idp_ui, "soft_min", IDP_DOUBLE);
-                       *softmin = item ? (float)IDP_Double(item) : FLT_MIN;
+                       *softmin = item ? (float)IDP_Double(item) : -FLT_MAX;
 
                        item = IDP_GetPropertyTypeFromGroup(idp_ui, "soft_max", IDP_DOUBLE);
                        *softmax = item ? (float)IDP_Double(item) : FLT_MAX;
index 03e20322a59b8480fc6fda4d255540d7bd87648f..bd660ae00015b902e28bc17aa616a26155f0eaa9 100644 (file)
@@ -435,7 +435,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
 
        RNA_property_float_range(&self->ptr, self->prop, &min, &max);
 
-       if (min != FLT_MIN || max != FLT_MAX) {
+       if (min != -FLT_MAX || max != FLT_MAX) {
                int i, len = RNA_property_array_length(&self->ptr, self->prop);
                for (i = 0; i < len; i++) {
                        CLAMP(bmo->data[i], min, max);