From b21b24573d3538e893743d6bca233edba7b026b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Sep 2013 05:50:41 +0000 Subject: lots of operator descriptions were incorrectly copy/pasted. update some descriptions, others were removed and operators tagged as internal. add a script to detect duplicate operator descriptions. --- source/blender/editors/curve/editfont.c | 2 +- source/blender/editors/interface/view2d_ops.c | 6 ++++-- source/blender/editors/mesh/editmesh_bisect.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 8 ++++---- source/blender/editors/object/object_group.c | 4 ++-- source/blender/editors/object/object_hook.c | 4 ++-- source/blender/editors/sculpt_paint/paint_utils.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/editors/space_node/node_view.c | 2 +- source/blender/editors/space_sequencer/sequencer_edit.c | 2 +- source/blender/editors/space_sequencer/sequencer_modifier.c | 4 ++-- source/blender/editors/space_sequencer/sequencer_select.c | 2 +- source/blender/editors/space_text/text_ops.c | 10 +++++----- source/blender/editors/space_view3d/view3d_edit.c | 8 ++++---- source/blender/editors/space_view3d/view3d_view.c | 5 ++++- 15 files changed, 34 insertions(+), 29 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index b9759e16f20..ac9c338e431 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -981,7 +981,7 @@ void FONT_OT_move_select(wmOperatorType *ot) { /* identifiers */ ot->name = "Move Select"; - ot->description = "Make selection from current cursor position to new cursor position type"; + ot->description = "Move the cursor while selecting"; ot->idname = "FONT_OT_move_select"; /* api callbacks */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 22c20842723..00113666872 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1374,14 +1374,16 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot) { /* identifiers */ ot->name = "Smooth View 2D"; - ot->description = "Zoom in the view to the nearest item contained in the border"; + ot->description = ""; ot->idname = "VIEW2D_OT_smoothview"; /* api callbacks */ ot->invoke = view2d_smoothview_invoke; - ot->poll = view2d_poll; + /* flags */ + ot->flag = OPTYPE_INTERNAL; + /* rna */ WM_operator_properties_gesture_border(ot, FALSE); } diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index afafd8458c5..4cfee8cf6f2 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -300,7 +300,7 @@ void MESH_OT_bisect(struct wmOperatorType *ot) /* identifiers */ ot->name = "Bisect"; - ot->description = "Enforce symmetry (both form and topological) across an axis"; + ot->description = "Cuts geometry along a plane"; ot->idname = "MESH_OT_bisect"; /* api callbacks */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index f0e5a64b1bd..b5262bff850 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3342,7 +3342,7 @@ void MESH_OT_dissolve_verts(wmOperatorType *ot) { /* identifiers */ ot->name = "Dissolve Vertices"; - ot->description = "Dissolve geometry"; + ot->description = "Dissolve verts, merge edges and faces"; ot->idname = "MESH_OT_dissolve_verts"; /* api callbacks */ @@ -3379,7 +3379,7 @@ void MESH_OT_dissolve_edges(wmOperatorType *ot) { /* identifiers */ ot->name = "Dissolve Edges"; - ot->description = "Dissolve geometry"; + ot->description = "Dissolve edges, merging faces"; ot->idname = "MESH_OT_dissolve_edges"; /* api callbacks */ @@ -3418,7 +3418,7 @@ void MESH_OT_dissolve_faces(wmOperatorType *ot) { /* identifiers */ ot->name = "Dissolve Faces"; - ot->description = "Dissolve geometry"; + ot->description = "Dissolve faces"; ot->idname = "MESH_OT_dissolve_faces"; /* api callbacks */ @@ -4519,7 +4519,7 @@ void MESH_OT_wireframe(wmOperatorType *ot) /* identifiers */ ot->name = "Wire Frame"; ot->idname = "MESH_OT_wireframe"; - ot->description = "Inset new faces into selected faces"; + ot->description = "Create a solid wire-frame from faces"; /* api callbacks */ ot->exec = edbm_wireframe_exec; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 1f52346222c..a9fd3ce1288 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -289,7 +289,7 @@ void GROUP_OT_objects_remove_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Remove From All Groups"; - ot->description = "Remove selected objects from all groups or a selected group"; + ot->description = "Remove selected objects from all groups"; ot->idname = "GROUP_OT_objects_remove_all"; /* api callbacks */ @@ -335,7 +335,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove From Group"; - ot->description = "Remove selected objects from all groups or a selected group"; + ot->description = "Remove selected objects from a group"; ot->idname = "GROUP_OT_objects_remove"; /* api callbacks */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 5b20489c9cb..37656f82b25 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -569,7 +569,7 @@ void OBJECT_OT_hook_add_selob(wmOperatorType *ot) { /* identifiers */ ot->name = "Hook to Selected Object"; - ot->description = "Hook selected vertices to the first selected Object"; + ot->description = "Hook selected vertices to the first selected object"; ot->idname = "OBJECT_OT_hook_add_selob"; /* api callbacks */ @@ -603,7 +603,7 @@ void OBJECT_OT_hook_add_newob(wmOperatorType *ot) { /* identifiers */ ot->name = "Hook to New Object"; - ot->description = "Hook selected vertices to the first selected Object"; + ot->description = "Hook selected vertices to a newly created object"; ot->idname = "OBJECT_OT_hook_add_newob"; /* api callbacks */ diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index d376bd3180f..bfc431baea5 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -441,7 +441,7 @@ static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wm void PAINT_OT_face_select_linked_pick(wmOperatorType *ot) { ot->name = "Select Linked Pick"; - ot->description = "Select linked faces"; + ot->description = "Select linked faces under the cursor"; ot->idname = "PAINT_OT_face_select_linked_pick"; ot->invoke = paint_select_linked_pick_invoke; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 538e8394b1f..122dbae6129 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3480,7 +3480,7 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Gradient"; ot->idname = "PAINT_OT_weight_gradient"; - ot->description = "Sample a line and show it in Scope panels"; + ot->description = "Draw a line to apply a weight gradient to selected vertices"; /* api callbacks */ ot->invoke = paint_weight_gradient_invoke; diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index e4a9c4fa5db..f889a8ec97b 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -373,7 +373,7 @@ void NODE_OT_backimage_fit(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Fit"; ot->idname = "NODE_OT_backimage_fit"; - ot->description = "Zoom in/out the background image"; + ot->description = "Fit the background image to the view"; /* api callbacks */ ot->exec = backimage_fit_exec; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index d8b4824b528..8b2e7067eb9 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2960,7 +2960,7 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) /* identifiers */ ot->name = "Border Offset View"; ot->idname = "SEQUENCER_OT_view_ghost_border"; - ot->description = "Enable border select mode"; + ot->description = "Set the boundaries of the border used for offset-view"; /* api callbacks */ ot->invoke = WM_border_select_invoke; diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index 51df21e509a..c8fd6e4b6ea 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -99,7 +99,7 @@ void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Strip Modifier"; ot->idname = "SEQUENCER_OT_strip_modifier_add"; - ot->description = "Add a modifier to strip"; + ot->description = "Add a modifier to the strip"; /* api callbacks */ ot->exec = strip_modifier_add_exec; @@ -142,7 +142,7 @@ void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Strip Modifier"; ot->idname = "SEQUENCER_OT_strip_modifier_remove"; - ot->description = "Add a modifier to strip"; + ot->description = "Remove a modifier from the strip"; /* api callbacks */ ot->exec = strip_modifier_remove_exec; diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 254d15341cd..45f05d56076 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -892,7 +892,7 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot) /* identifiers */ ot->name = "Border Select"; ot->idname = "SEQUENCER_OT_select_border"; - ot->description = "Enable border select mode"; + ot->description = "Select strips using border selection"; /* api callbacks */ ot->invoke = WM_border_select_invoke; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 2c2a8b255da..c078e612d68 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1943,7 +1943,7 @@ void TEXT_OT_move_select(wmOperatorType *ot) /* identifiers */ ot->name = "Move Select"; ot->idname = "TEXT_OT_move_select"; - ot->description = "Make selection from current cursor position to new cursor position type"; + ot->description = "Move the cursor while selecting"; /* api callbacks */ ot->exec = text_move_select_exec; @@ -2291,7 +2291,7 @@ void TEXT_OT_scroll(wmOperatorType *ot) * scroll_bar. Both do basically the same thing (aside * from keymaps).*/ ot->idname = "TEXT_OT_scroll"; - ot->description = "Scroll text screen"; + ot->description = ""; /* api callbacks */ ot->exec = text_scroll_exec; @@ -2301,7 +2301,7 @@ void TEXT_OT_scroll(wmOperatorType *ot) ot->poll = text_scroll_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER | OPTYPE_INTERNAL; /* properties */ RNA_def_int(ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100); @@ -2385,7 +2385,7 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot) * scroll. Both do basically the same thing (aside * from keymaps).*/ ot->idname = "TEXT_OT_scroll_bar"; - ot->description = "Scroll text screen"; + ot->description = ""; /* api callbacks */ ot->invoke = text_scroll_bar_invoke; @@ -2394,7 +2394,7 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot) ot->poll = text_region_scroll_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING; + ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; /* properties */ RNA_def_int(ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 005bb5940bc..67c9ea4599c 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1257,7 +1257,7 @@ void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot) { /* identifiers */ ot->name = "NDOF Orbit View"; - ot->description = "Explore every angle of an object using the 3D mouse"; + ot->description = "Orbit the view using the 3D mouse"; ot->idname = "VIEW3D_OT_ndof_orbit"; /* api callbacks */ @@ -1355,7 +1355,7 @@ void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot) { /* identifiers */ ot->name = "NDOF Orbit View with Zoom"; - ot->description = "Explore every angle of an object using the 3D mouse"; + ot->description = "Orbit and zoom the view using the 3D mouse"; ot->idname = "VIEW3D_OT_ndof_orbit_zoom"; /* api callbacks */ @@ -1452,7 +1452,7 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot) { /* identifiers */ ot->name = "NDOF Pan View"; - ot->description = "Position your viewpoint with the 3D mouse"; + ot->description = "Pan the view with the 3D mouse"; ot->idname = "VIEW3D_OT_ndof_pan"; /* api callbacks */ @@ -1543,7 +1543,7 @@ void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) { /* identifiers */ ot->name = "NDOF Move View"; - ot->description = "Position your viewpoint with the 3D mouse"; + ot->description = "Pan and rotate the view with the 3D mouse"; ot->idname = "VIEW3D_OT_ndof_all"; /* api callbacks */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 7e39c0b6be0..388d83d3208 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -378,12 +378,15 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) /* identifiers */ ot->name = "Smooth View"; + ot->description = ""; ot->idname = "VIEW3D_OT_smoothview"; - ot->description = "The time to animate the change of view (in milliseconds)"; /* api callbacks */ ot->invoke = view3d_smoothview_invoke; + /* flags */ + ot->flag = OPTYPE_INTERNAL; + ot->poll = ED_operator_view3d_active; } -- cgit v1.2.3 From d6a52c67d56dddab35b04dd3dec7af58dd384df7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Sep 2013 07:58:38 +0000 Subject: fix [#36861] In face select masking circle select selects all when out of focus. --- source/blender/editors/mesh/editmesh_select.c | 1 + source/blender/editors/space_view3d/view3d_select.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 806ae96cb61..76c08433b25 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -266,6 +266,7 @@ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xma int EDBM_backbuf_check(unsigned int index) { + BLI_assert(selbuf != NULL); if (selbuf == NULL) return 1; if (index > 0 && index <= bm_vertoffs) return selbuf[index]; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c812f1084e2..8553791e229 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -2406,12 +2406,12 @@ static void paint_facesel_circle_select(ViewContext *vc, const bool select, cons { Object *ob = vc->obact; Mesh *me = ob ? ob->data : NULL; - /* int bbsel; */ /* UNUSED */ + bool bbsel; - if (me) { - bm_vertoffs = me->totpoly + 1; /* max index array */ + bm_vertoffs = me->totpoly + 1; /* max index array */ - /* bbsel = */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); + bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); + if (bbsel) { edbm_backbuf_check_and_select_tfaces(me, select); EDBM_backbuf_free(); paintface_flush_flags(ob); @@ -2431,15 +2431,17 @@ static void paint_vertsel_circle_select(ViewContext *vc, const bool select, cons const int use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT); Object *ob = vc->obact; Mesh *me = ob->data; - /* int bbsel; */ /* UNUSED */ + bool bbsel; /* CircleSelectUserData data = {NULL}; */ /* UNUSED */ if (use_zbuf) { bm_vertoffs = me->totvert + 1; /* max index array */ - /* bbsel = */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); - edbm_backbuf_check_and_select_verts_obmode(me, select); - EDBM_backbuf_free(); + bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); + if (bbsel) { + edbm_backbuf_check_and_select_verts_obmode(me, select); + EDBM_backbuf_free(); + } } else { CircleSelectUserData data; -- cgit v1.2.3 From be654aab58c6d881ee3db95e542e729da23b0ede Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Sep 2013 08:21:12 +0000 Subject: fix [#36842] OpenGL Animation Playblast renders 1 too many frames --- source/blender/editors/render/render_opengl.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index cdebbf4e103..21074bdc47c 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -517,7 +517,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) return 1; } -static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) +static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); OGLRender *oglrender = op->customdata; @@ -549,12 +549,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, &scene->r.im_format, scene->r.scemode & R_EXTENSION, TRUE); if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) { - printf("skipping existing frame \"%s\"\n", name); - - /* go to next frame */ - oglrender->nfra += scene->r.frame_step; - - return 1; + BKE_reportf(op->reports, RPT_INFO, "Skipping existing frame \"%s\"", name); + ok = true; + goto finally; } } @@ -656,6 +653,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) /* movie stats prints have no line break */ printf("\n"); + +finally: /* Step the frame and bail early if needed */ + /* go to next frame */ oglrender->nfra += scene->r.frame_step; @@ -673,7 +673,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent { OGLRender *oglrender = op->customdata; int anim = RNA_boolean_get(op->ptr, "animation"); - int ret; + bool ret; switch (event->type) { case ESCKEY: @@ -698,11 +698,12 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent screen_opengl_render_end(C, op->customdata); return OPERATOR_FINISHED; } - else + else { ret = screen_opengl_render_anim_step(C, op); + } /* stop at the end or on error */ - if (ret == 0) { + if (ret == false) { return OPERATOR_FINISHED; } @@ -750,7 +751,7 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } else { - int ret = 1; + bool ret = true; if (!screen_opengl_render_anim_initialize(C, op)) return OPERATOR_CANCELLED; -- cgit v1.2.3 From 8064989e7ba076dd978ef4d6befd579791a95307 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Sep 2013 08:43:22 +0000 Subject: fix regression [#36878], missing NULL checks for linestyle. --- source/blender/editors/space_outliner/outliner_tree.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index b86fba1398a..10890a305fb 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -384,17 +384,21 @@ static void outliner_add_line_styles(SpaceOops *soops, ListBase *lb, Scene *sce, for (srl = sce->r.layers.first; srl; srl = srl->next) { for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) { - lineset->linestyle->id.flag |= LIB_DOIT; + FreestyleLineStyle *linestyle = lineset->linestyle; + if (linestyle) { + linestyle->id.flag |= LIB_DOIT; + } } } for (srl = sce->r.layers.first; srl; srl = srl->next) { for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) { FreestyleLineStyle *linestyle = lineset->linestyle; - - if (!(linestyle->id.flag & LIB_DOIT)) - continue; - linestyle->id.flag &= ~LIB_DOIT; - outliner_add_element(soops, lb, linestyle, te, 0, 0); + if (linestyle) { + if (!(linestyle->id.flag & LIB_DOIT)) + continue; + linestyle->id.flag &= ~LIB_DOIT; + outliner_add_element(soops, lb, linestyle, te, 0, 0); + } } } } -- cgit v1.2.3 From 65233bc49e021e0d4609c61242a4005ed0aa133c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Sep 2013 09:04:17 +0000 Subject: revert r36440, own commit, no longer needed because of changes to the keymap. resolves [#36860] sampling color in face select mask --- source/blender/editors/sculpt_paint/paint_image.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index feff02fa121..a32293ab12b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -963,26 +963,6 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -/* same as image_paint_poll but fail when face mask mode is enabled */ -static int image_paint_sample_color_poll(bContext *C) -{ - if (image_paint_poll(C)) { - if (CTX_wm_view3d(C)) { - Object *obact = CTX_data_active_object(C); - if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - Mesh *me = BKE_mesh_from_object(obact); - if (me) { - return !(me->editflag & ME_EDIT_PAINT_FACE_SEL); - } - } - } - - return 1; - } - - return 0; -} - void PAINT_OT_sample_color(wmOperatorType *ot) { /* identifiers */ @@ -994,7 +974,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) ot->exec = sample_color_exec; ot->invoke = sample_color_invoke; ot->modal = sample_color_modal; - ot->poll = image_paint_sample_color_poll; + ot->poll = image_paint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -- cgit v1.2.3 From b6ea073af2d244bcec186b5095dccad6ef972e73 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Sep 2013 09:28:43 +0000 Subject: more fixes relating to [#36878], freestyle was only checking for NULL linestyles in some places. --- source/blender/editors/animation/anim_filter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 041a2c2216e..09b6e7d2206 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1546,7 +1546,9 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data for (srl = sce->r.layers.first; srl; srl = srl->next) { for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) { - lineset->linestyle->id.flag |= LIB_DOIT; + if (lineset->linestyle) { + lineset->linestyle->id.flag |= LIB_DOIT; + } } } @@ -1562,8 +1564,11 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; - if (!(linestyle->id.flag & LIB_DOIT)) + if ((linestyle == NULL) || + !(linestyle->id.flag & LIB_DOIT)) + { continue; + } linestyle->id.flag &= ~LIB_DOIT; /* add scene-level animation channels */ -- cgit v1.2.3 From 169b4e81186279e4ce28ed935b69b811175a2e50 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 30 Sep 2013 09:51:25 +0000 Subject: Fix #36853, Undo not working for Particles Hair - Free Edit. Resetting the particle system without losing edit undo is not so easy. Just added a confirm message for now to warn user about loss of particle edit undo. --- source/blender/editors/physics/particle_edit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 1a561efd217..b0e19d04e35 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4421,7 +4421,7 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSystem *psys = psys_get_current(ob); if (psys->edit) { - if (psys->edit->edited || 1) { // XXX okee("Lose changes done in particle mode?")) + if (psys->edit->edited || 1) { PE_free_ptcache_edit(psys->edit); psys->edit = NULL; @@ -4447,6 +4447,11 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } +static int clear_edited_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + return WM_operator_confirm_message(C, op, "Lose changes done in particle mode? (no undo)"); +} + void PARTICLE_OT_edited_clear(wmOperatorType *ot) { /* identifiers */ @@ -4457,6 +4462,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot) /* api callbacks */ ot->exec = clear_edited_exec; ot->poll = particle_edit_toggle_poll; + ot->invoke = clear_edited_invoke; /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; -- cgit v1.2.3 From 6e7615281642d2efb59f5fdd868c407c2a21f205 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 30 Sep 2013 10:20:54 +0000 Subject: Fix [#36846] Adding a cloth sim to an object does not make it possible to go into Particle Mode for that object. Softbody/cloth were not checked when building available modes enum. --- source/blender/editors/object/object_edit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 96144d13519..bd4c2e997fe 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1471,12 +1471,14 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( ob = CTX_data_active_object(C); if (ob) { + const bool use_mode_particle_edit = (ob->particlesystem.first != NULL) || (ob->soft != NULL) || + (modifiers_findByType(ob, eModifierType_Cloth) != NULL); while (input->identifier) { if ((input->value == OB_MODE_EDIT && OB_TYPE_SUPPORT_EDITMODE(ob->type)) || (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) || - (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) || - ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT || - input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) || + (input->value == OB_MODE_PARTICLE_EDIT && use_mode_particle_edit) || + (ELEM4(input->value, OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, + OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) || (input->value == OB_MODE_OBJECT)) { RNA_enum_item_add(&item, &totitem, input); -- cgit v1.2.3 From 414fadb192f9e32e80828d213093859e0b912783 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 30 Sep 2013 14:33:18 +0000 Subject: changing shortcut to toggle Properties in text editor (ctrl+t) --- source/blender/editors/space_text/space_text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c5e7a47b7a2..c668c8063a8 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -309,7 +309,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "selection", TRUE); } - WM_keymap_add_item(keymap, "TEXT_OT_properties", PKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_CTRL, 0); -- cgit v1.2.3 From aec701721184c711a54632a0849ba9d8386f52d4 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Mon, 30 Sep 2013 16:18:56 +0000 Subject: Fix "Sample Color" not working in vertex paint mode. The issue was discussed at blender.org forum: http://www.blender.org/forum/viewtopic.php?t=28158 --- source/blender/editors/sculpt_paint/paint_image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a32293ab12b..910a49a8f7d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -963,6 +963,11 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } +static int sample_color_poll(bContext *C) +{ + return (image_paint_poll(C) || vertex_paint_poll(C)); +} + void PAINT_OT_sample_color(wmOperatorType *ot) { /* identifiers */ @@ -974,7 +979,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) ot->exec = sample_color_exec; ot->invoke = sample_color_invoke; ot->modal = sample_color_modal; - ot->poll = image_paint_poll; + ot->poll = sample_color_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -- cgit v1.2.3 From 00140a8584d5eb2fbd4697906b67f4f5326caab5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 30 Sep 2013 17:54:35 +0000 Subject: Fix #36892: crash running "Sample Color" operator from 3D viewport when the sequencer contained any data. The sequence color sample operator was available here when it shouldn't be. --- source/blender/editors/space_sequencer/sequencer_view.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index 18733d4e409..deb37f8d943 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -220,7 +220,8 @@ static int sample_cancel(bContext *C, wmOperator *op) static int sample_poll(bContext *C) { - return BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL; + SpaceSeq *sseq = CTX_wm_space_seq(C); + return sseq && BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL; } void SEQUENCER_OT_sample(wmOperatorType *ot) -- cgit v1.2.3 From 3ccb370d38cc66bbcf261e0425077ed0988f4c5e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 30 Sep 2013 19:30:56 +0000 Subject: Usual UI messages fixes... --- source/blender/editors/mesh/editmesh_bisect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 4cfee8cf6f2..5431b1deb1c 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -300,7 +300,7 @@ void MESH_OT_bisect(struct wmOperatorType *ot) /* identifiers */ ot->name = "Bisect"; - ot->description = "Cuts geometry along a plane"; + ot->description = "Cut geometry along a plane"; ot->idname = "MESH_OT_bisect"; /* api callbacks */ -- cgit v1.2.3 From e28bd0d3024f6a21adbc1aa74fa87865ae613046 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 30 Sep 2013 22:53:56 +0000 Subject: * Change NA_EDITED notifier to NA_ADDED, as suggested by Sergey. (r60414 follow up) --- source/blender/editors/space_image/image_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2da109d281b..a7dee3fab93 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1804,7 +1804,7 @@ static int image_new_exec(bContext *C, wmOperator *op) BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE); - WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); + WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); return OPERATOR_FINISHED; } -- cgit v1.2.3 From aaba317c763657d7c309a1c3e96b58f5924afd29 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Mon, 30 Sep 2013 23:02:29 +0000 Subject: Follow-up to r60433 (related to Bug #36878): additional checks for NULL line styles. --- source/blender/editors/render/render_shading.c | 36 ++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 58c244228ed..c19c5a38517 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -860,8 +860,12 @@ static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to"); return OPERATOR_CANCELLED; } - lineset->linestyle->id.us--; - lineset->linestyle = BKE_copy_linestyle(lineset->linestyle); + if (lineset->linestyle) { + lineset->linestyle->id.us--; + lineset->linestyle = BKE_copy_linestyle(lineset->linestyle); + } else { + lineset->linestyle = BKE_new_linestyle("LineStyle", NULL); + } WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); @@ -894,6 +898,10 @@ static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } if (BKE_add_linestyle_color_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type"); return OPERATOR_CANCELLED; @@ -933,6 +941,10 @@ static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } if (BKE_add_linestyle_alpha_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type"); return OPERATOR_CANCELLED; @@ -972,6 +984,10 @@ static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } if (BKE_add_linestyle_thickness_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type"); return OPERATOR_CANCELLED; @@ -1011,6 +1027,10 @@ static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } if (BKE_add_linestyle_geometry_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type"); return OPERATOR_CANCELLED; @@ -1064,6 +1084,10 @@ static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } switch (freestyle_get_modifier_type(&ptr)) { case LS_MODIFIER_TYPE_COLOR: @@ -1114,6 +1138,10 @@ static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } switch (freestyle_get_modifier_type(&ptr)) { case LS_MODIFIER_TYPE_COLOR: @@ -1165,6 +1193,10 @@ static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to"); return OPERATOR_CANCELLED; } + if (!lineset->linestyle) { + BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return OPERATOR_CANCELLED; + } switch (freestyle_get_modifier_type(&ptr)) { case LS_MODIFIER_TYPE_COLOR: -- cgit v1.2.3 From 6067fa682b0c70778f614ab68af20455befe5a76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 02:51:39 +0000 Subject: de-duplicate report strings for freestyle error checks --- source/blender/editors/render/render_shading.c | 67 ++++++++++---------------- 1 file changed, 25 insertions(+), 42 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index c19c5a38517..d04639f95e7 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -588,6 +588,20 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot) #ifdef WITH_FREESTYLE +static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportList *reports) +{ + if (!lineset) { + BKE_report(reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); + return false; + } + if (!lineset->linestyle) { + BKE_report(reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + return false; + } + + return true; +} + static int freestyle_active_module_poll(bContext *C) { PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); @@ -894,14 +908,10 @@ static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op) FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); int type = RNA_enum_get(op->ptr, "type"); - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } + if (BKE_add_linestyle_color_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type"); return OPERATOR_CANCELLED; @@ -937,14 +947,10 @@ static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op) FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); int type = RNA_enum_get(op->ptr, "type"); - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } + if (BKE_add_linestyle_alpha_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type"); return OPERATOR_CANCELLED; @@ -980,14 +986,10 @@ static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op) FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); int type = RNA_enum_get(op->ptr, "type"); - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } + if (BKE_add_linestyle_thickness_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type"); return OPERATOR_CANCELLED; @@ -1023,14 +1025,10 @@ static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op) FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); int type = RNA_enum_get(op->ptr, "type"); - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } + if (BKE_add_linestyle_geometry_modifier(lineset->linestyle, type) == NULL) { BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type"); return OPERATOR_CANCELLED; @@ -1080,12 +1078,7 @@ static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op) PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); LineStyleModifier *modifier = ptr.data; - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } @@ -1134,12 +1127,7 @@ static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op) PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); LineStyleModifier *modifier = ptr.data; - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } @@ -1189,12 +1177,7 @@ static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) LineStyleModifier *modifier = ptr.data; int dir = RNA_enum_get(op->ptr, "direction"); - if (!lineset) { - BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to"); - return OPERATOR_CANCELLED; - } - if (!lineset->linestyle) { - BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)"); + if (!freestyle_linestyle_check_report(lineset, op->reports)) { return OPERATOR_CANCELLED; } -- cgit v1.2.3 From 92527b9264c8cca99282e7d7a2368dbf17aa4605 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 03:56:02 +0000 Subject: remove assert for poly_find_ear(), added recently but its incorrect, also minor style edits. --- source/blender/editors/render/render_shading.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index d04639f95e7..553a543390f 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -877,7 +877,8 @@ static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op) if (lineset->linestyle) { lineset->linestyle->id.us--; lineset->linestyle = BKE_copy_linestyle(lineset->linestyle); - } else { + } + else { lineset->linestyle = BKE_new_linestyle("LineStyle", NULL); } -- cgit v1.2.3 From fe9a64ad6f4a982e2767987372db86ab25ea136f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 05:17:57 +0000 Subject: curve transform: scale handles around their knot when using individual centers. --- source/blender/editors/transform/transform_conversions.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index a4299fe688c..ad31287fa93 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1443,7 +1443,9 @@ static void createTransCurveVerts(TransInfo *t) { copy_v3_v3(td->iloc, bezt->vec[0]); td->loc = bezt->vec[0]; - copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1 : 0]); + copy_v3_v3(td->center, bezt->vec[(hide_handles || + (t->around == V3D_LOCAL) || + (bezt->f2 & SELECT)) ? 1 : 0]); if (hide_handles) { if (bezt->f2 & SELECT) td->flag = TD_SELECTED; else td->flag = 0; @@ -1511,7 +1513,9 @@ static void createTransCurveVerts(TransInfo *t) { copy_v3_v3(td->iloc, bezt->vec[2]); td->loc = bezt->vec[2]; - copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1 : 2]); + copy_v3_v3(td->center, bezt->vec[(hide_handles || + (t->around == V3D_LOCAL) || + (bezt->f2 & SELECT)) ? 1 : 2]); if (hide_handles) { if (bezt->f2 & SELECT) td->flag = TD_SELECTED; else td->flag = 0; -- cgit v1.2.3 From 86b28fc2fccfae34a97d96c76be4d25fe8f9ea6b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 05:39:41 +0000 Subject: addition to r60465, check for individual centers when positioning the manipulator --- source/blender/editors/transform/transform_manipulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 6fecf0d6642..bcc4bb60bb7 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -429,11 +429,11 @@ int calc_manipulator_stats(const bContext *C) } else { if (bezt->f1) { - calc_tw_center(scene, bezt->vec[0]); + calc_tw_center(scene, bezt->vec[(v3d->around == V3D_LOCAL) ? 1 : 0]); totsel++; } if (bezt->f3) { - calc_tw_center(scene, bezt->vec[2]); + calc_tw_center(scene, bezt->vec[(v3d->around == V3D_LOCAL) ? 1 : 2]); totsel++; } } -- cgit v1.2.3 From 9550d05a1c1ab065d73fc1854739a6f0bf500bc2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 07:02:18 +0000 Subject: fix [#36900] single spline handle can't be "scaled" this works in the graph editor but didn't for curves, useful functionality to have. --- source/blender/editors/transform/transform_conversions.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index ad31287fa93..7110e7a66c5 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -123,6 +123,17 @@ #include "transform.h" #include "bmesh.h" +/** + * Transforming around ourselves is no use, fallback to individual origins, + * useful for curve/armatures. + */ +static void transform_around_single_fallback(TransInfo *t) +{ + if (t->total == 1 && ELEM3(t->around, V3D_CENTER, V3D_CENTROID, V3D_ACTIVE)) { + t->around = V3D_LOCAL; + } +} + /* when transforming islands */ struct TransIslandData { float co[3]; @@ -1084,6 +1095,8 @@ static void createTransArmatureVerts(TransInfo *t) if (!t->total) return; + transform_around_single_fallback(t); + copy_m3_m4(mtx, t->obedit->obmat); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); @@ -1408,6 +1421,8 @@ static void createTransCurveVerts(TransInfo *t) else t->total = countsel; t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Curve EditMode)"); + transform_around_single_fallback(t); + copy_m3_m4(mtx, t->obedit->obmat); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); -- cgit v1.2.3 From f1f7648d4ce51b29f17108ff96287de3994d00b0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 08:18:43 +0000 Subject: fix for error setting vector handles to free when both vector handles were selected but not the mid-point. only one of the handles would be changed to the HD_FREE. effected curves and fcurves. --- source/blender/editors/animation/keyframes_edit.c | 2 +- source/blender/editors/space_view3d/view3d_buttons.c | 2 +- source/blender/editors/space_view3d/view3d_snap.c | 2 +- source/blender/editors/transform/transform_conversions.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index decbc351cad..71717284d8e 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -396,7 +396,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) int filter; /* when not in graph view, don't use handles */ SpaceIpo *sipo = (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL; - const short use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : FALSE; + const bool use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : false; /* filter animation data */ filter = ANIMFILTER_DATA_VISIBLE; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 75e7605df6b..eea084b4750 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -682,7 +682,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } BKE_nurb_test2D(nu); - BKE_nurb_handles_test(nu); /* test for bezier too */ + BKE_nurb_handles_test(nu, true); /* test for bezier too */ nu = nu->next; } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 5f988edb950..7c29ab01c24 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -143,7 +143,7 @@ static void special_transvert_update(Object *obedit) } BKE_nurb_test2D(nu); - BKE_nurb_handles_test(nu); /* test for bezier too */ + BKE_nurb_handles_test(nu, true); /* test for bezier too */ nu = nu->next; } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 7110e7a66c5..35896f65668 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1571,7 +1571,7 @@ static void createTransCurveVerts(TransInfo *t) * but for now just don't change handle types */ if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0) { /* sets the handles based on their selection, do this after the data is copied to the TransData */ - BKE_nurb_handles_test(nu); + BKE_nurb_handles_test(nu, !hide_handles); } } else { -- cgit v1.2.3 From aecb76b93e57d48c8607007ff7581e7ed9c7a031 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 08:30:46 +0000 Subject: fix bug with vector handles in the graph editor when transforming 2 selected points of a bezt, the unselected handle wouldn't have its value restored on transform cancel. --- source/blender/editors/transform/transform_conversions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 35896f65668..0231ea73322 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3891,7 +3891,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } /* if handles were not selected, store their selection status */ - if (!(sel1) && !(sel3)) { + if (!(sel1) || !(sel3)) { if (hdata == NULL) hdata = initTransDataCurveHandles(td, bezt); } -- cgit v1.2.3 From 3073a5b1c46b2c607099f9783d043299b224ef3d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 1 Oct 2013 09:17:35 +0000 Subject: Mark some CCG funcrions as inlined This seems to be giving speedup up to 10% in own tests. -- svn merge -r60104:60105 ^/branches/soc-2013-depsgraph_mt --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 3f58795cae4..d710d0c8cb1 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4920,7 +4920,7 @@ int ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) { GridPaintMask *gmask; int level = max_ii(1, mmd->sculptlvl); - int gridsize = ccg_gridsize(level); + int gridsize = BKE_ccg_gridsize(level); int gridarea = gridsize * gridsize; int i, j; -- cgit v1.2.3 From 9b3e3f3e3197cc7f92f74a9f6b095c65bd43fa8f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 12:11:10 +0000 Subject: fix for bug own recent commit [#36904] Snap to Volume is broken with Armature this is infact an older bug which was exposed by the recent change. for now only use the change in behavior for scale/rotation. --- source/blender/editors/transform/transform_conversions.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 0231ea73322..f5a12fed076 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -129,7 +129,10 @@ */ static void transform_around_single_fallback(TransInfo *t) { - if (t->total == 1 && ELEM3(t->around, V3D_CENTER, V3D_CENTROID, V3D_ACTIVE)) { + if ((t->total == 1) && + (ELEM3(t->around, V3D_CENTER, V3D_CENTROID, V3D_ACTIVE)) && + (ELEM3(t->mode, TFM_RESIZE, TFM_ROTATION, TFM_TRACKBALL))) + { t->around = V3D_LOCAL; } } -- cgit v1.2.3 From fd01e728773ebc9369a78dc27c5700394e8fd98b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 12:35:43 +0000 Subject: check SELECT flags for curves (was checking for nonzero which would break if new files use this field for other flags) --- source/blender/editors/space_info/info_stats.c | 6 +++--- source/blender/editors/transform/transform_manipulator.c | 4 ++-- source/blender/editors/transform/transform_snap.c | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index c1cddf092aa..9686c6dfc29 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -194,9 +194,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) a = nu->pntsu; while (a--) { stats->totvert += 3; - if (bezt->f1) stats->totvertsel++; - if (bezt->f2) stats->totvertsel++; - if (bezt->f3) stats->totvertsel++; + if (bezt->f1 & SELECT) stats->totvertsel++; + if (bezt->f2 & SELECT) stats->totvertsel++; + if (bezt->f3 & SELECT) stats->totvertsel++; bezt++; } } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index bcc4bb60bb7..ee9bf486c20 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -428,11 +428,11 @@ int calc_manipulator_stats(const bContext *C) totsel++; } else { - if (bezt->f1) { + if (bezt->f1 & SELECT) { calc_tw_center(scene, bezt->vec[(v3d->around == V3D_LOCAL) ? 1 : 0]); totsel++; } - if (bezt->f3) { + if (bezt->f3 & SELECT) { calc_tw_center(scene, bezt->vec[(v3d->around == V3D_LOCAL) ? 1 : 2]); totsel++; } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 4a208f6eee1..04bccac2a15 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -134,7 +134,8 @@ bool validSnap(TransInfo *t) bool activeSnap(TransInfo *t) { - return (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT; + return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) || + ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT); } void drawSnapping(const struct bContext *C, TransInfo *t) -- cgit v1.2.3 From d44b3f66acd3ffa501e6560391b9f92518b5ef13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 12:37:17 +0000 Subject: make the manipulator work with curve handle selections with normal orientation and individual origins. --- .../editors/transform/transform_orientations.c | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 55d80d63234..cd6a2e6712e 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -728,31 +728,46 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], } } else { + const bool use_handle = (cu->drawflag & CU_HIDE_HANDLES) == 0; + for (nu = nurbs->first; nu; nu = nu->next) { /* only bezier has a normal */ if (nu->type == CU_BEZIER) { bezt = nu->bezt; a = nu->pntsu; while (a--) { + short flag = 0; + +#define SEL_F1 (1 << 0) +#define SEL_F2 (1 << 1) +#define SEL_F3 (1 << 2) + + if (use_handle) { + if (bezt->f1 & SELECT) flag |= SEL_F1; + if (bezt->f2 & SELECT) flag |= SEL_F2; + if (bezt->f3 & SELECT) flag |= SEL_F3; + } + else { + flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0; + } + /* exception */ - if ((bezt->f1 | bezt->f2 | bezt->f3) & SELECT) { + if (flag) { float tvec[3]; - if ((bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT) { + if ((v3d->around == V3D_LOCAL) || + ELEM3(flag, SEL_F2, SEL_F1 | SEL_F3, SEL_F1 | SEL_F2 | SEL_F3)) + { BKE_nurb_bezt_calc_normal(nu, bezt, tvec); add_v3_v3(normal, tvec); } else { - if (bezt->f1 & SELECT) { + /* ignore bezt->f2 in this case */ + if (flag & SEL_F1) { sub_v3_v3v3(tvec, bezt->vec[0], bezt->vec[1]); normalize_v3(tvec); add_v3_v3(normal, tvec); } - if (bezt->f2 & SELECT) { - sub_v3_v3v3(tvec, bezt->vec[0], bezt->vec[2]); - normalize_v3(tvec); - add_v3_v3(normal, tvec); - } - if (bezt->f3 & SELECT) { + if (flag & SEL_F3) { sub_v3_v3v3(tvec, bezt->vec[1], bezt->vec[2]); normalize_v3(tvec); add_v3_v3(normal, tvec); @@ -762,6 +777,11 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], BKE_nurb_bezt_calc_plane(nu, bezt, tvec); add_v3_v3(plane, tvec); } + +#undef SEL_F1 +#undef SEL_F2 +#undef SEL_F3 + bezt++; } } -- cgit v1.2.3 From 4c3d9e358be04b6b2d8979ae9ef59e4b86f3bf13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 12:56:25 +0000 Subject: fix [#36906] AutoName operator do not update the display of the bone's name in the Bone Properties --- source/blender/editors/armature/armature_naming.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 1ee2dc80a97..98128404977 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -294,9 +294,13 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) /* since we renamed stuff... */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + /* copied from #rna_Bone_update_renamed */ + /* redraw view */ + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + + /* update animation channels */ + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, ob->data); + return OPERATOR_FINISHED; } -- cgit v1.2.3 From 9883641f46ebf4a9db407f125903a45ea617464e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 13:28:59 +0000 Subject: add assert for bone renaming, to check if the chanhash is still valid. --- source/blender/editors/armature/armature_naming.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 98128404977..60f5e69621f 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -192,6 +192,8 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n BLI_ghash_insert(gh, pchan->name, pchan); } } + + BLI_assert(BKE_pose_channels_is_valid(ob->pose) == true); } /* Update any object constraints to use the new bone name */ -- cgit v1.2.3 From d8020f54baefc96ccaf7d1c5df49f8e5cd0c6e76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 13:33:43 +0000 Subject: change to ED_armature_bone_rename so theres never any duplicates dictionary items in 'ob->pose->chanhash' this turned out to be harmless but it did make ghash assert() because the ghash isnt flagged to allow duplicates. --- source/blender/editors/armature/armature_naming.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 60f5e69621f..8745d571a28 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -182,13 +182,17 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n if (ob->pose) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname); if (pchan) { + GHash *gh = ob->pose->chanhash; + + /* remove the old hash entry, and replace with the new name */ + if (gh) { + BLI_assert(BLI_ghash_haskey(gh, pchan->name)); + BLI_ghash_remove(gh, pchan->name, NULL, NULL); + } + BLI_strncpy(pchan->name, newname, MAXBONENAME); - - if (ob->pose->chanhash) { - GHash *gh = ob->pose->chanhash; - - /* remove the old hash entry, and replace with the new name */ - BLI_ghash_remove(gh, oldname, NULL, NULL); + + if (gh) { BLI_ghash_insert(gh, pchan->name, pchan); } } -- cgit v1.2.3 From 4c6a6a8fe372a1fa73da51d52bd473dcb5734492 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 1 Oct 2013 15:04:58 +0000 Subject: UV sculpting was missing curve initialization causing crashes. Reported by Sebastian Koenig, thanks! --- source/blender/editors/sculpt_paint/sculpt_uv.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index d630b6478fb..6401842f43e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -45,6 +45,7 @@ #include "BKE_brush.h" #include "BKE_paint.h" +#include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_main.h" #include "BKE_depsgraph.h" @@ -538,6 +539,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm op->customdata = data; + curvemapping_initialize (ts->uvsculpt->paint.brush->curve); + if (data) { int counter = 0, i; ARegion *ar = CTX_wm_region(C); -- cgit v1.2.3 From 5806ffdfd911bad5fd5aa7e8ac0fa86e7c217515 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 1 Oct 2013 15:34:43 +0000 Subject: Fix blender internal viewport render not using color management settings like view, exposure, looks. --- source/blender/editors/render/render_internal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 577d8af0caf..39d6f836815 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1152,7 +1152,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C) /* Try using GLSL display transform. */ if (force_fallback == false) { - if (IMB_colormanagement_setup_glsl_draw(NULL, &scene->display_settings, true, false)) { + if (IMB_colormanagement_setup_glsl_draw(&scene->view_settings, &scene->display_settings, true, false)) { glEnable(GL_BLEND); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glaDrawPixelsTex(rres.xof, rres.yof, rres.rectx, rres.recty, GL_RGBA, GL_FLOAT, @@ -1170,7 +1170,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C) "render_view3d_draw"); IMB_colormanagement_buffer_make_display_space(rres.rectf, display_buffer, rres.rectx, rres.recty, - 4, dither, NULL, &scene->display_settings); + 4, dither, &scene->view_settings, &scene->display_settings); glEnable(GL_BLEND); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); -- cgit v1.2.3 From 1fa59cdf4dcae382904ea06bfdeba19d89a9f0ad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 15:52:29 +0000 Subject: allow knife-project to use sub-pixel length edges. --- source/blender/editors/mesh/editmesh_knife.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index a60b0248644..43cb15e065e 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1546,8 +1546,16 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) knife_project_v2(kcd, v1, s1); knife_project_v2(kcd, v2, s2); - if (len_squared_v2v2(s1, s2) < 1) - return; + if (kcd->is_interactive) { + if (len_squared_v2v2(s1, s2) < 1.0f) { + return; + } + } + else { + if (len_squared_v2v2(s1, s2) < KNIFE_FLT_EPS_SQUARED) { + return; + } + } /* unproject screen line */ ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s1, v1, v3, true); -- cgit v1.2.3 From 4627f9d92cb8c79456ed56aff6cf4a1153f645f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 16:40:11 +0000 Subject: style edits and use macro for prefix check --- source/blender/editors/screen/screendump.c | 4 ++-- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 40447a0106a..dbe1197436b 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -85,7 +85,7 @@ static void screenshot_read_pixels(int x, int y, int w, int h, unsigned char *re glFinish(); /* clear alpha, it is not set to a meaningful value in opengl */ - for (i = 0, rect += 3; i < w*h; i++, rect += 4) + for (i = 0, rect += 3; i < w * h; i++, rect += 4) *rect = 255; } @@ -327,7 +327,7 @@ static void screenshot_updatejob(void *sjv) if (sj->dumprect == NULL) { dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); - screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char*)dumprect); + screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char *)dumprect); sj->dumprect = dumprect; } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 6401842f43e..7a973d8c1ae 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -539,7 +539,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm op->customdata = data; - curvemapping_initialize (ts->uvsculpt->paint.brush->curve); + curvemapping_initialize(ts->uvsculpt->paint.brush->curve); if (data) { int counter = 0, i; -- cgit v1.2.3 From b5fcc340b600c6ef761a01304a3ff6a4b7c30d70 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 1 Oct 2013 17:47:08 +0000 Subject: OSX/keys: change to OSX conform cmd-a for 'select-all' in text(-boxes) --- source/blender/editors/interface/interface_handlers.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 20e03e7dcd5..3ee380fa46b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2228,7 +2228,11 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle case AKEY: /* Ctrl + A: Select all */ +#if !defined(__APPLE__) if (event->ctrl && !(event->alt || event->shift || event->oskey)) { +#else + if (event->oskey && !(event->alt || event->shift || event->ctrl)) { // OSX conformity +#endif ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_ALL); ui_textedit_move(but, data, STRCUR_DIR_NEXT, -- cgit v1.2.3 From bab799bf2504adf2f9f556a36f8c841c381a20ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2013 18:23:39 +0000 Subject: fix regression - convex hull tool leaving new faces unselected. --- source/blender/editors/mesh/editmesh_tools.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index b5262bff850..6cdcc3c0732 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4561,7 +4561,8 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_FACE, BM_ELEM_SELECT, true); + /* Delete unused vertices, edges, and faces */ if (RNA_boolean_get(op->ptr, "delete_unused")) { if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", @@ -4584,9 +4585,11 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Merge adjacent triangles */ if (RNA_boolean_get(op->ptr, "join_triangles")) { - if (!EDBM_op_callf(em, op, "join_triangles faces=%S limit=%f", - &bmop, "geom.out", - RNA_float_get(op->ptr, "limit"))) + if (!EDBM_op_call_and_selectf(em, op, + "faces.out", true, + "join_triangles faces=%S limit=%f", + &bmop, "geom.out", + RNA_float_get(op->ptr, "limit"))) { EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; -- cgit v1.2.3 From 8e70db78f4e1c7c9b99cad709b347b3da92f442e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 2 Oct 2013 12:14:50 +0000 Subject: Bugfix: All actions created when keyframing now have their "id-root" set appropriately This means that it will no longer be possible to accidentally load a nodetree action in the Action Editor (object-level actions only), resulting in F-Curves getting invalidated/disabled. --- source/blender/editors/animation/keyframing.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 70361f00004..b5844b2aab2 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -141,9 +141,18 @@ bAction *verify_adt_action(ID *id, short add) /* init action if none available yet */ /* TODO: need some wizardry to handle NLA stuff correct */ if ((adt->action == NULL) && (add)) { + /* init action name from name of ID block */ char actname[sizeof(id->name) - 2]; BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); + + /* create action */ adt->action = add_empty_action(G.main, actname); + + /* set ID-type from ID-block that this is going to be assigned to + * so that users can't accidentally break actions by assigning them + * to the wrong places + */ + adt->action->idroot = GS(id->name); } /* return the action */ -- cgit v1.2.3 From 4bc998d0b3487732712c44848702fd9eaf2fd11e Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 2 Oct 2013 16:09:09 +0000 Subject: OSX: readd ctrl-a for 'select all' in text(-boxes) against my own conviction for now - really to be discussed --- source/blender/editors/interface/interface_handlers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 3ee380fa46b..2d7a86721d9 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2230,8 +2230,8 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* Ctrl + A: Select all */ #if !defined(__APPLE__) if (event->ctrl && !(event->alt || event->shift || event->oskey)) { -#else - if (event->oskey && !(event->alt || event->shift || event->ctrl)) { // OSX conformity +#else /* OSX uses cmd-a systemwide, so add it */ + if ((event->oskey && !(event->alt || event->shift || event->ctrl)) || (event->ctrl && !(event->alt || event->shift || event->oskey))) { #endif ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_ALL); -- cgit v1.2.3 From 592443816dc5b5473f5092d79dfcdf552023631d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Oct 2013 16:13:24 +0000 Subject: re-shuffle ifdef for osx to make it more clear --- source/blender/editors/interface/interface_handlers.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 2d7a86721d9..dbaa30d01c2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2227,12 +2227,16 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle break; case AKEY: + /* Ctrl + A: Select all */ -#if !defined(__APPLE__) - if (event->ctrl && !(event->alt || event->shift || event->oskey)) { -#else /* OSX uses cmd-a systemwide, so add it */ - if ((event->oskey && !(event->alt || event->shift || event->ctrl)) || (event->ctrl && !(event->alt || event->shift || event->oskey))) { +#if defined(__APPLE__) + /* OSX uses cmd-a systemwide, so add it */ + if ((event->oskey && !(event->alt || event->shift || event->ctrl)) || + (event->ctrl && !(event->alt || event->shift || event->oskey))) +#else + if (event->ctrl && !(event->alt || event->shift || event->oskey)) #endif + { ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_ALL); ui_textedit_move(but, data, STRCUR_DIR_NEXT, -- cgit v1.2.3 From ba01e5e3ebf4d94f8837dff1d263331e1bf412be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Oct 2013 16:37:47 +0000 Subject: fix [#36919] Cannot delete keyframe of animated simulation parameter if simulation has been disabled --- source/blender/editors/animation/keyframing.c | 73 +++++++++++++++++-------- source/blender/editors/space_graph/graph_draw.c | 2 +- 2 files changed, 50 insertions(+), 25 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index b5844b2aab2..6b9200afb75 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -61,6 +61,7 @@ #include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_main.h" +#include "BKE_idcode.h" #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_context.h" @@ -1005,6 +1006,34 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * The flag argument is used for special settings that alter the behavior of * the keyframe deletion. These include the quick refresh options. */ + + + +/** + * \note caller needs to run #BKE_nla_tweakedit_remap to get NLA relative frame. + * caller should also check #BKE_fcurve_is_protected before keying. + */ +static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra) +{ + bool found; + int i; + + /* try to find index of beztriple to get rid of */ + i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found); + if (found) { + /* delete the key at the index (will sanity check + do recalc afterwards) */ + delete_fcurve_key(fcu, i, 1); + + /* Only delete curve too if it won't be doing anything anymore */ + if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) + ANIM_fcurve_delete_from_animdata(NULL, adt, fcu); + + /* return success */ + return true; + } + return false; +} + short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short UNUSED(flag)) { AnimData *adt = BKE_animdata_from_id(id); @@ -1064,32 +1093,20 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { FCurve *fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, 0); - bool found; - int i; - + /* check if F-Curve exists and/or whether it can be edited */ if (fcu == NULL) continue; - - if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { - if (G.debug & G_DEBUG) - printf("WARNING: not deleting keyframe for locked F-Curve\n"); + + if (BKE_fcurve_is_protected(fcu)) { + BKE_reportf(reports, RPT_WARNING, + "not deleting keyframe for locked F-Curve '%s' for %s '%s'", + fcu->rna_path, BKE_idcode_to_name(GS(id->name)), id->name + 2); continue; } - - /* try to find index of beztriple to get rid of */ - i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found); - if (found) { - /* delete the key at the index (will sanity check + do recalc afterwards) */ - delete_fcurve_key(fcu, i, 1); - - /* Only delete curve too if it won't be doing anything anymore */ - if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) - ANIM_fcurve_delete_from_animdata(NULL, adt, fcu); - - /* return success */ - ret++; - } + + ret += delete_keyframe_fcurve(adt, fcu, cfra); + } /* return success/failure */ @@ -1167,7 +1184,7 @@ static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const cha if (fcu == NULL) continue; - if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) { + if (BKE_fcurve_is_protected(fcu)) { if (G.debug & G_DEBUG) printf("WARNING: not deleting keyframe for locked F-Curve\n"); continue; @@ -1546,14 +1563,22 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) AnimData *adt = ob->adt; bAction *act = adt->action; FCurve *fcu, *fcn; + const float cfra_unmap = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); for (fcu = act->curves.first; fcu; fcu = fcn) { fcn = fcu->next; - + + if (BKE_fcurve_is_protected(fcu)) { + BKE_reportf(op->reports, RPT_WARNING, + "not deleting keyframe for locked F-Curve '%s', object '%s'", + fcu->rna_path, id->name + 2); + continue; + } + /* delete keyframes on current frame * WARNING: this can delete the next F-Curve, hence the "fcn" copying */ - success += delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); + success += delete_keyframe_fcurve(adt, fcu, cfra_unmap); } } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 7610f7a9192..23c39a5e99a 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -951,7 +951,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid /* 1) draw curve line */ { /* set color/drawing style for curve itself */ - if (((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || (fcu->flag & FCURVE_PROTECTED)) { + if (BKE_fcurve_is_protected(fcu)) { /* protected curves (non editable) are drawn with dotted lines */ setlinestyle(2); } -- cgit v1.2.3 From a47e6810a28714a840a83262734b109a3ac78747 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 Oct 2013 17:02:59 +0000 Subject: Fixes for cycles Mapping and Vector Transform node: * Keep the Mapping node default type as Point for now, instead of Texture. The latter is a better default, but this is breaking API compatibility and it's too close to release to expect addons to be fixed in time. * Vector Transform and Mapping nodes had properties with name "type" to set the type of vector, but this conflicts with the node type property, so renamed to vector_type now. --- source/blender/editors/space_node/drawnode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 913e48ebb7d..ec5e1ceeb1a 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -709,7 +709,7 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin { uiLayout *row; - uiItemR(layout, ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemL(layout, IFACE_("Location:"), ICON_NONE); row = uiLayoutRow(layout, TRUE); @@ -739,7 +739,7 @@ static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), Po static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE); uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE); } -- cgit v1.2.3 From 8dcbc1060bcf7ee0d58726080405cffd2f3db5d1 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 2 Oct 2013 22:18:14 +0000 Subject: Revert 60358, it made irregularly scaled objects behave incorrectly, checking out different approach here. --- source/blender/editors/sculpt_paint/sculpt.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index d710d0c8cb1..459cf0fd3e9 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1791,6 +1791,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) /* offset with as much as possible factored in already */ mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius); + mul_v3_v3(offset, ss->cache->scale); mul_v3_fl(offset, bstrength); /* threaded loop over nodes */ @@ -1835,6 +1836,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod /* offset with as much as possible factored in already */ mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius); + mul_v3_v3(offset, ss->cache->scale); mul_v3_fl(offset, bstrength); /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ @@ -2263,7 +2265,8 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno if (vd.fno) copy_v3_v3(val, vd.fno); else normal_short_to_float_v3(val, vd.no); - mul_v3_v3fl(proxy[vd.i], val, fade * ss->cache->radius); + mul_v3_fl(val, fade * ss->cache->radius); + mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale); if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; @@ -2642,7 +2645,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno displace = radius * offset; - mul_v3_v3fl(temp, an, displace); + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); add_v3_v3(fc, temp); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) @@ -2711,7 +2715,8 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) displace = radius * (0.25f + offset); - mul_v3_v3fl(temp, an, displace); + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); add_v3_v3(fc, temp); /* add_v3_v3v3(p, ss->cache->location, an); */ @@ -2798,7 +2803,8 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t displace = radius * (0.25f + offset); - mul_v3_v3fl(temp, sn, displace); + mul_v3_v3v3(temp, sn, ss->cache->scale); + mul_v3_fl(temp, displace); add_v3_v3(fc, temp); /* init mat */ @@ -2877,7 +2883,8 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) displace = radius * offset; - mul_v3_v3fl(temp, an, displace); + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); add_v3_v3(fc, temp); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) @@ -2940,7 +2947,8 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod displace = -radius * offset; - mul_v3_v3fl(temp, an, displace); + mul_v3_v3v3(temp, an, ss->cache->scale); + mul_v3_fl(temp, displace); add_v3_v3(fc, temp); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) -- cgit v1.2.3 From 6ff35258c046565589cc5a9d4f3c74a6f13f0388 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 2 Oct 2013 22:46:26 +0000 Subject: real fix for #36695, scale brush stroke with maximum scale component, except layer brush where the previous algorithm is used. --- source/blender/editors/sculpt_paint/sculpt.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 459cf0fd3e9..9b999ce0474 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3801,10 +3801,24 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio ss->cache = cache; /* Set scaling adjustment */ - cache->scale[0] = 1.0f / ob->size[0]; - cache->scale[1] = 1.0f / ob->size[1]; - cache->scale[2] = 1.0f / ob->size[2]; + if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { + cache->scale[0] = 1.0f / ob->size[0]; + cache->scale[1] = 1.0f / ob->size[1]; + cache->scale[2] = 1.0f / ob->size[2]; + } + else { + float max_scale = 0.0f; + + for (i = 0; i < 3; i ++) { + if (fabs(ob->size[i]) > max_scale) + max_scale = fabs(ob->size[i]); + } + + cache->scale[0] = max_scale / ob->size[0]; + cache->scale[1] = max_scale / ob->size[1]; + cache->scale[2] = max_scale / ob->size[2]; + } cache->plane_trim_squared = brush->plane_trim * brush->plane_trim; cache->flag = 0; -- cgit v1.2.3 From 58fe3435b4ab33698c2239aaa8969e234710c00e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Oct 2013 03:05:41 +0000 Subject: adjustments to sculpt cache scaling code, (float/double promotion) --- source/blender/editors/sculpt_paint/sculpt.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9b999ce0474..53357b2616b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3795,30 +3795,27 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio Object *ob = CTX_data_active_object(C); float mat[3][3]; float viewDir[3] = {0.0f, 0.0f, 1.0f}; + float max_scale; int i; int mode; ss->cache = cache; /* Set scaling adjustment */ - if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { - cache->scale[0] = 1.0f / ob->size[0]; - cache->scale[1] = 1.0f / ob->size[1]; - cache->scale[2] = 1.0f / ob->size[2]; + max_scale = 1.0f; } else { - float max_scale = 0.0f; - + max_scale = 0.0f; for (i = 0; i < 3; i ++) { - if (fabs(ob->size[i]) > max_scale) - max_scale = fabs(ob->size[i]); + max_scale = max_ff(max_scale, fabsf(ob->size[i])); } - - cache->scale[0] = max_scale / ob->size[0]; - cache->scale[1] = max_scale / ob->size[1]; - cache->scale[2] = max_scale / ob->size[2]; } + cache->scale[0] = max_scale / ob->size[0]; + cache->scale[1] = max_scale / ob->size[1]; + cache->scale[2] = max_scale / ob->size[2]; + + cache->plane_trim_squared = brush->plane_trim * brush->plane_trim; cache->flag = 0; -- cgit v1.2.3 From 5568b6308713922b6a9371a4608fd899bc5d1fa4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Oct 2013 04:31:41 +0000 Subject: console: shift pad-enter now clears the line too. --- source/blender/editors/space_console/space_console.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 88a04197847..5c8d1e84fd5 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -317,6 +317,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); WM_keymap_add_item(keymap, "CONSOLE_OT_clear_line", RETKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "CONSOLE_OT_clear_line", PADENTER, KM_PRESS, KM_SHIFT, 0); #ifdef WITH_PYTHON kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From f3e41046fe171175f4cb754d5e1b3161ae1adc8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Oct 2013 07:01:32 +0000 Subject: fix bug in ED_vgroup_subset_from_select_type, setting negative index in boolean array. also was freeing NULL pointer in vgroup_blend_subset() --- source/blender/editors/object/object_vgroup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 917f816d6b1..82454baae78 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1480,7 +1480,7 @@ bool *ED_vgroup_subset_from_select_type(Object *ob, eVGroupSelect subset_type, i const int def_nr_active = ob->actdef - 1; vgroup_validmap = MEM_mallocN(*r_vgroup_tot * sizeof(*vgroup_validmap), __func__); memset(vgroup_validmap, false, *r_vgroup_tot * sizeof(*vgroup_validmap)); - if (def_nr_active < *r_vgroup_tot) { + if ((def_nr_active >= 0) && (def_nr_active < *r_vgroup_tot)) { *r_subset_count = 1; vgroup_validmap[def_nr_active] = true; } @@ -2262,7 +2262,8 @@ static void vgroup_blend_subset(Object *ob, const bool *vgroup_validmap, const i MEM_freeN(emap_mem); } - MEM_freeN(dvert_array); + if (dvert_array) + MEM_freeN(dvert_array); BLI_SMALLSTACK_FREE(dv_stack); /* not so efficient to get 'dvert_array' again just so unselected verts are NULL'd */ @@ -2270,7 +2271,8 @@ static void vgroup_blend_subset(Object *ob, const bool *vgroup_validmap, const i ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, true); ED_vgroup_parray_mirror_sync(ob, dvert_array, dvert_tot, vgroup_validmap, vgroup_tot); - MEM_freeN(dvert_array); + if (dvert_array) + MEM_freeN(dvert_array); } } -- cgit v1.2.3 From 4cb4dc8432922413e40e0b8b93dc06e5710693de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Oct 2013 07:02:52 +0000 Subject: remove assert recently added to EDBM_backbuf_check and explain odd logic. --- source/blender/editors/mesh/editmesh_select.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 76c08433b25..85b0cbbc318 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -266,8 +266,11 @@ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xma int EDBM_backbuf_check(unsigned int index) { - BLI_assert(selbuf != NULL); + /* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled + * and just ignore the depth buffer, this is error prone since its possible + * code doesn't set the depth buffer by accident, but leave for now. - Campbell */ if (selbuf == NULL) return 1; + if (index > 0 && index <= bm_vertoffs) return selbuf[index]; return 0; -- cgit v1.2.3 From c819fd4ee0b935dd88f2b516c4d49332af447f03 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Thu, 3 Oct 2013 14:24:54 +0000 Subject: Changed some labels from Second Life to OpenSim --- source/blender/editors/io/io_collada.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 70fa97bebc1..f50e4400b91 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -96,7 +96,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) int use_object_instantiation; int sort_by_name; int export_transformation_type; - int second_life; + int open_sim; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -142,7 +142,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); export_transformation_type = RNA_enum_get(op->ptr, "export_transformation_type_selection"); - second_life = RNA_boolean_get(op->ptr, "second_life"); + open_sim = RNA_boolean_get(op->ptr, "open_sim"); /* get editmode results */ ED_object_editmode_load(CTX_data_edit_object(C)); @@ -168,7 +168,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) use_object_instantiation, sort_by_name, export_transformation_type, - second_life)) + open_sim)) { return OPERATOR_FINISHED; } @@ -236,7 +236,7 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, FALSE); - uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); + uiItemR(row, imfptr, "open_sim", 0, NULL, ICON_NONE); /* Collada options: */ box = uiLayoutBox(layout); @@ -350,8 +350,8 @@ void WM_OT_collada_export(wmOperatorType *ot) RNA_def_enum(ot->srna, "export_transformation_type_selection", prop_bc_export_transformation_type, 0, "Transform", "Transformation type for translation, scale and rotation"); - RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", - "Compatibility mode for Second Life"); + RNA_def_boolean(ot->srna, "open_sim", 0, "Export for OpenSim", + "Compatibility mode for OpenSim and compatible online worlds"); } -- cgit v1.2.3 From f9afdac2a356215e56bb210e975aae531c7c7f92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2013 01:10:23 +0000 Subject: fix [#36942] unfreed memory on trackball widget use --- source/blender/editors/transform/transform_manipulator.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index ee9bf486c20..f667a98812b 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1858,11 +1858,12 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op) * See [#34621], it's a miracle it did not cause more problems!!! */ /* However, we need to copy the "release_confirm" property... */ PointerRNA props_ptr; - WM_operator_properties_create(&props_ptr, "TRANSFORM_OT_trackball"); + wmOperatorType *ot = WM_operatortype_find("TRANSFORM_OT_trackball", true); + WM_operator_properties_create_ptr(&props_ptr, ot); RNA_boolean_set(&props_ptr, "release_confirm", RNA_boolean_get(op->ptr, "release_confirm")); - - WM_operator_name_call(C, "TRANSFORM_OT_trackball", WM_OP_INVOKE_DEFAULT, &props_ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, NULL, NULL, FALSE); + WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, &props_ptr); + //wm_operator_invoke(C, WM_operatortype_find(ot->idname, 0), event, NULL, NULL, FALSE); + WM_operator_properties_free(&props_ptr); } else if (drawflags & MAN_ROT_C) { switch (drawflags) { -- cgit v1.2.3 From ac606a704702af5719cc6c5b62de028d30036769 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2013 05:53:02 +0000 Subject: fix [#36947] "Edge Slide" bugs when "Even" is on was doing a linear interpolation between points on either side instead of interpolating along the edges. --- source/blender/editors/transform/transform.c | 43 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 87ef3d6742a..ce2f07f1813 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4804,6 +4804,26 @@ static BMEdge *get_other_edge(BMVert *v, BMEdge *e) return NULL; } +/* interpoaltes along a line made up of 2 segments (used for edge slide) */ +static void interp_line_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float t) +{ + float t_mid, t_delta; + + /* could be pre-calculated */ + t_mid = line_point_factor_v3(v2, v1, v3); + + t_delta = t - t_mid; + if (fabsf(t_delta) < FLT_EPSILON) { + copy_v3_v3(p, v2); + } + else if (t_delta < 0.0f) { + interp_v3_v3v3(p, v1, v2, t / t_mid); + } + else { + interp_v3_v3v3(p, v2, v3, (t - t_mid) / (1.0f - t_mid)); + } +} + static void len_v3_ensure(float v[3], const float length) { normalize_v3(v); @@ -5716,20 +5736,16 @@ static void drawEdgeSlide(const struct bContext *C, TransInfo *t) /* Non-Prop mode */ if (sld && sld->is_proportional == FALSE) { View3D *v3d = CTX_wm_view3d(C); - float marker[3]; - float v1[3], v2[3]; - float interp_v; + float co_a[3], co_b[3], co_mark[3]; TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; + const float fac = (sld->perc + 1.0f) / 2.0f; const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; const float guide_size = ctrl_size - 0.5f; const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; const int alpha_shade = -30; - add_v3_v3v3(v1, curr_sv->v_co_orig, curr_sv->dir_a); - add_v3_v3v3(v2, curr_sv->v_co_orig, curr_sv->dir_b); - - interp_v = (sld->perc + 1.0f) / 2.0f; - interp_v3_v3v3(marker, v2, v1, interp_v); + add_v3_v3v3(co_a, curr_sv->v_co_orig, curr_sv->dir_a); + add_v3_v3v3(co_b, curr_sv->v_co_orig, curr_sv->dir_b); if (v3d && v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -5770,7 +5786,12 @@ static void drawEdgeSlide(const struct bContext *C, TransInfo *t) UI_ThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); glPointSize(guide_size); bglBegin(GL_POINTS); - bglVertex3fv(marker); +#if 0 + interp_v3_v3v3(co_mark, co_b, co_a, fac); + bglVertex3fv(co_mark); +#endif + interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); + bglVertex3fv(co_mark); bglEnd(); @@ -5832,10 +5853,10 @@ static int doEdgeSlide(TransInfo *t, float perc) add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_b); if (sld->flipped_vtx) { - interp_v3_v3v3(sv->v->co, co_b, co_a, fac); + interp_line_v3_v3v3v3(sv->v->co, co_b, sv->v_co_orig, co_a, fac); } else { - interp_v3_v3v3(sv->v->co, co_a, co_b, fac); + interp_line_v3_v3v3v3(sv->v->co, co_a, sv->v_co_orig, co_b, fac); } } } -- cgit v1.2.3 From ec4a7fcad12ba8106531ab02c5bc1cce213cfb86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2013 10:48:24 +0000 Subject: fix for lasso selection (in non-zbuf mode) when the line intersected its self. isect_point_poly_v2() - add argument to check overlapping areas. --- source/blender/editors/mesh/editmesh_knife.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 43cb15e065e..5e88ecabd35 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -3525,7 +3525,7 @@ static bool edbm_mesh_knife_face_isect(ARegion *ar, LinkNode *polys, BMFace *f, while (p) { const float (*mval_fl)[2] = p->link; const int mval_tot = MEM_allocN_len(mval_fl) / sizeof(*mval_fl); - isect += (int)isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1); + isect += (int)isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1, false); p = p->next; } -- cgit v1.2.3 From 865fe764dc4d027ad80f03b30a6f741f46c3d675 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 Oct 2013 12:22:54 +0000 Subject: Code cleanup: remove unused function --- source/blender/editors/include/BIF_glutil.h | 3 -- source/blender/editors/screen/glutil.c | 54 ----------------------------- 2 files changed, 57 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 352a74cf172..dd1995a5428 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -221,8 +221,5 @@ void glaDrawImBuf_glsl(struct ImBuf *ibuf, float x, float y, int zoomfilter, /* Draw imbuf on a screen, preferably using GLSL display transform */ void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter); -/* Transform buffer from role to scene linear space using GLSL OCIO conversion */ -int glaBufferTransformFromRole_glsl(float *buffer, int width, int height, int role); - #endif /* __BIF_GLUTIL_H__ */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 13befeceee9..70e5aab6628 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -1160,57 +1160,3 @@ void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int glaDrawImBuf_glsl(ibuf, x, y, zoomfilter, view_settings, display_settings); } - -/* Transform buffer from role to scene linear space using GLSL OCIO conversion - * - * See IMB_colormanagement_setup_transform_from_role_glsl description for - * some more details - * - * NOTE: this only works for RGBA buffers! - */ -int glaBufferTransformFromRole_glsl(float *buffer, int width, int height, int role) -{ - GPUOffScreen *ofs; - char err_out[256]; - rcti display_rect; - - ofs = GPU_offscreen_create(width, height, err_out); - - if (!ofs) - return FALSE; - - GPU_offscreen_bind(ofs); - - if (!IMB_colormanagement_setup_transform_from_role_glsl(role, true)) { - GPU_offscreen_unbind(ofs); - GPU_offscreen_free(ofs); - return FALSE; - } - - BLI_rcti_init(&display_rect, 0, width, 0, height); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - - glaDefine2DArea(&display_rect); - - glaDrawPixelsTex(0, 0, width, height, GL_RGBA, GL_FLOAT, - GL_NEAREST, buffer); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - GPU_offscreen_read_pixels(ofs, GL_FLOAT, buffer); - - IMB_colormanagement_finish_glsl_transform(); - - /* unbind */ - GPU_offscreen_unbind(ofs); - GPU_offscreen_free(ofs); - - return TRUE; -} -- cgit v1.2.3 From 8cdeba8d67a4af89d57bec21b313817311e65883 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 Oct 2013 12:30:00 +0000 Subject: Fix #36948: blender internal viewport render crashes holding shift+Z pressed to quickly toggle it on/off. Problem is accessing freed data, now the job is ended immediately. Fix based on patch from Sergey and investigation from Bastien. --- source/blender/editors/include/ED_render.h | 2 ++ source/blender/editors/include/ED_view3d.h | 3 +++ source/blender/editors/space_view3d/space_view3d.c | 20 ++++++++++++++++++++ source/blender/editors/space_view3d/view3d_view.c | 11 +++-------- 4 files changed, 28 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index bdfbbbb9c74..518bee665ae 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -40,6 +40,7 @@ struct Scene; struct ScrArea; struct RegionView3D; struct RenderEngine; +struct View3D; /* render_ops.c */ @@ -51,6 +52,7 @@ void ED_render_id_flush_update(struct Main *bmain, struct ID *id); void ED_render_engine_changed(struct Main *bmain); void ED_render_engine_area_exit(struct ScrArea *sa); void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated); +void ED_render_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index ce9d3af3013..86abf29c308 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -336,4 +336,7 @@ void ED_view3d_operator_properties_viewmat_set(struct bContext *C, struct wmOper void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, int *winx, int *winy, float persmat[4][4]); #endif +/* render */ +void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); + #endif /* __ED_VIEW3D_H__ */ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 6c61c2af816..58c0df6b6bd 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_icons.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_screen.h" @@ -258,6 +259,25 @@ void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d) } #endif +void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) +{ + wmWindowManager *wm = bmain->wm.first; + + if (v3d->drawtype != OB_RENDER) { + ARegion *ar; + + for (ar = sa->regionbase.first; ar; ar = ar->next) { + RegionView3D *rv3d = ar->regiondata; + + if (rv3d && rv3d->render_engine) { + WM_jobs_kill_type(wm, ar, WM_JOB_TYPE_RENDER_PREVIEW); + RE_engine_free(rv3d->render_engine); + rv3d->render_engine = NULL; + } + } + } +} + /* ******************** default callbacks for view3d space ***************** */ static SpaceLink *view3d_new(const bContext *C) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 388d83d3208..74d72061995 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1180,7 +1180,7 @@ static bool view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, Report return ok; } -static void restore_localviewdata(ScrArea *sa, int free) +static void restore_localviewdata(Main *bmain, ScrArea *sa, int free) { ARegion *ar; View3D *v3d = sa->spacedata.first; @@ -1217,12 +1217,7 @@ static void restore_localviewdata(ScrArea *sa, int free) } } - if (v3d->drawtype != OB_RENDER) { - if (rv3d->render_engine) { - RE_engine_free(rv3d->render_engine); - rv3d->render_engine = NULL; - } - } + ED_view3d_shade_update(bmain, v3d, sa); } } } @@ -1237,7 +1232,7 @@ static bool view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) locallay = v3d->lay & 0xFF000000; - restore_localviewdata(sa, 1); /* 1 = free */ + restore_localviewdata(bmain, sa, 1); /* 1 = free */ /* for when in other window the layers have changed */ if (v3d->scenelock) v3d->lay = scene->lay; -- cgit v1.2.3 From 5dc9db3533e720f09c9a66e9489056ae00e1c394 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2013 15:02:05 +0000 Subject: fix for lasso failing/glitches on overlapping lines, replace scanfill with 2d pixel filling for drawing and selection. --- source/blender/editors/mesh/editmesh_select.c | 108 ++++++-------------------- 1 file changed, 25 insertions(+), 83 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 85b0cbbc318..4d512fab1c0 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -186,53 +186,6 @@ unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0; /* set in dr /* facilities for border select and circle select */ static char *selbuf = NULL; -/* opengl doesn't support concave... */ -static void draw_triangulated(const int mcords[][2], const short tot) -{ - ListBase lb = {NULL, NULL}; - DispList *dl; - float *fp; - int a; - const float z_up[3] = {0.0f, 0.0f, 1.0f}; - - /* make displist */ - dl = MEM_callocN(sizeof(DispList), "poly disp"); - dl->type = DL_POLY; - dl->parts = 1; - dl->nr = tot; - dl->verts = fp = MEM_callocN(tot * 3 * sizeof(float), "poly verts"); - BLI_addtail(&lb, dl); - - for (a = 0; a < tot; a++, fp += 3) { - fp[0] = (float)mcords[a][0]; - fp[1] = (float)mcords[a][1]; - } - - /* do the fill */ - BKE_displist_fill(&lb, &lb, z_up, false); - - /* do the draw */ - dl = lb.first; /* filldisplist adds in head of list */ - if (dl->type == DL_INDEX3) { - int *index; - - a = dl->parts; - fp = dl->verts; - index = dl->index; - glBegin(GL_TRIANGLES); - while (a--) { - glVertex3fv(fp + 3 * index[0]); - glVertex3fv(fp + 3 * index[1]); - glVertex3fv(fp + 3 * index[2]); - index += 3; - } - glEnd(); - } - - BKE_displist_free(&lb); -} - - /* reads rect, and builds selection array for quick lookup */ /* returns if all is OK */ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xmax, short ymax) @@ -282,6 +235,18 @@ void EDBM_backbuf_free(void) selbuf = NULL; } +struct LassoMaskData { + unsigned int *px; + int width; +}; + +static void edbm_mask_lasso_px_cb(int x, int y, void *user_data) +{ + struct LassoMaskData *data = user_data; + data->px[(y * data->width) + x] = true; +} + + /* mcords is a polygon mask * - grab backbuffer, * - draw with black in backbuffer, @@ -290,9 +255,10 @@ void EDBM_backbuf_free(void) */ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) { - unsigned int *dr, *drm; - struct ImBuf *buf, *bufmask; + unsigned int *dr, *dr_mask, *dr_mask_arr; + struct ImBuf *buf; int a; + struct LassoMaskData lasso_mask_data; /* method in use for face selecting too */ if (vc->obedit == NULL) { @@ -310,49 +276,25 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short dr = buf->rect; - if (vc->rv3d->gpuoffscreen) - GPU_offscreen_bind(vc->rv3d->gpuoffscreen); - - /* draw the mask */ - glDisable(GL_DEPTH_TEST); - - glColor3ub(0, 0, 0); - - /* yah, opengl doesn't do concave... tsk! */ - ED_region_pixelspace(vc->ar); - draw_triangulated(mcords, tot); - - glBegin(GL_LINE_LOOP); /* for zero sized masks, lines */ - for (a = 0; a < tot; a++) { - glVertex2iv(mcords[a]); - } - glEnd(); - - glFinish(); /* to be sure readpixels sees mask */ - - if (vc->rv3d->gpuoffscreen) - GPU_offscreen_unbind(vc->rv3d->gpuoffscreen); - - /* grab mask */ - bufmask = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); + dr_mask = dr_mask_arr = MEM_callocN(sizeof(*dr_mask) * buf->x * buf->y, __func__); + lasso_mask_data.px = dr_mask; + lasso_mask_data.width = (xmax - xmin) + 1; - if (bufmask == NULL) { - return false; /* only when mem alloc fails, go crash somewhere else! */ - } - else { - drm = bufmask->rect; - } + fill_poly_v2i_n( + xmin, ymin, xmax + 1, ymax + 1, + mcords, tot, + edbm_mask_lasso_px_cb, &lasso_mask_data); /* build selection lookup */ selbuf = MEM_callocN(bm_vertoffs + 1, "selbuf"); a = (xmax - xmin + 1) * (ymax - ymin + 1); while (a--) { - if (*dr > 0 && *dr <= bm_vertoffs && *drm == 0) selbuf[*dr] = 1; - dr++; drm++; + if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) selbuf[*dr] = 1; + dr++; dr_mask++; } IMB_freeImBuf(buf); - IMB_freeImBuf(bufmask); + MEM_freeN(dr_mask_arr); return true; } -- cgit v1.2.3 From 0b1cf4c2ea2cf009e1991c8d258603538621aeeb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2013 17:47:58 +0000 Subject: code cleanup: warnings and minor edits. --- source/blender/editors/mesh/editmesh_tools.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 6cdcc3c0732..fa65fb88315 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -983,12 +983,6 @@ void MESH_OT_flip_normals(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static const EnumPropertyItem direction_items[] = { - {false, "CW", 0, "Clockwise", ""}, - {true, "CCW", 0, "Counter Clockwise", ""}, - {0, NULL, 0, NULL, NULL} -}; - /* only accepts 1 selected edge, or 2 selected faces */ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) { -- cgit v1.2.3 From 7a9bc838de58c306afc33c7d0dd158af655817e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2013 18:34:28 +0000 Subject: pressing enter over a file-text button is ignored (so enter in the file selector works again). --- source/blender/editors/interface/interface_handlers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index dbaa30d01c2..cdce651c860 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2621,7 +2621,10 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) { - if (but->dt == UI_EMBOSSN && !event->ctrl) { + if (ELEM(event->type, PADENTER, RETKEY) && (!ui_is_but_utf8(but))) { + /* pass - allow filesel, enter to execute */ + } + else if (but->dt == UI_EMBOSSN && !event->ctrl) { /* pass */ } else { -- cgit v1.2.3 From 1f53674bb8d34c3fff836e064679d5e845eaff4b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Oct 2013 11:59:15 +0000 Subject: avoid divide by zero with grid fill (when there is no selection) --- source/blender/editors/mesh/editmesh_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index fa65fb88315..9e5782c12f2 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3002,7 +3002,7 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op) } offset = RNA_property_int_get(op->ptr, prop_offset); - offset = mod_i(offset, clamp); + offset = clamp ? mod_i(offset, clamp) : 0; /* in simple cases, move selection for tags, but also support more advanced cases */ edbm_fill_grid_prepare(em->bm, offset, &span, calc_span); -- cgit v1.2.3 From 46a1d921f10445da80c9a2398cfe57d0f4553533 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sun, 6 Oct 2013 10:28:09 +0000 Subject: Fix for Output File node operators: added a sanity type check to avoid using invalid node data. Reported by Sebastian Koenig in unrelated bug report #36968. --- source/blender/editors/space_node/node_edit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index ff6a8e884a6..bc0a518b1b0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1731,7 +1731,7 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op) node = nodeGetActive(snode->edittree); } - if (!node) + if (!node || node->type != CMP_NODE_OUTPUT_FILE) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "file_path", file_path); @@ -1777,7 +1777,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U node = nodeGetActive(snode->edittree); } - if (!node) + if (!node || node->type != CMP_NODE_OUTPUT_FILE) return OPERATOR_CANCELLED; if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) @@ -1819,7 +1819,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) else if (snode && snode->edittree) node = nodeGetActive(snode->edittree); - if (!node) + if (!node || node->type != CMP_NODE_OUTPUT_FILE) return OPERATOR_CANCELLED; nimf = node->storage; -- cgit v1.2.3 From 31db661e1dfeed299f194c7d3fe39a84d28e38e2 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 6 Oct 2013 12:22:30 +0000 Subject: * Display warning icon for SSS/GPU message. --- source/blender/editors/space_node/drawnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ec5e1ceeb1a..a767fb4d3f3 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -920,7 +920,7 @@ static void node_shader_buts_subsurface(uiLayout *layout, bContext *C, PointerRN if (scene.data) { PointerRNA cscene = RNA_pointer_get(&scene, "cycles"); if (cscene.data && RNA_enum_get(&cscene, "device") == 1) - uiItemL(layout, IFACE_("SSS not supported on GPU"), ICON_NONE); + uiItemL(layout, IFACE_("SSS not supported on GPU"), ICON_ERROR); } uiItemR(layout, ptr, "falloff", 0, "", ICON_NONE); -- cgit v1.2.3 From ca152da25885c4760efb71657aa3f769fdf1e23d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 Oct 2013 07:53:36 +0000 Subject: Remove unused and meaningless line. --- source/blender/editors/space_image/image_draw.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 23c85699b00..b64ece99b0f 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -268,8 +268,6 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def else rgba[3] = linearcol[3]; - (void)color_manage; - if (use_default_view) IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings); else -- cgit v1.2.3 From 51a7089bea11db9118ce6251ff0645bf5f69a184 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 Oct 2013 08:06:19 +0000 Subject: Fix #36980: Color space issue when displaying pixel color in a render HSV values were calculated from a linear space color, which is not so much useful and correct. Now RGB(A) buffers will use color managed color for HSV values. Still not sure which color to use for HSV when there's only one channel in a buffer. This part left unchanged for now. --- source/blender/editors/space_image/image_draw.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index b64ece99b0f..89e57955339 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -358,14 +358,8 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def dx += BLF_width(blf_mono_font, str); } else if (channels >= 3) { - if (fp) { - rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val); - rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v); - } - else if (cp) { - rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[1] / 255.0f, (float)cp[2] / 255.0f, &hue, &sat, &val); - rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[1] / 255.0f, (float)cp[2] / 255.0f, &lum, &u, &v); - } + rgb_to_hsv(finalcol[0], finalcol[1], finalcol[2], &hue, &sat, &val); + rgb_to_yuv(finalcol[0], finalcol[1], finalcol[2], &lum, &u, &v); BLI_snprintf(str, sizeof(str), "H:%-.4f", hue); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); -- cgit v1.2.3 From 31433a380982cfa15adb04b5483981f00a1c6b22 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 7 Oct 2013 09:25:39 +0000 Subject: Fix #36981, Removing Sample line fails during render. The SAMPLELINE flag in histogram was set during the BKE_histogram_update_sample_line function. That function in turn is called during every scope update in area draw function, meaning that during render it constantly gets set. OTOH the operator tries to disable the flag on invoke, which "cancels" the sample line by default. So during render the operator un-setting of the flag has no effect, because the render job immediatly triggers a redraw, which updates scopes and sets it again. Moved the flag out of the actual sample line update function into the operator execute. Now only the operator enables/disables overall sample line drawing, while the rest of the update works as before. --- source/blender/editors/space_image/image_ops.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index a7dee3fab93..710d5c8cd81 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2417,6 +2417,9 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) hist->co[1][0] = x2f; hist->co[1][1] = y2f; + /* enable line drawing */ + hist->flag |= HISTO_FLAG_SAMPLELINE; + BKE_histogram_update_sample_line(hist, ibuf, &scene->view_settings, &scene->display_settings); /* reset y zoom */ -- cgit v1.2.3 From 13a21588ae8289b30b4091d8c5921937ec6416c9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 10:52:33 +0000 Subject: rename UI_OT_eyedropper to UI_OT_eyedropper_color to make way for other kinds of eyedroppers. --- source/blender/editors/interface/interface_ops.c | 6 +++--- source/blender/editors/interface/interface_regions.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index d52702c2d51..c94267753bb 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -326,11 +326,11 @@ static int eyedropper_poll(bContext *C) else return 1; } -static void UI_OT_eyedropper(wmOperatorType *ot) +static void UI_OT_eyedropper_color(wmOperatorType *ot) { /* identifiers */ ot->name = "Eyedropper"; - ot->idname = "UI_OT_eyedropper"; + ot->idname = "UI_OT_eyedropper_color"; ot->description = "Sample a color from the Blender Window to store in a property"; /* api callbacks */ @@ -1114,7 +1114,7 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot) void UI_buttons_operatortypes(void) { - WM_operatortype_append(UI_OT_eyedropper); + WM_operatortype_append(UI_OT_eyedropper_color); WM_operatortype_append(UI_OT_reset_default_theme); WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_reset_default_button); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 35741618211..15fbd51c6fc 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2185,7 +2185,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper yco = -3.0f * UI_UNIT_Y; if (show_picker) { - bt = uiDefIconButO(block, BUT, "UI_OT_eyedropper", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, butwidth + 10, yco, UI_UNIT_X, UI_UNIT_Y, NULL); + bt = uiDefIconButO(block, BUT, "UI_OT_eyedropper_color", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, butwidth + 10, yco, UI_UNIT_X, UI_UNIT_Y, NULL); uiButSetFunc(bt, close_popup_cb, bt, NULL); } -- cgit v1.2.3 From eb51bfcfca4c963afcc7788882d383a598bf16b2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 11:23:14 +0000 Subject: uiSetRoundBox still took hard coded numbers in places. --- source/blender/editors/interface/interface_draw.c | 6 +++--- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_node/node_draw.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index cd845da10c6..11062ea2bd2 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1389,7 +1389,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if (scopes->track_disabled) { glColor4f(0.7f, 0.3f, 0.3f, 0.3f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f); ok = 1; @@ -1437,7 +1437,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if (scopes->use_track_mask) { glColor4f(0.0f, 0.0f, 0.0f, 0.3f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f); } @@ -1478,7 +1478,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if (!ok) { glColor4f(0.f, 0.f, 0.f, 0.3f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index a767fb4d3f3..f562212f1e2 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -571,7 +571,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED( */ #if 0 /* body */ - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); UI_ThemeColor4(TH_NODE); glEnable(GL_BLEND); uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 29f796aecb1..b991a2c3b5f 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1241,7 +1241,7 @@ static void draw_group_overlay(const bContext *C, ARegion *ar) /* shade node groups to separate them visually */ UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); glEnable(GL_BLEND); - uiSetRoundBox(0); + uiSetRoundBox(UI_CNR_NONE); uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0); glDisable(GL_BLEND); -- cgit v1.2.3 From 7e5d5e61ae41ad775c8d5023565c8bb6db5f63bd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 13:10:22 +0000 Subject: avoid allocating a dummy string for the unlink button. --- source/blender/editors/interface/interface_handlers.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index cdce651c860..57f28a8540f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2658,13 +2658,8 @@ static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHa BLI_rcti_rctf_copy(&rect, &but->rect); rect.xmin = rect.xmax - (BLI_rcti_size_y(&rect)); - if ( BLI_rcti_isect_pt(&rect, x, y) ) { - /* most likely NULL, but let's check, and give it temp zero string */ - if (data->str == NULL) - data->str = MEM_callocN(16, "temp str"); - data->str[0] = 0; - - ui_apply_but_TEX(C, but, data); + if (BLI_rcti_isect_pt(&rect, x, y)) { + ui_set_but_string(C, but, ""); button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; -- cgit v1.2.3 From 2101237227c2a09c653680ef4c7c112c50c37407 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 13:16:14 +0000 Subject: make bookmake name consistent was: FILE_OT_bookmark_add/FILE_OT_delete_bookmark --- source/blender/editors/space_file/file_intern.h | 2 +- source/blender/editors/space_file/file_ops.c | 4 ++-- source/blender/editors/space_file/file_panels.c | 2 +- source/blender/editors/space_file/space_file.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 240106d37d5..d01286442be 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -65,7 +65,7 @@ void FILE_OT_select_all_toggle(struct wmOperatorType *ot); void FILE_OT_select_border(struct wmOperatorType *ot); void FILE_OT_select_bookmark(struct wmOperatorType *ot); void FILE_OT_bookmark_add(struct wmOperatorType *ot); -void FILE_OT_delete_bookmark(struct wmOperatorType *ot); +void FILE_OT_bookmark_delete(struct wmOperatorType *ot); void FILE_OT_reset_recent(wmOperatorType *ot); void FILE_OT_hidedot(struct wmOperatorType *ot); void FILE_OT_execute(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index e3270d9ce8e..a97b3b1d719 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -503,14 +503,14 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void FILE_OT_delete_bookmark(wmOperatorType *ot) +void FILE_OT_bookmark_delete(wmOperatorType *ot) { PropertyRNA *prop; /* identifiers */ ot->name = "Delete Bookmark"; ot->description = "Delete selected bookmark"; - ot->idname = "FILE_OT_delete_bookmark"; + ot->idname = "FILE_OT_bookmark_delete"; /* api callbacks */ ot->exec = bookmark_delete_exec; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 0efc7b927a9..f4161c7da1c 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -121,7 +121,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* create delete button */ if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { uiBlockSetEmboss(block, UI_EMBOSSN); - uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i); + uiItemIntO(layout, "", ICON_X, "FILE_OT_bookmark_delete", "index", i); uiBlockSetEmboss(block, UI_EMBOSS); } } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 9758e2e9135..1a8565a58b1 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -387,7 +387,7 @@ static void file_operatortypes(void) WM_operatortype_append(FILE_OT_refresh); WM_operatortype_append(FILE_OT_bookmark_toggle); WM_operatortype_append(FILE_OT_bookmark_add); - WM_operatortype_append(FILE_OT_delete_bookmark); + WM_operatortype_append(FILE_OT_bookmark_delete); WM_operatortype_append(FILE_OT_reset_recent); WM_operatortype_append(FILE_OT_hidedot); WM_operatortype_append(FILE_OT_filenum); -- cgit v1.2.3 From d41413758d859a10e7d7014a77a3984db6dc0460 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 13:49:42 +0000 Subject: move color button event handling into its own function. --- .../blender/editors/interface/interface_handlers.c | 62 +++++++++++++--------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 57f28a8540f..fc8ced14096 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3585,31 +3585,6 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_BREAK; } } - else if (but->type == COLOR) { - if (ELEM3(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { - float *hsv = ui_block_hsv_get(but->block); - float col[3]; - - ui_get_but_vectorf(but, col); - rgb_to_hsv_compat_v(col, hsv); - - if (event->type == WHEELDOWNMOUSE) - hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f); - else if (event->type == WHEELUPMOUSE) - hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f); - else { - float fac = 0.005 * (event->y - event->prevy); - hsv[2] = CLAMPIS(hsv[2] + fac, 0.0f, 1.0f); - } - - hsv_to_rgb_v(hsv, data->vec); - ui_set_but_vectorf(but, data->vec); - - button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, true); - return WM_UI_HANDLER_BREAK; - } - } } else if (data->state == BUTTON_STATE_WAIT_DRAG) { @@ -3697,6 +3672,41 @@ static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, return changed; } +static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) +{ + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { + button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); + return WM_UI_HANDLER_BREAK; + } + else if (ELEM3(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { + float *hsv = ui_block_hsv_get(but->block); + float col[3]; + + ui_get_but_vectorf(but, col); + rgb_to_hsv_compat_v(col, hsv); + + if (event->type == WHEELDOWNMOUSE) + hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f); + else if (event->type == WHEELUPMOUSE) + hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f); + else { + float fac = 0.005 * (event->y - event->prevy); + hsv[2] = CLAMPIS(hsv[2] + fac, 0.0f, 1.0f); + } + + hsv_to_rgb_v(hsv, data->vec); + ui_set_but_vectorf(but, data->vec); + + button_activate_state(C, but, BUTTON_STATE_EXIT); + ui_apply_button(C, but->block, but, data, true); + return WM_UI_HANDLER_BREAK; + } + } + + return WM_UI_HANDLER_CONTINUE; +} + static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { int mx, my; @@ -5540,7 +5550,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * if (but->a1 == UI_GRAD_V_ALT) /* signal to prevent calling up color picker */ retval = ui_do_but_EXIT(C, but, data, event); else - retval = ui_do_but_BLOCK(C, but, data, event); + retval = ui_do_but_COLOR(C, but, data, event); break; case BUT_NORMAL: retval = ui_do_but_NORMAL(C, block, but, data, event); -- cgit v1.2.3 From e8551313f6b40790947fbc00a8c1182e4f7bca23 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 13:58:28 +0000 Subject: e-key to access the eyedropper over a color button. --- source/blender/editors/interface/interface_handlers.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index fc8ced14096..77eb4a81928 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5405,6 +5405,18 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * else if (event->type == EVT_DROP) { ui_but_drop(C, event, but, data); } + /* handle eyedropper */ + else if ((event->type == EKEY) && (event->val == KM_PRESS)) { + if (event->alt || event->shift || event->ctrl || event->oskey) { + /* pass */ + } + else { + if (but->type == COLOR) { + WM_operator_name_call(C, "UI_OT_eyedropper_color", WM_OP_INVOKE_DEFAULT, NULL); + return WM_UI_HANDLER_BREAK; + } + } + } /* handle keyframing */ else if ((event->type == IKEY) && !ELEM(KM_MOD_FIRST, event->ctrl, event->oskey) && -- cgit v1.2.3 From ed758beb663a3876b5b86b41d2d86a7fede55d89 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 15:07:52 +0000 Subject: move eyedropper into its own file, uses mostly different includes to interface_ops.c --- source/blender/editors/interface/CMakeLists.txt | 1 + .../editors/interface/interface_eyedropper.c | 333 +++++++++++++++++++++ .../blender/editors/interface/interface_intern.h | 5 +- source/blender/editors/interface/interface_ops.c | 290 +----------------- 4 files changed, 341 insertions(+), 288 deletions(-) create mode 100644 source/blender/editors/interface/interface_eyedropper.c (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index a8b8765a5c6..e13517adbb3 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -40,6 +40,7 @@ set(SRC interface.c interface_anim.c interface_draw.c + interface_eyedropper.c interface_handlers.c interface_icons.c interface_layout.c diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c new file mode 100644 index 00000000000..1838381636a --- /dev/null +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -0,0 +1,333 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/interface/interface_eyedropper.c + * \ingroup edinterface + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_space_types.h" +#include "DNA_screen_types.h" + +#include "BLI_blenlib.h" +#include "BLI_math_vector.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "RNA_access.h" + +#include "BIF_gl.h" + +#include "UI_interface.h" + +#include "IMB_colormanagement.h" + +#include "interface_intern.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* for HDR color sampling */ +#include "ED_image.h" +#include "ED_node.h" +#include "ED_clip.h" + + +/** \name Eyedropper (RGB Color) + * \{ */ + +typedef struct Eyedropper { + struct ColorManagedDisplay *display; + + PointerRNA ptr; + PropertyRNA *prop; + int index; + + int accum_start; /* has mouse been presed */ + float accum_col[3]; + int accum_tot; +} Eyedropper; + +static int eyedropper_init(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Eyedropper *eye; + + op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper"); + + uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index); + + if ((eye->ptr.data == NULL) || + (eye->prop == NULL) || + (RNA_property_editable(&eye->ptr, eye->prop) == FALSE) || + (RNA_property_array_length(&eye->ptr, eye->prop) < 3) || + (RNA_property_type(eye->prop) != PROP_FLOAT)) + { + return FALSE; + } + + if (RNA_property_subtype(eye->prop) == PROP_COLOR) { + const char *display_device; + + display_device = scene->display_settings.display_device; + eye->display = IMB_colormanagement_display_get_named(display_device); + } + + return TRUE; +} + +static void eyedropper_exit(bContext *C, wmOperator *op) +{ + WM_cursor_modal_restore(CTX_wm_window(C)); + + if (op->customdata) + MEM_freeN(op->customdata); + op->customdata = NULL; +} + +static int eyedropper_cancel(bContext *C, wmOperator *op) +{ + eyedropper_exit(C, op); + return OPERATOR_CANCELLED; +} + +/* *** eyedropper_color_ helper functions *** */ + +/** + * \brief get the color from the screen. + * + * Special check for image or nodes where we MAY have HDR pixels which don't display. + */ +static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int mx, int my, float r_col[3]) +{ + + /* we could use some clever */ + wmWindow *win = CTX_wm_window(C); + ScrArea *sa; + for (sa = win->screen->areabase.first; sa; sa = sa->next) { + if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) { + if (sa->spacetype == SPACE_IMAGE) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + SpaceImage *sima = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_image_color_sample(sima, ar, mval, r_col)) { + return; + } + } + } + else if (sa->spacetype == SPACE_NODE) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + SpaceNode *snode = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_node_color_sample(snode, ar, mval, r_col)) { + return; + } + } + } + else if (sa->spacetype == SPACE_CLIP) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + SpaceClip *sc = sa->spacedata.first; + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + + if (ED_space_clip_color_sample(sc, ar, mval, r_col)) { + return; + } + } + } + } + } + + /* fallback to simple opengl picker */ + glReadBuffer(GL_FRONT); + glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col); + glReadBuffer(GL_BACK); +} + +/* sets the sample color RGB, maintaining A */ +static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3]) +{ + float col_conv[4]; + + /* to maintain alpha */ + RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv); + + /* convert from display space to linear rgb space */ + if (eye->display) { + copy_v3_v3(col_conv, col); + IMB_colormanagement_display_to_scene_linear_v3(col_conv, eye->display); + } + else { + copy_v3_v3(col_conv, col); + } + + RNA_property_float_set_array(&eye->ptr, eye->prop, col_conv); + + RNA_property_update(C, &eye->ptr, eye->prop); +} + +/* set sample from accumulated values */ +static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye) +{ + float col[3]; + mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot); + eyedropper_color_set(C, eye, col); +} + +/* single point sample & set */ +static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my) +{ + float col[3]; + eyedropper_color_sample_fl(C, eye, mx, my, col); + eyedropper_color_set(C, eye, col); +} + +static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my) +{ + float col[3]; + eyedropper_color_sample_fl(C, eye, mx, my, col); + /* delay linear conversion */ + add_v3_v3(eye->accum_col, col); + eye->accum_tot++; +} + +/* main modal status check */ +static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + Eyedropper *eye = (Eyedropper *)op->customdata; + + switch (event->type) { + case ESCKEY: + case RIGHTMOUSE: + return eyedropper_cancel(C, op); + case LEFTMOUSE: + if (event->val == KM_RELEASE) { + if (eye->accum_tot == 0) { + eyedropper_color_sample(C, eye, event->x, event->y); + } + else { + eyedropper_color_set_accum(C, eye); + } + eyedropper_exit(C, op); + return OPERATOR_FINISHED; + } + else if (event->val == KM_PRESS) { + /* enable accum and make first sample */ + eye->accum_start = TRUE; + eyedropper_color_sample_accum(C, eye, event->x, event->y); + } + break; + case MOUSEMOVE: + if (eye->accum_start) { + /* button is pressed so keep sampling */ + eyedropper_color_sample_accum(C, eye, event->x, event->y); + eyedropper_color_set_accum(C, eye); + } + break; + case SPACEKEY: + if (event->val == KM_RELEASE) { + eye->accum_tot = 0; + zero_v3(eye->accum_col); + eyedropper_color_sample_accum(C, eye, event->x, event->y); + eyedropper_color_set_accum(C, eye); + } + break; + } + + return OPERATOR_RUNNING_MODAL; +} + +/* Modal Operator init */ +static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + /* init */ + if (eyedropper_init(C, op)) { + WM_cursor_modal_set(CTX_wm_window(C), BC_EYEDROPPER_CURSOR); + + /* add temp handler */ + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; + } + else { + eyedropper_exit(C, op); + return OPERATOR_CANCELLED; + } +} + +/* Repeat operator */ +static int eyedropper_exec(bContext *C, wmOperator *op) +{ + /* init */ + if (eyedropper_init(C, op)) { + + /* do something */ + + /* cleanup */ + eyedropper_exit(C, op); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +static int eyedropper_poll(bContext *C) +{ + if (!CTX_wm_window(C)) return 0; + else return 1; +} + +void UI_OT_eyedropper_color(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Eyedropper"; + ot->idname = "UI_OT_eyedropper_color"; + ot->description = "Sample a color from the Blender Window to store in a property"; + + /* api callbacks */ + ot->invoke = eyedropper_invoke; + ot->modal = eyedropper_modal; + ot->cancel = eyedropper_cancel; + ot->exec = eyedropper_exec; + ot->poll = eyedropper_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING; + + /* properties */ +} + +/** \} */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6382130cbbd..a8f71294498 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -584,4 +584,7 @@ int ui_but_anim_expression_set(uiBut *but, const char *str); int ui_but_anim_expression_create(uiBut *but, const char *str); void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra); -#endif +/* interface_eyedropper.c */ +void UI_OT_eyedropper_color(struct wmOperatorType *ot); + +#endif /* __INTERFACE_INTERN_H__ */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index c94267753bb..1c00479acaf 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -27,20 +27,14 @@ * \ingroup edinterface */ -#include -#include #include #include "MEM_guardedalloc.h" -#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_text_types.h" /* for UI_OT_reports_to_text */ #include "BLI_blenlib.h" -#include "BLI_math_color.h" -#include "BLI_math_vector.h" -#include "BLI_utildefines.h" #include "BLF_api.h" #include "BLF_translation.h" @@ -54,12 +48,8 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "BIF_gl.h" - #include "UI_interface.h" -#include "IMB_colormanagement.h" - #include "interface_intern.h" #include "WM_api.h" @@ -70,282 +60,6 @@ #include "BKE_main.h" #include "BLI_ghash.h" -#include "ED_image.h" /* for HDR color sampling */ -#include "ED_node.h" /* for HDR color sampling */ -#include "ED_clip.h" /* for HDR color sampling */ - -/* ********************************************************** */ - -typedef struct Eyedropper { - struct ColorManagedDisplay *display; - - PointerRNA ptr; - PropertyRNA *prop; - int index; - - int accum_start; /* has mouse been presed */ - float accum_col[3]; - int accum_tot; -} Eyedropper; - -static int eyedropper_init(bContext *C, wmOperator *op) -{ - Scene *scene = CTX_data_scene(C); - Eyedropper *eye; - - op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper"); - - uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index); - - if ((eye->ptr.data == NULL) || - (eye->prop == NULL) || - (RNA_property_editable(&eye->ptr, eye->prop) == FALSE) || - (RNA_property_array_length(&eye->ptr, eye->prop) < 3) || - (RNA_property_type(eye->prop) != PROP_FLOAT)) - { - return FALSE; - } - - if (RNA_property_subtype(eye->prop) == PROP_COLOR) { - const char *display_device; - - display_device = scene->display_settings.display_device; - eye->display = IMB_colormanagement_display_get_named(display_device); - } - - return TRUE; -} - -static void eyedropper_exit(bContext *C, wmOperator *op) -{ - WM_cursor_modal_restore(CTX_wm_window(C)); - - if (op->customdata) - MEM_freeN(op->customdata); - op->customdata = NULL; -} - -static int eyedropper_cancel(bContext *C, wmOperator *op) -{ - eyedropper_exit(C, op); - return OPERATOR_CANCELLED; -} - -/* *** eyedropper_color_ helper functions *** */ - -/** - * \brief get the color from the screen. - * - * Special check for image or nodes where we MAY have HDR pixels which don't display. - */ -static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int mx, int my, float r_col[3]) -{ - - /* we could use some clever */ - wmWindow *win = CTX_wm_window(C); - ScrArea *sa; - for (sa = win->screen->areabase.first; sa; sa = sa->next) { - if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) { - if (sa->spacetype == SPACE_IMAGE) { - ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { - SpaceImage *sima = sa->spacedata.first; - int mval[2] = {mx - ar->winrct.xmin, - my - ar->winrct.ymin}; - - if (ED_space_image_color_sample(sima, ar, mval, r_col)) { - return; - } - } - } - else if (sa->spacetype == SPACE_NODE) { - ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { - SpaceNode *snode = sa->spacedata.first; - int mval[2] = {mx - ar->winrct.xmin, - my - ar->winrct.ymin}; - - if (ED_space_node_color_sample(snode, ar, mval, r_col)) { - return; - } - } - } - else if (sa->spacetype == SPACE_CLIP) { - ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { - SpaceClip *sc = sa->spacedata.first; - int mval[2] = {mx - ar->winrct.xmin, - my - ar->winrct.ymin}; - - if (ED_space_clip_color_sample(sc, ar, mval, r_col)) { - return; - } - } - } - } - } - - /* fallback to simple opengl picker */ - glReadBuffer(GL_FRONT); - glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col); - glReadBuffer(GL_BACK); -} - -/* sets the sample color RGB, maintaining A */ -static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3]) -{ - float col_conv[4]; - - /* to maintain alpha */ - RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv); - - /* convert from display space to linear rgb space */ - if (eye->display) { - copy_v3_v3(col_conv, col); - IMB_colormanagement_display_to_scene_linear_v3(col_conv, eye->display); - } - else { - copy_v3_v3(col_conv, col); - } - - RNA_property_float_set_array(&eye->ptr, eye->prop, col_conv); - - RNA_property_update(C, &eye->ptr, eye->prop); -} - -/* set sample from accumulated values */ -static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye) -{ - float col[3]; - mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot); - eyedropper_color_set(C, eye, col); -} - -/* single point sample & set */ -static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my) -{ - float col[3]; - eyedropper_color_sample_fl(C, eye, mx, my, col); - eyedropper_color_set(C, eye, col); -} - -static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my) -{ - float col[3]; - eyedropper_color_sample_fl(C, eye, mx, my, col); - /* delay linear conversion */ - add_v3_v3(eye->accum_col, col); - eye->accum_tot++; -} - -/* main modal status check */ -static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) -{ - Eyedropper *eye = (Eyedropper *)op->customdata; - - switch (event->type) { - case ESCKEY: - case RIGHTMOUSE: - return eyedropper_cancel(C, op); - case LEFTMOUSE: - if (event->val == KM_RELEASE) { - if (eye->accum_tot == 0) { - eyedropper_color_sample(C, eye, event->x, event->y); - } - else { - eyedropper_color_set_accum(C, eye); - } - eyedropper_exit(C, op); - return OPERATOR_FINISHED; - } - else if (event->val == KM_PRESS) { - /* enable accum and make first sample */ - eye->accum_start = TRUE; - eyedropper_color_sample_accum(C, eye, event->x, event->y); - } - break; - case MOUSEMOVE: - if (eye->accum_start) { - /* button is pressed so keep sampling */ - eyedropper_color_sample_accum(C, eye, event->x, event->y); - eyedropper_color_set_accum(C, eye); - } - break; - case SPACEKEY: - if (event->val == KM_RELEASE) { - eye->accum_tot = 0; - zero_v3(eye->accum_col); - eyedropper_color_sample_accum(C, eye, event->x, event->y); - eyedropper_color_set_accum(C, eye); - } - break; - } - - return OPERATOR_RUNNING_MODAL; -} - -/* Modal Operator init */ -static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - /* init */ - if (eyedropper_init(C, op)) { - WM_cursor_modal_set(CTX_wm_window(C), BC_EYEDROPPER_CURSOR); - - /* add temp handler */ - WM_event_add_modal_handler(C, op); - - return OPERATOR_RUNNING_MODAL; - } - else { - eyedropper_exit(C, op); - return OPERATOR_CANCELLED; - } -} - -/* Repeat operator */ -static int eyedropper_exec(bContext *C, wmOperator *op) -{ - /* init */ - if (eyedropper_init(C, op)) { - - /* do something */ - - /* cleanup */ - eyedropper_exit(C, op); - - return OPERATOR_FINISHED; - } - else { - return OPERATOR_CANCELLED; - } -} - -static int eyedropper_poll(bContext *C) -{ - if (!CTX_wm_window(C)) return 0; - else return 1; -} - -static void UI_OT_eyedropper_color(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Eyedropper"; - ot->idname = "UI_OT_eyedropper_color"; - ot->description = "Sample a color from the Blender Window to store in a property"; - - /* api callbacks */ - ot->invoke = eyedropper_invoke; - ot->modal = eyedropper_modal; - ot->cancel = eyedropper_cancel; - ot->exec = eyedropper_exec; - ot->poll = eyedropper_poll; - - /* flags */ - ot->flag = OPTYPE_BLOCKING; - - /* properties */ -} - /* Reset Default Theme ------------------------ */ static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1114,7 +828,6 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot) void UI_buttons_operatortypes(void) { - WM_operatortype_append(UI_OT_eyedropper_color); WM_operatortype_append(UI_OT_reset_default_theme); WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_reset_default_button); @@ -1127,4 +840,7 @@ void UI_buttons_operatortypes(void) WM_operatortype_append(UI_OT_edittranslation_init); #endif WM_operatortype_append(UI_OT_reloadtranslation); + + /* external */ + WM_operatortype_append(UI_OT_eyedropper_color); } -- cgit v1.2.3 From 03f7885b0a87de71f677c3f733bbf870140e5d36 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 15:32:54 +0000 Subject: id-data eyedropprt, currently only accessible via the Ekey, We need to investigate ways to add options like this without cluttering the interface. --- .../editors/interface/interface_eyedropper.c | 310 ++++++++++++++++++++- .../blender/editors/interface/interface_handlers.c | 10 + .../blender/editors/interface/interface_intern.h | 1 + source/blender/editors/interface/interface_ops.c | 1 + 4 files changed, 320 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 1838381636a..56dd18565dc 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -31,12 +31,15 @@ #include "DNA_space_types.h" #include "DNA_screen_types.h" +#include "DNA_object_types.h" #include "BLI_blenlib.h" #include "BLI_math_vector.h" #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_report.h" +#include "BKE_idcode.h" #include "RNA_access.h" @@ -46,16 +49,25 @@ #include "IMB_colormanagement.h" -#include "interface_intern.h" - #include "WM_api.h" #include "WM_types.h" +#include "interface_intern.h" + /* for HDR color sampling */ #include "ED_image.h" #include "ED_node.h" #include "ED_clip.h" +/* for ID data eyedropper */ +#include "ED_space_api.h" +#include "ED_screen.h" +#include "ED_view3d.h" + + +/* -------------------------------------------------------------------- */ +/* Eyedropper + */ /** \name Eyedropper (RGB Color) * \{ */ @@ -329,5 +341,299 @@ void UI_OT_eyedropper_color(wmOperatorType *ot) /* properties */ } +/** \} */ + + +/* -------------------------------------------------------------------- */ +/* Data Dropper + * + * note: datadropper is only internal name to avoid confusion in this file + */ + +/** \name Eyedropper (ID data-blocks) + * \{ */ + +typedef struct DataDropper { + PointerRNA ptr; + PropertyRNA *prop; + short idcode; + const char *idcode_name; + + ARegionType *art; + void *draw_handle_pixel; + char name[200]; +} DataDropper; + + +static void datadropper_draw_cb(const struct bContext *C, ARegion *ar, void *arg) +{ + DataDropper *ddr = arg; + int width; + const char *name = ddr->name; + wmWindow *win = CTX_wm_window(C); + int x = win->eventstate->x; + int y = win->eventstate->y; + + if ((name[0] == '\0') || + (BLI_rcti_isect_pt(&ar->winrct, x, y) == false)) + { + return; + } + + width = UI_GetStringWidth(name); + x = x - ar->winrct.xmin; + y = y - ar->winrct.ymin; + + y += 20; + + glColor4ub(0, 0, 0, 50); + + uiSetRoundBox(UI_CNR_ALL | UI_RB_ALPHA); + uiRoundBox(x, y, x + width + 8, y + 15, 4); + + glColor4ub(255, 255, 255, 255); + UI_DrawString(x + 4, y + 4, name); +} + + +static int datadropper_init(bContext *C, wmOperator *op) +{ + DataDropper *ddr; + int index_dummy; + StructRNA *type; + + SpaceType *st; + ARegionType *art; + + st = BKE_spacetype_from_id(SPACE_VIEW3D); + art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW); + + op->customdata = ddr = MEM_callocN(sizeof(DataDropper), "DataDropper"); + + uiContextActiveProperty(C, &ddr->ptr, &ddr->prop, &index_dummy); + + if ((ddr->ptr.data == NULL) || + (ddr->prop == NULL) || + (RNA_property_editable(&ddr->ptr, ddr->prop) == false) || + (RNA_property_type(ddr->prop) != PROP_POINTER)) + { + return false; + } + + ddr->art = art; + ddr->draw_handle_pixel = ED_region_draw_cb_activate(art, datadropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL); + + type = RNA_property_pointer_type(&ddr->ptr, ddr->prop); + ddr->idcode = RNA_type_to_ID_code(type); + BLI_assert(ddr->idcode != 0); + ddr->idcode_name = BKE_idcode_to_name(ddr->idcode); + + return true; +} + +static void datadropper_exit(bContext *C, wmOperator *op) +{ + DataDropper *ddr = (DataDropper *)op->customdata; + + WM_cursor_modal_restore(CTX_wm_window(C)); + + ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel); + + if (op->customdata) + MEM_freeN(op->customdata); + op->customdata = NULL; +} + +static int datadropper_cancel(bContext *C, wmOperator *op) +{ + datadropper_exit(C, op); + return OPERATOR_CANCELLED; +} + +/* *** datadropper id helper functions *** */ +/** + * \brief get the ID from the screen. + * + */ +static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int my, ID **r_id) +{ + + /* we could use some clever */ + wmWindow *win = CTX_wm_window(C); + ScrArea *sa; + + ScrArea *area_prev = CTX_wm_area(C); + ARegion *ar_prev = CTX_wm_region(C); + + ddr->name[0] = '\0'; + + for (sa = win->screen->areabase.first; sa; sa = sa->next) { + if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) { + if (sa->spacetype == SPACE_VIEW3D) { + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + int mval[2] = {mx - ar->winrct.xmin, + my - ar->winrct.ymin}; + Base *base; + + CTX_wm_area_set(C, sa); + CTX_wm_region_set(C, ar); + + /* grr, always draw else we leave stale text */ + ED_region_tag_redraw(ar); + + base = ED_view3d_give_base_under_cursor(C, mval); + if (base) { + Object *ob = base->object; + ID *id = NULL; + if (ddr->idcode == ID_OB) { + id = (ID *)ob; + } + else if (ob->data) { + if (GS(((ID *)ob->data)->name) == ddr->idcode) { + id = (ID *)ob->data; + } + else { + BLI_snprintf(ddr->name, sizeof(ddr->name), "Incompatible, expected a %s", + ddr->idcode_name); + } + } + + if (id) { + BLI_snprintf(ddr->name, sizeof(ddr->name), "%s: %s", + ddr->idcode_name, id->name + 2); + *r_id = id; + } + + break; + } + } + } + } + } + + CTX_wm_area_set(C, area_prev); + CTX_wm_region_set(C, ar_prev); +} + +/* sets the ID, returns success */ +static bool datadropper_id_set(bContext *C, DataDropper *ddr, ID *id) +{ + PointerRNA ptr_value; + + RNA_id_pointer_create(id, &ptr_value); + + RNA_property_pointer_set(&ddr->ptr, ddr->prop, ptr_value); + + RNA_property_update(C, &ddr->ptr, ddr->prop); + + ptr_value = RNA_property_pointer_get(&ddr->ptr, ddr->prop); + + return (ptr_value.id.data == id); +} + +/* single point sample & set */ +static bool datadropper_id_sample(bContext *C, DataDropper *ddr, int mx, int my) +{ + ID *id = NULL; + + datadropper_id_sample_pt(C, ddr, mx, my, &id); + return datadropper_id_set(C, ddr, id); +} + +/* main modal status check */ +static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + DataDropper *ddr = (DataDropper *)op->customdata; + + switch (event->type) { + case ESCKEY: + case RIGHTMOUSE: + return datadropper_cancel(C, op); + case LEFTMOUSE: + if (event->val == KM_RELEASE) { + bool success; + + success = datadropper_id_sample(C, ddr, event->x, event->y); + datadropper_exit(C, op); + + if (success) { + return OPERATOR_FINISHED; + } + else { + BKE_report(op->reports, RPT_WARNING, "Failed to set value"); + return OPERATOR_CANCELLED; + } + } + break; + case MOUSEMOVE: + { + ID *id = NULL; + datadropper_id_sample_pt(C, ddr, event->x, event->y, &id); + break; + } + } + + return OPERATOR_RUNNING_MODAL; +} + +/* Modal Operator init */ +static int datadropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + /* init */ + if (datadropper_init(C, op)) { + WM_cursor_modal_set(CTX_wm_window(C), BC_EYEDROPPER_CURSOR); + + /* add temp handler */ + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; + } + else { + datadropper_exit(C, op); + return OPERATOR_CANCELLED; + } +} + +/* Repeat operator */ +static int datadropper_exec(bContext *C, wmOperator *op) +{ + /* init */ + if (datadropper_init(C, op)) { + /* cleanup */ + datadropper_exit(C, op); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +static int datadropper_poll(bContext *C) +{ + if (!CTX_wm_window(C)) return 0; + else return 1; +} + +void UI_OT_eyedropper_id(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Eyedropper Datablock"; + ot->idname = "UI_OT_eyedropper_id"; + ot->description = "Sample a color from the Blender Window to store in a property"; + + /* api callbacks */ + ot->invoke = datadropper_invoke; + ot->modal = datadropper_modal; + ot->cancel = datadropper_cancel; + ot->exec = datadropper_exec; + ot->poll = datadropper_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING; + + /* properties */ +} /** \} */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 77eb4a81928..c5faa99e067 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5415,6 +5415,16 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * WM_operator_name_call(C, "UI_OT_eyedropper_color", WM_OP_INVOKE_DEFAULT, NULL); return WM_UI_HANDLER_BREAK; } + else if (but->type == SEARCH_MENU_UNLINK) { + if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_POINTER) { + StructRNA *type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop); + const short idcode = RNA_type_to_ID_code(type); + if ((idcode == ID_OB) || OB_DATA_SUPPORT_ID(idcode)) { + WM_operator_name_call(C, "UI_OT_eyedropper_id", WM_OP_INVOKE_DEFAULT, NULL); + return WM_UI_HANDLER_BREAK; + } + } + } } } /* handle keyframing */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index a8f71294498..9cc16d82810 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -586,5 +586,6 @@ void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, fl /* interface_eyedropper.c */ void UI_OT_eyedropper_color(struct wmOperatorType *ot); +void UI_OT_eyedropper_id(struct wmOperatorType *ot); #endif /* __INTERFACE_INTERN_H__ */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 1c00479acaf..36e965e13d2 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -843,4 +843,5 @@ void UI_buttons_operatortypes(void) /* external */ WM_operatortype_append(UI_OT_eyedropper_color); + WM_operatortype_append(UI_OT_eyedropper_id); } -- cgit v1.2.3 From bfd6f6041dadc78fc6c41f5fbb9725a0171d64b2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 19:47:53 +0000 Subject: remove redundant NULL checks --- source/blender/editors/space_view3d/view3d_select.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 8553791e229..66af2ccb417 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -725,7 +725,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh { const int use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT); Object *ob = vc->obact; - Mesh *me = ob ? ob->data : NULL; + Mesh *me = ob->data; rcti rect; if (me == NULL || me->totvert == 0) @@ -764,7 +764,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { Object *ob = vc->obact; - Mesh *me = ob ? ob->data : NULL; + Mesh *me = ob->data; rcti rect; if (me == NULL || me->totpoly == 0) @@ -2405,7 +2405,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva static void paint_facesel_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad) { Object *ob = vc->obact; - Mesh *me = ob ? ob->data : NULL; + Mesh *me = ob->data; bool bbsel; bm_vertoffs = me->totpoly + 1; /* max index array */ -- cgit v1.2.3 From 590f58d45583f36522ffbcebd68b4a6c921bebeb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Oct 2013 20:18:38 +0000 Subject: code cleanup: redundant includes and add minor comments. --- source/blender/editors/object/object_vgroup.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 82454baae78..b0d884568ca 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -47,6 +47,7 @@ #include "DNA_scene_types.h" #include "DNA_particle_types.h" +#include "BLI_alloca.h" #include "BLI_array.h" #include "BLI_math.h" #include "BLI_blenlib.h" -- cgit v1.2.3 From 4abb8fde95260e692b3cd5b5b2f8bcd1d1f3be3b Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 8 Oct 2013 21:17:24 +0000 Subject: Photoshop PSD support We now support the combined layer of Photoshop files (stored as layer 0 in the file). This way users can keep their files as multilayer PSD and Blender always handle them as flat images. For perfect alpha this requires an OpenImageIO update: https://github.com/OpenImageIO/oiio/commit/342cc2633ff590a3bb278481c61ae798c7148361 Photoshop sample files: https://github.com/OpenImageIO/oiio-images Brecht has some pending fixes to push for OIIO as well, so we may as well wait to update our libraries. What works: =========== * 8bit images (with or without alpha) * 16bits images (alpha discarded) * Photoshop files saved with 'Maximum Compatibility' * Cycles, Blender internal, BGE (and player) Known limitations (due to OIIO dependency): ========================= * Images with less than 4 channels show a wrong thumbnail (bug may be in OIIO) * Packed images are not supported * We do not write PSD files. Note: old Blenders have support for PSD via Quicktime library. But due to license issues this was discontinued. Many thanks for Brecht van Lommel for reviewing the patch, suggesting multiple improvements and to help solving the alpha issue. --- source/blender/editors/space_file/CMakeLists.txt | 4 ++++ source/blender/editors/space_image/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index b30f008e1bf..74f3a425c25 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -58,6 +58,10 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() +if(WITH_IMAGE_PSD) + add_definitions(-DWITH_PSD) +endif() + if(WITH_IMAGE_TIFF) add_definitions(-DWITH_TIFF) endif() diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 6509af179e7..fdc1960d128 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -58,6 +58,9 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() +if(WITH_IMAGE_PSD) + add_definitions(-DWITH_PSD) +endif() if(WITH_IMAGE_TIFF) add_definitions(-DWITH_TIFF) endif() -- cgit v1.2.3 From de3f6b3ec19d2402be8003e172c69e87c356f310 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Oct 2013 14:35:25 +0000 Subject: re-enable activating the text input field for new popup dialog boxes, I'd disabled this for 2.68 since it caused bug [#36109]. This fix now only enabled text activation for popups. (so the toolbar textboxes are skipped) --- source/blender/editors/animation/anim_markers.c | 2 +- source/blender/editors/armature/pose_lib.c | 2 +- source/blender/editors/interface/interface_layout.c | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 3c8576be312..34246427b7e 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1380,7 +1380,7 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm RNA_string_set(op->ptr, "name", marker->name); /* now see if the operator is usable */ - return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup); + return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm); } static void MARKER_OT_rename(wmOperatorType *ot) diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index cb7a699b522..182f94b3693 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -638,7 +638,7 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve } /* part to sync with other similar operators... */ - return WM_operator_props_popup(C, op, event); + return WM_operator_props_popup_confirm(C, op, event); } static int poselib_rename_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 424d2231a03..4e498476f5d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -3091,20 +3091,25 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, /* set various special settings for buttons */ { + uiBlock *block = uiLayoutGetBlock(layout); + const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; uiBut *but; + - for (but = uiLayoutGetBlock(layout)->buttons.first; but; but = but->next) { + for (but = block->buttons.first; but; but = but->next) { /* no undo for buttons for operator redo panels */ uiButClearFlag(but, UI_BUT_UNDO); -#if 0 /* broken, causes freedback loop, see [#36109] */ + /* only for popups, see [#36109] */ + /* if button is operator's default property, and a text-field, enable focus for it * - this is used for allowing operators with popups to rename stuff with fewer clicks */ - if ((but->rnaprop == op->type->prop) && (but->type == TEX)) { - uiButSetFocusOnEnter(CTX_wm_window(C), but); + if (is_popup) { + if ((but->rnaprop == op->type->prop) && (but->type == TEX)) { + uiButSetFocusOnEnter(CTX_wm_window(C), but); + } } -#endif } } } -- cgit v1.2.3 From 1255b1e82dae4db4cc6f1fab1e80e831cbee583b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Oct 2013 15:36:04 +0000 Subject: fix [#37007] Save to file - increment number doesn't update background color of filename field if hovered --- source/blender/editors/interface/interface.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e02cdf018c0..91e5f2fe61d 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -611,6 +611,9 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut **butpp) { + /* flags from the buttons we want to refresh, may want to add more here... */ + const int flag_copy = UI_BUT_REDALERT; + uiBlock *oldblock; uiBut *oldbut, *but = *butpp; int found = 0; @@ -667,6 +670,8 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut SWAP(void *, oldbut->func_argN, but->func_argN); } + oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy); + /* copy hardmin for list rows to prevent 'sticking' highlight to mouse position * when scrolling without moving mouse (see [#28432]) */ if (ELEM(oldbut->type, ROW, LISTROW)) -- cgit v1.2.3 From d917bdb095573161522194449fc22f6809e5b5b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 9 Oct 2013 15:51:14 +0000 Subject: Derivative map baker Added support for derivative map baking, which is accessable as a dedicated baker type. Works pretty much the same as displacement map baker, but gives you derivative map. In fact, inernally this baker is just a filter which applies on the result of displacement map. Both regular and multires baking are supported. Patch by Morten Mikkelsen and self. --- source/blender/editors/object/object_bake.c | 36 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 376f2ed294b..4a8097f260e 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -91,20 +91,24 @@ typedef struct MultiresBakerJobData { struct MultiresBakerJobData *next, *prev; DerivedMesh *lores_dm, *hires_dm; - int simple, lvl, tot_lvl; + bool simple; + int lvl, tot_lvl; ListBase images; } MultiresBakerJobData; /* data passing to multires-baker job */ typedef struct { ListBase data; - int bake_clear, bake_filter; - short mode, use_lores_mesh; - int number_of_rays; - float bias; - int raytrace_structure; - int octree_resolution; - int threads; + bool bake_clear; /* Clear the images before baking */ + int bake_filter; /* Bake-filter, aka margin */ + short mode; /* mode of baking (displacement, normals, AO) */ + bool use_lores_mesh; /* Use low-resolution mesh when baking displacement maps */ + int number_of_rays; /* Number of rays to be cast when doing AO baking */ + float bias; /* Bias between object and start ray point when doing AO baking */ + int raytrace_structure; /* Optimization structure to be used for AO baking */ + int octree_resolution; /* Reslution of octotree when using octotree optimization structure */ + int threads; /* Number of threads to be used for baking */ + float user_scale; /* User scale used to scale displacement when baking derivative map. */ } MultiresBakeJob; static bool multiresbake_check(bContext *C, wmOperator *op) @@ -236,7 +240,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l return dm; } -static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *lvl, int *simple) +static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *lvl, bool *simple) { Mesh *me = (Mesh *)ob->data; MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); @@ -253,7 +257,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l CustomData_set_only_copy(&cddm->polyData, CD_MASK_BAREMESH); *lvl = mmd->totlvl; - *simple = mmd->simple; + *simple = mmd->simple != 0; tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; @@ -349,7 +353,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) if (scene->r.bake_mode == RE_BAKE_NORMALS) { clear_flag = CLEAR_TANGENT_NORMAL; } - else if (scene->r.bake_mode == RE_BAKE_DISPLACEMENT) { + else if (ELEM(scene->r.bake_mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) { clear_flag = CLEAR_DISPLACEMENT; } @@ -376,6 +380,8 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) bkr.raytrace_structure = scene->r.raytrace_structure; bkr.octree_resolution = scene->r.ocres; bkr.threads = BKE_scene_num_threads(scene); + bkr.user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f; + //bkr.reports= op->reports; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple); @@ -414,6 +420,8 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) bkj->raytrace_structure = scene->r.raytrace_structure; bkj->octree_resolution = scene->r.ocres; bkj->threads = BKE_scene_num_threads(scene); + bkj->user_scale = (scene->r.bake_flag & R_BAKE_USERSCALE) ? scene->r.bake_user_scale : -1.0f; + //bkj->reports = op->reports; CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { @@ -453,7 +461,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa if (bkj->mode == RE_BAKE_NORMALS) { clear_flag = CLEAR_TANGENT_NORMAL; } - else if (bkj->mode == RE_BAKE_DISPLACEMENT) { + else if (ELEM(bkj->mode, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE)) { clear_flag = CLEAR_DISPLACEMENT; } @@ -468,6 +476,8 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa bkr.bake_filter = bkj->bake_filter; bkr.mode = bkj->mode; bkr.use_lores_mesh = bkj->use_lores_mesh; + bkr.user_scale = bkj->user_scale; + //bkr.reports = bkj->reports; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ bkr.lores_dm = data->lores_dm; @@ -773,7 +783,7 @@ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const static int is_multires_bake(Scene *scene) { - if (ELEM3(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO)) + if (ELEM4(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_DERIVATIVE, RE_BAKE_AO)) return scene->r.bake_flag & R_BAKE_MULTIRES; return 0; -- cgit v1.2.3 From 6e1fe4ddd9209aa1b5bc562d92f82a6bfb743513 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 9 Oct 2013 15:57:32 +0000 Subject: Implementation of curve mapping in GLSL The title says it all, now having curve mapping enabled in color management settings wouldn't force fallback from GLSL to CPU based color space conversion. --- source/blender/editors/render/render_internal.c | 2 +- source/blender/editors/screen/glutil.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 39d6f836815..df8d5ec4e84 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1152,7 +1152,7 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C) /* Try using GLSL display transform. */ if (force_fallback == false) { - if (IMB_colormanagement_setup_glsl_draw(&scene->view_settings, &scene->display_settings, true, false)) { + if (IMB_colormanagement_setup_glsl_draw(&scene->view_settings, &scene->display_settings, true)) { glEnable(GL_BLEND); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glaDrawPixelsTex(rres.xof, rres.yof, rres.rectx, rres.recty, GL_RGBA, GL_FLOAT, diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 70e5aab6628..b70b06f2aa4 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -1091,18 +1091,15 @@ void glaDrawImBuf_glsl(ImBuf *ibuf, float x, float y, int zoomfilter, if (ibuf->rect_float) { if (ibuf->float_colorspace) { ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, - ibuf->float_colorspace, - true, false); + ibuf->float_colorspace, true); } else { - ok = IMB_colormanagement_setup_glsl_draw(view_settings, display_settings, - true, false); + ok = IMB_colormanagement_setup_glsl_draw(view_settings, display_settings, true); } } else { ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, - ibuf->rect_colorspace, - false, false); + ibuf->rect_colorspace, false); } if (ok) { -- cgit v1.2.3 From fe727ab4a26351894ee277aacbfd1696316bc189 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 9 Oct 2013 16:00:15 +0000 Subject: Paint cursor overlays: Delete the cursor texture overlay resources when exiting a paint mode. --- source/blender/editors/sculpt_paint/paint_cursor.c | 72 ++++++++++++++-------- source/blender/editors/sculpt_paint/paint_image.c | 4 ++ source/blender/editors/sculpt_paint/paint_intern.h | 1 + source/blender/editors/sculpt_paint/paint_vertex.c | 4 ++ source/blender/editors/sculpt_paint/sculpt.c | 2 + 5 files changed, 58 insertions(+), 25 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index c18afd066fa..05fe23eb223 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -79,6 +79,30 @@ typedef struct TexSnapshot { bool old_col; } TexSnapshot; +typedef struct CursorSnapshot { + GLuint overlay_texture; + int size; + int zoom; +} CursorSnapshot; + +static TexSnapshot primary_snap = {0}; +static TexSnapshot secondary_snap = {0}; +static CursorSnapshot cursor_snap = {0}; + +/* delete overlay cursor textures to preserve memory and invalidate all overlay flags */ +void paint_cursor_delete_textures() +{ + glDeleteTextures(1, &primary_snap.overlay_texture); + glDeleteTextures(1, &secondary_snap.overlay_texture); + glDeleteTextures(1, &cursor_snap.overlay_texture); + + memset(&primary_snap, 0, sizeof(TexSnapshot)); + memset(&secondary_snap, 0, sizeof(TexSnapshot)); + memset(&cursor_snap, 0, sizeof(TexSnapshot)); + + BKE_paint_invalidate_overlay_all(); +} + static int same_tex_snap(TexSnapshot *snap, MTex *mtex, ViewContext *vc, bool col, float zoom) { return (/* make brush smaller shouldn't cause a resample */ @@ -103,9 +127,7 @@ static void make_tex_snap(TexSnapshot *snap, ViewContext *vc, float zoom) static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool primary) { - static int init = 0; - static TexSnapshot primary_snap = {0}; - static TexSnapshot secondary_snap = {0}; + bool init; TexSnapshot *target; MTex *mtex = (primary) ? &br->mtex : &br->mask_mtex; @@ -120,12 +142,14 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY); target = (primary) ? &primary_snap : &secondary_snap; - + refresh = !target->overlay_texture || (invalid != 0) || !same_tex_snap(target, mtex, vc, col, zoom); + init = (target->overlay_texture != 0); + if (refresh) { struct ImagePool *pool = NULL; /* stencil is rotated later */ @@ -160,7 +184,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima target->overlay_texture = 0; } - init = 0; + init = false; target->old_size = size; } @@ -267,7 +291,6 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima if (refresh) { if (!init || (target->old_col != col)) { glTexImage2D(GL_TEXTURE_2D, 0, format, size, size, 0, format, GL_UNSIGNED_BYTE, buffer); - init = 1; } else { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, format, GL_UNSIGNED_BYTE, buffer); @@ -297,10 +320,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) { - static GLuint overlay_texture = 0; - static int init = 0; - static int old_size = -1; - static int old_zoom = -1; + bool init; OverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); GLubyte *buffer = NULL; @@ -310,14 +330,16 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) int refresh; refresh = - !overlay_texture || + !cursor_snap.overlay_texture || (overlay_flags & PAINT_INVALID_OVERLAY_CURVE) || - old_zoom != zoom; + cursor_snap.zoom != zoom; + + init = (cursor_snap.overlay_texture != 0); if (refresh) { int s, r; - old_zoom = zoom; + cursor_snap.zoom = zoom; s = BKE_brush_size_get(vc->scene, br); r = 1; @@ -330,18 +352,18 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) if (size < 256) size = 256; - if (size < old_size) - size = old_size; + if (size < cursor_snap.size) + size = cursor_snap.size; - if (old_size != size) { - if (overlay_texture) { - glDeleteTextures(1, &overlay_texture); - overlay_texture = 0; + if (cursor_snap.size != size) { + if (cursor_snap.overlay_texture) { + glDeleteTextures(1, &cursor_snap.overlay_texture); + cursor_snap.overlay_texture = 0; } - init = 0; + init = false; - old_size = size; + cursor_snap.size = size; } buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); @@ -383,14 +405,14 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) } } - if (!overlay_texture) - glGenTextures(1, &overlay_texture); + if (!cursor_snap.overlay_texture) + glGenTextures(1, &cursor_snap.overlay_texture); } else { - size = old_size; + size = cursor_snap.size; } - glBindTexture(GL_TEXTURE_2D, overlay_texture); + glBindTexture(GL_TEXTURE_2D, cursor_snap.overlay_texture); if (refresh) { if (!init) { diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 910a49a8f7d..34603d7516c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -792,6 +792,7 @@ static void toggle_paint_cursor(bContext *C, int enable) if (settings->imapaint.paintcursor && !enable) { WM_paint_cursor_end(wm, settings->imapaint.paintcursor); settings->imapaint.paintcursor = NULL; + paint_cursor_delete_textures(); } else if (enable) paint_cursor_start(C, image_paint_poll); @@ -820,6 +821,9 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) paint_cursor_start_explicit(&imapaint->paint, wm, image_paint_poll); } + else { + paint_cursor_delete_textures(); + } } /************************ grab clone operator ************************/ diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 6c13f6efb74..607edcab9f8 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -86,6 +86,7 @@ void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data); int paint_poll(struct bContext *C); void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, int (*poll)(struct bContext *C)); +void paint_cursor_delete_textures(void); /* paint_vertex.c */ int weight_paint_poll(struct bContext *C); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 122dbae6129..c3f1e38b663 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2062,6 +2062,8 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) /* weight paint spesific */ mesh_octree_table(NULL, NULL, NULL, 'e'); mesh_mirrtopo_table(NULL, 'e'); + + paint_cursor_delete_textures(); } else { ob->mode |= mode_flag; @@ -2684,6 +2686,8 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { BKE_mesh_flush_select_from_polys(me); } + + paint_cursor_delete_textures(); } else { ob->mode |= mode_flag; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 53357b2616b..2a6b6d4b3d9 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5039,6 +5039,8 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) ob->mode &= ~mode_flag; free_sculptsession(ob); + + paint_cursor_delete_textures(); } else { /* Enter sculptmode */ -- cgit v1.2.3 From b754efcca572749c0aad2c94b9ca7a015bbc06b8 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 9 Oct 2013 16:04:08 +0000 Subject: minor code cleanup. --- source/blender/editors/sculpt_paint/paint_cursor.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 05fe23eb223..9649a4c5de8 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -73,7 +73,6 @@ typedef struct TexSnapshot { GLuint overlay_texture; int winx; int winy; - bool init; int old_size; float old_zoom; bool old_col; @@ -417,7 +416,6 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) if (refresh) { if (!init) { glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, size, size, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buffer); - init = 1; } else { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_ALPHA, GL_UNSIGNED_BYTE, buffer); -- cgit v1.2.3 From f43154606a5344086b887a7cf827b480b7438deb Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 9 Oct 2013 16:53:35 +0000 Subject: Fix uber evil (-15 alignment points) own buffer overflow --- source/blender/editors/sculpt_paint/paint_cursor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 9649a4c5de8..e1a2f645dfa 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -97,7 +97,7 @@ void paint_cursor_delete_textures() memset(&primary_snap, 0, sizeof(TexSnapshot)); memset(&secondary_snap, 0, sizeof(TexSnapshot)); - memset(&cursor_snap, 0, sizeof(TexSnapshot)); + memset(&cursor_snap, 0, sizeof(CursorSnapshot)); BKE_paint_invalidate_overlay_all(); } -- cgit v1.2.3 From 4be74273462bbee7ba14dc660a53d769dee235e4 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Thu, 10 Oct 2013 06:33:23 +0000 Subject: Weight Paint Tools: Add "Subset" option to "Normalize All" This option is needed when vertex groups are used for both armature deformation and the other purpose such as influence of mesh modifier. Thanks to Campbell for code review! --- source/blender/editors/object/object_vgroup.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b0d884568ca..d6c365e9247 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2001,7 +2001,11 @@ static void vgroup_levels_subset(Object *ob, const bool *vgroup_validmap, const } } -static void vgroup_normalize_all(Object *ob, const bool lock_active) +static void vgroup_normalize_all(Object *ob, + const bool *vgroup_validmap, + const int vgroup_tot, + const int subset_count, + const bool lock_active) { MDeformVert *dv, **dvert_array = NULL; int i, dvert_tot = 0; @@ -2009,7 +2013,7 @@ static void vgroup_normalize_all(Object *ob, const bool lock_active) const int use_vert_sel = vertex_group_use_vert_sel(ob); - if (lock_active && !BLI_findlink(&ob->defbase, def_nr)) { + if ((lock_active && !BLI_findlink(&ob->defbase, def_nr)) || subset_count == 0) { return; } @@ -2030,13 +2034,15 @@ static void vgroup_normalize_all(Object *ob, const bool lock_active) /* in case its not selected */ if ((dv = dvert_array[i])) { if (lock_flags) { - defvert_normalize_lock_map(dv, lock_flags, defbase_tot); + defvert_normalize_lock_map(dv, vgroup_validmap, vgroup_tot, + lock_flags, defbase_tot); } else if (lock_active) { - defvert_normalize_lock_single(dv, def_nr); + defvert_normalize_lock_single(dv, vgroup_validmap, vgroup_tot, + def_nr); } else { - defvert_normalize(dv); + defvert_normalize_subset(dv, vgroup_validmap, vgroup_tot); } } } @@ -3474,8 +3480,13 @@ static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); bool lock_active = RNA_boolean_get(op->ptr, "lock_active"); + eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode"); + + int subset_count, vgroup_tot; - vgroup_normalize_all(ob, lock_active); + const bool *vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); + vgroup_normalize_all(ob, vgroup_validmap, vgroup_tot, subset_count, lock_active); + MEM_freeN((void *)vgroup_validmap); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -3499,6 +3510,7 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + vgroup_operator_subset_select_props(ot, false); RNA_def_boolean(ot->srna, "lock_active", true, "Lock Active", "Keep the values of the active group while normalizing others"); } -- cgit v1.2.3 From 77a0b90cdf5d42b774f75b392aa0e3aeb7ed3452 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 10 Oct 2013 11:33:20 +0000 Subject: Cleanup: Consistent names for draw callbacks in bNodeType. This aims to establish a common pattern for the various confusing draw callback function pointers in bNodeType: draw__[_ex] Currently there are 4 different types of draw callbacks: * draw_nodetype, draw_nodetype_prepare: Main draw functions, allows specialized node drawing for things like frames and reroute nodes. Not exposed in the API. * draw_buttons, draw_buttons_ex: Optional non-socket buttons, most commonly used callback. Extended version used in sidebar for verbose buttons that don't fit into a node. * draw_backdrop: Draw elements in the backdrop (compositor only). Not exposed in the API. * draw_input, draw_output: Specialized socket drawing for some nodes, only for OutputFile node. Should not be used any further and be removed at some point. Not exposed in the API. --- source/blender/editors/space_node/drawnode.c | 326 ++++++++++----------- source/blender/editors/space_node/node_draw.c | 16 +- source/blender/editors/space_node/node_edit.c | 4 +- source/blender/editors/space_node/node_templates.c | 8 +- 4 files changed, 177 insertions(+), 177 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index f562212f1e2..b348156bc1f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -339,7 +339,7 @@ static int node_resize_area_default(bNode *node, int x, int y) /* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */ -static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL); } @@ -348,7 +348,7 @@ static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) * Not ideal to do this in every draw call, but doing as transform callback doesn't work, * since the child node totr rects are not updated properly at that point. */ -static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node) +static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node) { const float margin = 1.5f * U.widget_unit; NodeFrame *data = (NodeFrame *)node->storage; @@ -511,7 +511,7 @@ static int node_resize_area_frame(bNode *node, int x, int y) return dir; } -static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_buts_frame_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE); uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE); @@ -520,7 +520,7 @@ static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), Point #define NODE_REROUTE_SIZE 8.0f -static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node) +static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *nsock; float locx, locy; @@ -632,17 +632,17 @@ static void node_common_set_butfunc(bNodeType *ntype) { switch (ntype->type) { case NODE_GROUP: - ntype->uifunc = node_uifunc_group; + ntype->draw_buttons = node_draw_buttons_group; break; case NODE_FRAME: - ntype->drawfunc = node_draw_frame; - ntype->drawupdatefunc = node_update_frame; - ntype->uifuncbut = node_buts_frame_details; + ntype->draw_nodetype = node_draw_frame; + ntype->draw_nodetype_prepare = node_draw_frame_prepare; + ntype->draw_buttons_ex = node_buts_frame_ex; ntype->resize_area_func = node_resize_area_frame; break; case NODE_REROUTE: - ntype->drawfunc = node_draw_reroute; - ntype->drawupdatefunc = node_update_reroute; + ntype->draw_nodetype = node_draw_reroute; + ntype->draw_nodetype_prepare = node_draw_reroute_prepare; ntype->tweak_area_func = node_tweak_area_reroute; break; } @@ -792,7 +792,7 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr); } -static void node_shader_buts_tex_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_shader_buts_tex_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user"); uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0); @@ -953,7 +953,7 @@ static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), Point uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update"); } -static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiItemS(layout); @@ -971,110 +971,110 @@ static void node_shader_set_butfunc(bNodeType *ntype) switch (ntype->type) { case SH_NODE_MATERIAL: case SH_NODE_MATERIAL_EXT: - ntype->uifunc = node_shader_buts_material; + ntype->draw_buttons = node_shader_buts_material; break; case SH_NODE_TEXTURE: - ntype->uifunc = node_buts_texture; + ntype->draw_buttons = node_buts_texture; break; case SH_NODE_NORMAL: - ntype->uifunc = node_buts_normal; + ntype->draw_buttons = node_buts_normal; break; case SH_NODE_CURVE_VEC: - ntype->uifunc = node_buts_curvevec; + ntype->draw_buttons = node_buts_curvevec; break; case SH_NODE_CURVE_RGB: - ntype->uifunc = node_buts_curvecol; + ntype->draw_buttons = node_buts_curvecol; break; case SH_NODE_MAPPING: - ntype->uifunc = node_shader_buts_mapping; + ntype->draw_buttons = node_shader_buts_mapping; break; case SH_NODE_VALUE: - ntype->uifunc = node_buts_value; + ntype->draw_buttons = node_buts_value; break; case SH_NODE_RGB: - ntype->uifunc = node_buts_rgb; + ntype->draw_buttons = node_buts_rgb; break; case SH_NODE_MIX_RGB: - ntype->uifunc = node_buts_mix_rgb; + ntype->draw_buttons = node_buts_mix_rgb; break; case SH_NODE_VALTORGB: - ntype->uifunc = node_buts_colorramp; + ntype->draw_buttons = node_buts_colorramp; break; case SH_NODE_MATH: - ntype->uifunc = node_buts_math; + ntype->draw_buttons = node_buts_math; break; case SH_NODE_VECT_MATH: - ntype->uifunc = node_shader_buts_vect_math; + ntype->draw_buttons = node_shader_buts_vect_math; break; case SH_NODE_VECT_TRANSFORM: - ntype->uifunc = node_shader_buts_vect_transform; + ntype->draw_buttons = node_shader_buts_vect_transform; break; case SH_NODE_GEOMETRY: - ntype->uifunc = node_shader_buts_geometry; + ntype->draw_buttons = node_shader_buts_geometry; break; case SH_NODE_ATTRIBUTE: - ntype->uifunc = node_shader_buts_attribute; + ntype->draw_buttons = node_shader_buts_attribute; break; case SH_NODE_WIREFRAME: - ntype->uifunc = node_shader_buts_wireframe; + ntype->draw_buttons = node_shader_buts_wireframe; break; case SH_NODE_TEX_SKY: - ntype->uifunc = node_shader_buts_tex_sky; + ntype->draw_buttons = node_shader_buts_tex_sky; break; case SH_NODE_TEX_IMAGE: - ntype->uifunc = node_shader_buts_tex_image; - ntype->uifuncbut = node_shader_buts_tex_image_details; + ntype->draw_buttons = node_shader_buts_tex_image; + ntype->draw_buttons_ex = node_shader_buts_tex_image_ex; break; case SH_NODE_TEX_ENVIRONMENT: - ntype->uifunc = node_shader_buts_tex_environment; + ntype->draw_buttons = node_shader_buts_tex_environment; break; case SH_NODE_TEX_GRADIENT: - ntype->uifunc = node_shader_buts_tex_gradient; + ntype->draw_buttons = node_shader_buts_tex_gradient; break; case SH_NODE_TEX_MAGIC: - ntype->uifunc = node_shader_buts_tex_magic; + ntype->draw_buttons = node_shader_buts_tex_magic; break; case SH_NODE_TEX_BRICK: - ntype->uifunc = node_shader_buts_tex_brick; + ntype->draw_buttons = node_shader_buts_tex_brick; break; case SH_NODE_TEX_WAVE: - ntype->uifunc = node_shader_buts_tex_wave; + ntype->draw_buttons = node_shader_buts_tex_wave; break; case SH_NODE_TEX_MUSGRAVE: - ntype->uifunc = node_shader_buts_tex_musgrave; + ntype->draw_buttons = node_shader_buts_tex_musgrave; break; case SH_NODE_TEX_VORONOI: - ntype->uifunc = node_shader_buts_tex_voronoi; + ntype->draw_buttons = node_shader_buts_tex_voronoi; break; case SH_NODE_TEX_COORD: - ntype->uifunc = node_shader_buts_tex_coord; + ntype->draw_buttons = node_shader_buts_tex_coord; break; case SH_NODE_BUMP: - ntype->uifunc = node_shader_buts_bump; + ntype->draw_buttons = node_shader_buts_bump; break; case SH_NODE_NORMAL_MAP: - ntype->uifunc = node_shader_buts_normal_map; + ntype->draw_buttons = node_shader_buts_normal_map; break; case SH_NODE_TANGENT: - ntype->uifunc = node_shader_buts_tangent; + ntype->draw_buttons = node_shader_buts_tangent; break; case SH_NODE_BSDF_GLOSSY: case SH_NODE_BSDF_GLASS: case SH_NODE_BSDF_REFRACTION: - ntype->uifunc = node_shader_buts_glossy; + ntype->draw_buttons = node_shader_buts_glossy; break; case SH_NODE_SUBSURFACE_SCATTERING: - ntype->uifunc = node_shader_buts_subsurface; + ntype->draw_buttons = node_shader_buts_subsurface; break; case SH_NODE_BSDF_TOON: - ntype->uifunc = node_shader_buts_toon; + ntype->draw_buttons = node_shader_buts_toon; break; case SH_NODE_BSDF_HAIR: - ntype->uifunc = node_shader_buts_hair; + ntype->draw_buttons = node_shader_buts_hair; break; case SH_NODE_SCRIPT: - ntype->uifunc = node_shader_buts_script; - ntype->uifuncbut = node_shader_buts_script_details; + ntype->draw_buttons = node_shader_buts_script; + ntype->draw_buttons_ex = node_shader_buts_script_ex; break; } } @@ -1096,7 +1096,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } -static void node_composit_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_composit_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { bNode *node = ptr->data; PointerRNA iuserptr; @@ -1629,7 +1629,7 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C) uiItemL(layout, IFACE_("Base Path:"), ICON_NONE); uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE); } -static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { PointerRNA imfptr = RNA_pointer_get(ptr, "format"); PointerRNA active_input_ptr, op_ptr; @@ -1787,7 +1787,7 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C } } -static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_composit_buts_colorbalance_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE); @@ -1841,7 +1841,7 @@ static void node_composit_buts_movieclip(uiLayout *layout, bContext *C, PointerR uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL); } -static void node_composit_buts_movieclip_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_composit_buts_movieclip_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { bNode *node = ptr->data; PointerRNA clipptr; @@ -1945,7 +1945,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } -static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; @@ -2147,7 +2147,7 @@ static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), Poi uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE); } -static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; @@ -2295,222 +2295,222 @@ static void node_composit_set_butfunc(bNodeType *ntype) { switch (ntype->type) { case CMP_NODE_IMAGE: - ntype->uifunc = node_composit_buts_image; - ntype->uifuncbut = node_composit_buts_image_details; + ntype->draw_buttons = node_composit_buts_image; + ntype->draw_buttons_ex = node_composit_buts_image_ex; break; case CMP_NODE_R_LAYERS: - ntype->uifunc = node_composit_buts_renderlayers; + ntype->draw_buttons = node_composit_buts_renderlayers; break; case CMP_NODE_NORMAL: - ntype->uifunc = node_buts_normal; + ntype->draw_buttons = node_buts_normal; break; case CMP_NODE_CURVE_VEC: - ntype->uifunc = node_buts_curvevec; + ntype->draw_buttons = node_buts_curvevec; break; case CMP_NODE_CURVE_RGB: - ntype->uifunc = node_buts_curvecol; + ntype->draw_buttons = node_buts_curvecol; break; case CMP_NODE_VALUE: - ntype->uifunc = node_buts_value; + ntype->draw_buttons = node_buts_value; break; case CMP_NODE_RGB: - ntype->uifunc = node_buts_rgb; + ntype->draw_buttons = node_buts_rgb; break; case CMP_NODE_FLIP: - ntype->uifunc = node_composit_buts_flip; + ntype->draw_buttons = node_composit_buts_flip; break; case CMP_NODE_SPLITVIEWER: - ntype->uifunc = node_composit_buts_splitviewer; + ntype->draw_buttons = node_composit_buts_splitviewer; break; case CMP_NODE_MIX_RGB: - ntype->uifunc = node_buts_mix_rgb; + ntype->draw_buttons = node_buts_mix_rgb; break; case CMP_NODE_VALTORGB: - ntype->uifunc = node_buts_colorramp; + ntype->draw_buttons = node_buts_colorramp; break; case CMP_NODE_CROP: - ntype->uifunc = node_composit_buts_crop; + ntype->draw_buttons = node_composit_buts_crop; break; case CMP_NODE_BLUR: - ntype->uifunc = node_composit_buts_blur; + ntype->draw_buttons = node_composit_buts_blur; break; case CMP_NODE_DBLUR: - ntype->uifunc = node_composit_buts_dblur; + ntype->draw_buttons = node_composit_buts_dblur; break; case CMP_NODE_BILATERALBLUR: - ntype->uifunc = node_composit_buts_bilateralblur; + ntype->draw_buttons = node_composit_buts_bilateralblur; break; case CMP_NODE_DEFOCUS: - ntype->uifunc = node_composit_buts_defocus; + ntype->draw_buttons = node_composit_buts_defocus; break; case CMP_NODE_GLARE: - ntype->uifunc = node_composit_buts_glare; + ntype->draw_buttons = node_composit_buts_glare; break; case CMP_NODE_TONEMAP: - ntype->uifunc = node_composit_buts_tonemap; + ntype->draw_buttons = node_composit_buts_tonemap; break; case CMP_NODE_LENSDIST: - ntype->uifunc = node_composit_buts_lensdist; + ntype->draw_buttons = node_composit_buts_lensdist; break; case CMP_NODE_VECBLUR: - ntype->uifunc = node_composit_buts_vecblur; + ntype->draw_buttons = node_composit_buts_vecblur; break; case CMP_NODE_FILTER: - ntype->uifunc = node_composit_buts_filter; + ntype->draw_buttons = node_composit_buts_filter; break; case CMP_NODE_MAP_VALUE: - ntype->uifunc = node_composit_buts_map_value; + ntype->draw_buttons = node_composit_buts_map_value; break; case CMP_NODE_MAP_RANGE: - ntype->uifunc = node_composit_buts_map_range; + ntype->draw_buttons = node_composit_buts_map_range; break; case CMP_NODE_TIME: - ntype->uifunc = node_buts_time; + ntype->draw_buttons = node_buts_time; break; case CMP_NODE_ALPHAOVER: - ntype->uifunc = node_composit_buts_alphaover; + ntype->draw_buttons = node_composit_buts_alphaover; break; case CMP_NODE_HUE_SAT: - ntype->uifunc = node_composit_buts_hue_sat; + ntype->draw_buttons = node_composit_buts_hue_sat; break; case CMP_NODE_TEXTURE: - ntype->uifunc = node_buts_texture; + ntype->draw_buttons = node_buts_texture; break; case CMP_NODE_DILATEERODE: - ntype->uifunc = node_composit_buts_dilateerode; + ntype->draw_buttons = node_composit_buts_dilateerode; break; case CMP_NODE_INPAINT: - ntype->uifunc = node_composit_buts_inpaint; + ntype->draw_buttons = node_composit_buts_inpaint; break; case CMP_NODE_DESPECKLE: - ntype->uifunc = node_composit_buts_despeckle; + ntype->draw_buttons = node_composit_buts_despeckle; break; case CMP_NODE_OUTPUT_FILE: - ntype->uifunc = node_composit_buts_file_output; - ntype->uifuncbut = node_composit_buts_file_output_details; - ntype->drawinputfunc = node_draw_input_file_output; + ntype->draw_buttons = node_composit_buts_file_output; + ntype->draw_buttons_ex = node_composit_buts_file_output_ex; + ntype->draw_input = node_draw_input_file_output; break; case CMP_NODE_DIFF_MATTE: - ntype->uifunc = node_composit_buts_diff_matte; + ntype->draw_buttons = node_composit_buts_diff_matte; break; case CMP_NODE_DIST_MATTE: - ntype->uifunc = node_composit_buts_distance_matte; + ntype->draw_buttons = node_composit_buts_distance_matte; break; case CMP_NODE_COLOR_SPILL: - ntype->uifunc = node_composit_buts_color_spill; + ntype->draw_buttons = node_composit_buts_color_spill; break; case CMP_NODE_CHROMA_MATTE: - ntype->uifunc = node_composit_buts_chroma_matte; + ntype->draw_buttons = node_composit_buts_chroma_matte; break; case CMP_NODE_COLOR_MATTE: - ntype->uifunc = node_composit_buts_color_matte; + ntype->draw_buttons = node_composit_buts_color_matte; break; case CMP_NODE_SCALE: - ntype->uifunc = node_composit_buts_scale; + ntype->draw_buttons = node_composit_buts_scale; break; case CMP_NODE_ROTATE: - ntype->uifunc = node_composit_buts_rotate; + ntype->draw_buttons = node_composit_buts_rotate; break; case CMP_NODE_CHANNEL_MATTE: - ntype->uifunc = node_composit_buts_channel_matte; + ntype->draw_buttons = node_composit_buts_channel_matte; break; case CMP_NODE_LUMA_MATTE: - ntype->uifunc = node_composit_buts_luma_matte; + ntype->draw_buttons = node_composit_buts_luma_matte; break; case CMP_NODE_MAP_UV: - ntype->uifunc = node_composit_buts_map_uv; + ntype->draw_buttons = node_composit_buts_map_uv; break; case CMP_NODE_ID_MASK: - ntype->uifunc = node_composit_buts_id_mask; + ntype->draw_buttons = node_composit_buts_id_mask; break; case CMP_NODE_DOUBLEEDGEMASK: - ntype->uifunc = node_composit_buts_double_edge_mask; + ntype->draw_buttons = node_composit_buts_double_edge_mask; break; case CMP_NODE_MATH: - ntype->uifunc = node_buts_math; + ntype->draw_buttons = node_buts_math; break; case CMP_NODE_INVERT: - ntype->uifunc = node_composit_buts_invert; + ntype->draw_buttons = node_composit_buts_invert; break; case CMP_NODE_PREMULKEY: - ntype->uifunc = node_composit_buts_premulkey; + ntype->draw_buttons = node_composit_buts_premulkey; break; case CMP_NODE_VIEW_LEVELS: - ntype->uifunc = node_composit_buts_view_levels; + ntype->draw_buttons = node_composit_buts_view_levels; break; case CMP_NODE_COLORBALANCE: - ntype->uifunc = node_composit_buts_colorbalance; - ntype->uifuncbut = node_composit_buts_colorbalance_but; + ntype->draw_buttons = node_composit_buts_colorbalance; + ntype->draw_buttons_ex = node_composit_buts_colorbalance_ex; break; case CMP_NODE_HUECORRECT: - ntype->uifunc = node_composit_buts_huecorrect; + ntype->draw_buttons = node_composit_buts_huecorrect; break; case CMP_NODE_ZCOMBINE: - ntype->uifunc = node_composit_buts_zcombine; + ntype->draw_buttons = node_composit_buts_zcombine; break; case CMP_NODE_COMBYCCA: case CMP_NODE_SEPYCCA: - ntype->uifunc = node_composit_buts_ycc; + ntype->draw_buttons = node_composit_buts_ycc; break; case CMP_NODE_MOVIECLIP: - ntype->uifunc = node_composit_buts_movieclip; - ntype->uifuncbut = node_composit_buts_movieclip_details; + ntype->draw_buttons = node_composit_buts_movieclip; + ntype->draw_buttons_ex = node_composit_buts_movieclip_ex; break; case CMP_NODE_STABILIZE2D: - ntype->uifunc = node_composit_buts_stabilize2d; + ntype->draw_buttons = node_composit_buts_stabilize2d; break; case CMP_NODE_TRANSFORM: - ntype->uifunc = node_composit_buts_transform; + ntype->draw_buttons = node_composit_buts_transform; break; case CMP_NODE_TRANSLATE: - ntype->uifunc = node_composit_buts_translate; + ntype->draw_buttons = node_composit_buts_translate; break; case CMP_NODE_MOVIEDISTORTION: - ntype->uifunc = node_composit_buts_moviedistortion; + ntype->draw_buttons = node_composit_buts_moviedistortion; break; case CMP_NODE_COLORCORRECTION: - ntype->uifunc = node_composit_buts_colorcorrection; - ntype->uifuncbut = node_composit_buts_colorcorrection_but; + ntype->draw_buttons = node_composit_buts_colorcorrection; + ntype->draw_buttons_ex = node_composit_buts_colorcorrection_ex; break; case CMP_NODE_SWITCH: - ntype->uifunc = node_composit_buts_switch; + ntype->draw_buttons = node_composit_buts_switch; break; case CMP_NODE_MASK_BOX: - ntype->uifunc = node_composit_buts_boxmask; - ntype->uibackdropfunc = node_composit_backdrop_boxmask; + ntype->draw_buttons = node_composit_buts_boxmask; + ntype->draw_backdrop = node_composit_backdrop_boxmask; break; case CMP_NODE_MASK_ELLIPSE: - ntype->uifunc = node_composit_buts_ellipsemask; - ntype->uibackdropfunc = node_composit_backdrop_ellipsemask; + ntype->draw_buttons = node_composit_buts_ellipsemask; + ntype->draw_backdrop = node_composit_backdrop_ellipsemask; break; case CMP_NODE_BOKEHIMAGE: - ntype->uifunc = node_composit_buts_bokehimage; + ntype->draw_buttons = node_composit_buts_bokehimage; break; case CMP_NODE_BOKEHBLUR: - ntype->uifunc = node_composit_buts_bokehblur; + ntype->draw_buttons = node_composit_buts_bokehblur; break; case CMP_NODE_VIEWER: - ntype->uifunc = node_composit_buts_viewer; - ntype->uifuncbut = node_composit_buts_viewer_but; - ntype->uibackdropfunc = node_composit_backdrop_viewer; + ntype->draw_buttons = node_composit_buts_viewer; + ntype->draw_buttons_ex = node_composit_buts_viewer_ex; + ntype->draw_backdrop = node_composit_backdrop_viewer; break; case CMP_NODE_COMPOSITE: - ntype->uifunc = node_composit_buts_composite; + ntype->draw_buttons = node_composit_buts_composite; break; case CMP_NODE_MASK: - ntype->uifunc = node_composit_buts_mask; + ntype->draw_buttons = node_composit_buts_mask; break; case CMP_NODE_KEYINGSCREEN: - ntype->uifunc = node_composit_buts_keyingscreen; + ntype->draw_buttons = node_composit_buts_keyingscreen; break; case CMP_NODE_KEYING: - ntype->uifunc = node_composit_buts_keying; + ntype->draw_buttons = node_composit_buts_keying; break; case CMP_NODE_TRACKPOS: - ntype->uifunc = node_composit_buts_trackpos; + ntype->draw_buttons = node_composit_buts_trackpos; break; case CMP_NODE_PLANETRACKDEFORM: - ntype->uifunc = node_composit_buts_planetrackdeform; + ntype->draw_buttons = node_composit_buts_planetrackdeform; break; } } @@ -2615,7 +2615,7 @@ static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *p uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); } -static void node_texture_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { bNode *node = ptr->data; PointerRNA iuserptr; @@ -2633,46 +2633,46 @@ static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), Poin static void node_texture_set_butfunc(bNodeType *ntype) { if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) { - ntype->uifunc = node_texture_buts_proc; + ntype->draw_buttons = node_texture_buts_proc; } else { switch (ntype->type) { case TEX_NODE_MATH: - ntype->uifunc = node_buts_math; + ntype->draw_buttons = node_buts_math; break; case TEX_NODE_MIX_RGB: - ntype->uifunc = node_buts_mix_rgb; + ntype->draw_buttons = node_buts_mix_rgb; break; case TEX_NODE_VALTORGB: - ntype->uifunc = node_buts_colorramp; + ntype->draw_buttons = node_buts_colorramp; break; case TEX_NODE_CURVE_RGB: - ntype->uifunc = node_buts_curvecol; + ntype->draw_buttons = node_buts_curvecol; break; case TEX_NODE_CURVE_TIME: - ntype->uifunc = node_buts_time; + ntype->draw_buttons = node_buts_time; break; case TEX_NODE_TEXTURE: - ntype->uifunc = node_buts_texture; + ntype->draw_buttons = node_buts_texture; break; case TEX_NODE_BRICKS: - ntype->uifunc = node_texture_buts_bricks; + ntype->draw_buttons = node_texture_buts_bricks; break; case TEX_NODE_IMAGE: - ntype->uifunc = node_texture_buts_image; - ntype->uifuncbut = node_texture_buts_image_details; + ntype->draw_buttons = node_texture_buts_image; + ntype->draw_buttons_ex = node_texture_buts_image_ex; break; case TEX_NODE_OUTPUT: - ntype->uifunc = node_texture_buts_output; + ntype->draw_buttons = node_texture_buts_output; break; } } @@ -2746,14 +2746,14 @@ void ED_node_init_butfuncs(void) extern bNodeSocketType NodeSocketTypeUndefined; /* default ui functions */ - NodeTypeUndefined.drawfunc = node_draw_default; - NodeTypeUndefined.drawupdatefunc = node_update_default; + NodeTypeUndefined.draw_nodetype = node_draw_default; + NodeTypeUndefined.draw_nodetype_prepare = node_update_default; NodeTypeUndefined.select_area_func = node_select_area_default; NodeTypeUndefined.tweak_area_func = node_tweak_area_default; - NodeTypeUndefined.uifunc = NULL; - NodeTypeUndefined.uifuncbut = NULL; - NodeTypeUndefined.drawinputfunc = node_draw_input_default; - NodeTypeUndefined.drawoutputfunc = node_draw_output_default; + NodeTypeUndefined.draw_buttons = NULL; + NodeTypeUndefined.draw_buttons_ex = NULL; + NodeTypeUndefined.draw_input = node_draw_input_default; + NodeTypeUndefined.draw_output = node_draw_output_default; NodeTypeUndefined.resize_area_func = node_resize_area_default; NodeSocketTypeUndefined.draw = node_socket_undefined_draw; @@ -2764,14 +2764,14 @@ void ED_node_init_butfuncs(void) /* node type ui functions */ NODE_TYPES_BEGIN(ntype) /* default ui functions */ - ntype->drawfunc = node_draw_default; - ntype->drawupdatefunc = node_update_default; + ntype->draw_nodetype = node_draw_default; + ntype->draw_nodetype_prepare = node_update_default; ntype->select_area_func = node_select_area_default; ntype->tweak_area_func = node_tweak_area_default; - ntype->uifunc = NULL; - ntype->uifuncbut = NULL; - ntype->drawinputfunc = node_draw_input_default; - ntype->drawoutputfunc = node_draw_output_default; + ntype->draw_buttons = NULL; + ntype->draw_buttons_ex = NULL; + ntype->draw_input = node_draw_input_default; + ntype->draw_output = node_draw_output_default; ntype->resize_area_func = node_resize_area_default; node_common_set_butfunc(ntype); @@ -2793,10 +2793,10 @@ void ED_node_init_butfuncs(void) void ED_init_custom_node_type(bNodeType *ntype) { /* default ui functions */ - ntype->drawfunc = node_draw_default; - ntype->drawupdatefunc = node_update_default; - ntype->drawinputfunc = node_draw_input_default; - ntype->drawoutputfunc = node_draw_output_default; + ntype->draw_nodetype = node_draw_default; + ntype->draw_nodetype_prepare = node_update_default; + ntype->draw_input = node_draw_input_default; + ntype->draw_output = node_draw_output_default; ntype->resize_area_func = node_resize_area_default; ntype->select_area_func = node_select_area_default; ntype->tweak_area_func = node_tweak_area_default; @@ -3053,8 +3053,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b rctf *viewer_border = &snode->nodetree->viewer_border; while (node) { if (node->flag & NODE_SELECT) { - if (node->typeinfo->uibackdropfunc) { - node->typeinfo->uibackdropfunc(snode, ibuf, node, x, y); + if (node->typeinfo->draw_backdrop) { + node->typeinfo->draw_backdrop(snode, ibuf, node, x, y); } } node = node->next; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index b991a2c3b5f..3196e4cc6af 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -351,7 +351,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); - node->typeinfo->drawoutputfunc((bContext *)C, row, &sockptr, &nodeptr); + node->typeinfo->draw_output((bContext *)C, row, &sockptr, &nodeptr); uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); @@ -402,7 +402,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) } /* buttons rect? */ - if (node->typeinfo->uifunc && (node->flag & NODE_OPTIONS)) { + if (node->typeinfo->draw_buttons && (node->flag & NODE_OPTIONS)) { dy -= NODE_DYS / 2; /* set this for uifunc() that don't use layout engine yet */ @@ -416,7 +416,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) locx + NODE_DYS, dy, node->butr.xmax, 0, UI_GetStyle()); uiLayoutSetContextPointer(layout, "node", &nodeptr); - node->typeinfo->uifunc(layout, (bContext *)C, &nodeptr); + node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr); uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); @@ -437,7 +437,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - node->typeinfo->drawinputfunc((bContext *)C, layout, &sockptr, &nodeptr); + node->typeinfo->draw_input((bContext *)C, layout, &sockptr, &nodeptr); uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); @@ -1115,8 +1115,8 @@ void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTr static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) { - if (node->typeinfo->drawupdatefunc) - node->typeinfo->drawupdatefunc(C, ntree, node); + if (node->typeinfo->draw_nodetype_prepare) + node->typeinfo->draw_nodetype_prepare(C, ntree, node); } void node_update_nodetree(const bContext *C, bNodeTree *ntree) @@ -1131,8 +1131,8 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree) static void node_draw(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) { - if (node->typeinfo->drawfunc) - node->typeinfo->drawfunc(C, ar, snode, ntree, node, key); + if (node->typeinfo->draw_nodetype) + node->typeinfo->draw_nodetype(C, ar, snode, ntree, node, key); } #define USE_DRAW_TOT_UPDATE diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index bc0a518b1b0..1d93fe65c09 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1419,7 +1419,7 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->uifunc || node->typeinfo->uifuncbut)) + if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; if (node->flag & toggle_flag) @@ -1433,7 +1433,7 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->uifunc || node->typeinfo->uifuncbut)) + if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; if ((tot_eq && tot_neq) || tot_eq == 0) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 83c11e69d84..a67a8791a64 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -207,7 +207,7 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode * break; if (node_from) - if (node_from->inputs.first || node_from->typeinfo->uifunc || node_from->typeinfo->uifuncbut) + if (node_from->inputs.first || node_from->typeinfo->draw_buttons || node_from->typeinfo->draw_buttons_ex) node_from = NULL; if (node_prev && node_prev->type == type && node_link_item_compare(node_prev, item)) { @@ -586,13 +586,13 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - if (node->typeinfo->uifunc) { + if (node->typeinfo->draw_buttons) { if (node->type != NODE_GROUP) { split = uiLayoutSplit(layout, 0.35f, FALSE); col = uiLayoutColumn(split, FALSE); col = uiLayoutColumn(split, FALSE); - node->typeinfo->uifunc(col, C, &nodeptr); + node->typeinfo->draw_buttons(col, C, &nodeptr); } } @@ -639,7 +639,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, if (depth > 0) { uiBlockSetEmboss(block, UI_EMBOSSN); - if (lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) { + if (lnode && (lnode->inputs.first || (lnode->typeinfo->draw_buttons && lnode->type != NODE_GROUP))) { int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); } -- cgit v1.2.3 From 3b7d5a8a405e4a2e5fbb0e7cd89d50306db17c27 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 10 Oct 2013 12:58:35 +0000 Subject: Change to node output socket drawing: Instead of always drawing only the socket label for outputs, leave this check up to the socket type draw function. This gives custom node scripts more flexibility in how to draw socket values by allowing buttons on output sockets as well. http://wiki.blender.org/index.php/Extensions:2.6/Py/API_Changes#Python_Node_Output_Drawing --- source/blender/editors/space_node/drawnode.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b348156bc1f..ae2fed91131 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -86,18 +86,12 @@ static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, Poin uiItemL(layout, text, 0); } -static void node_draw_input_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) +static void node_draw_socket_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) { bNodeSocket *sock = (bNodeSocket *)ptr->data; sock->typeinfo->draw(C, layout, ptr, node_ptr, IFACE_(sock->name)); } -static void node_draw_output_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) -{ - bNodeSocket *sock = ptr->data; - node_socket_button_label(C, layout, ptr, node_ptr, IFACE_(sock->name)); -} - /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ @@ -2752,8 +2746,8 @@ void ED_node_init_butfuncs(void) NodeTypeUndefined.tweak_area_func = node_tweak_area_default; NodeTypeUndefined.draw_buttons = NULL; NodeTypeUndefined.draw_buttons_ex = NULL; - NodeTypeUndefined.draw_input = node_draw_input_default; - NodeTypeUndefined.draw_output = node_draw_output_default; + NodeTypeUndefined.draw_input = node_draw_socket_default; + NodeTypeUndefined.draw_output = node_draw_socket_default; NodeTypeUndefined.resize_area_func = node_resize_area_default; NodeSocketTypeUndefined.draw = node_socket_undefined_draw; @@ -2770,8 +2764,8 @@ void ED_node_init_butfuncs(void) ntype->tweak_area_func = node_tweak_area_default; ntype->draw_buttons = NULL; ntype->draw_buttons_ex = NULL; - ntype->draw_input = node_draw_input_default; - ntype->draw_output = node_draw_output_default; + ntype->draw_input = node_draw_socket_default; + ntype->draw_output = node_draw_socket_default; ntype->resize_area_func = node_resize_area_default; node_common_set_butfunc(ntype); @@ -2795,8 +2789,8 @@ void ED_init_custom_node_type(bNodeType *ntype) /* default ui functions */ ntype->draw_nodetype = node_draw_default; ntype->draw_nodetype_prepare = node_update_default; - ntype->draw_input = node_draw_input_default; - ntype->draw_output = node_draw_output_default; + ntype->draw_input = node_draw_socket_default; + ntype->draw_output = node_draw_socket_default; ntype->resize_area_func = node_resize_area_default; ntype->select_area_func = node_select_area_default; ntype->tweak_area_func = node_tweak_area_default; @@ -2840,7 +2834,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ - if ((sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) { + if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) { node_socket_button_label(C, layout, ptr, node_ptr, text); return; } -- cgit v1.2.3 From 906111cb22fff9332728e5e8f8271a0a4a908cfe Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 10 Oct 2013 13:07:09 +0000 Subject: Get rid of the draw_input/draw_output callbacks for nodes. These are pretty useless wrappers around socket draw functions. Only use-case is the File Output node, which draws socket format type instead of an input value. This is now a special case in the standard socket type drawing, but should eventually become a socket type of its own for the File Output node. --- source/blender/editors/space_node/drawnode.c | 100 ++++++++++++-------------- source/blender/editors/space_node/node_draw.c | 6 +- 2 files changed, 51 insertions(+), 55 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ae2fed91131..ba28f502349 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -86,12 +86,6 @@ static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, Poin uiItemL(layout, text, 0); } -static void node_draw_socket_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) -{ - bNodeSocket *sock = (bNodeSocket *)ptr->data; - sock->typeinfo->draw(C, layout, ptr, node_ptr, IFACE_(sock->name)); -} - /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ @@ -1572,46 +1566,6 @@ static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), Po uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); } -/* draw function for file output node sockets, displays only sub-path and format, no value button */ -static void node_draw_input_file_output(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) -{ - bNodeTree *ntree = ptr->id.data; - bNodeSocket *sock = ptr->data; - uiLayout *row; - PointerRNA inputptr, imfptr; - int imtype; - - row = uiLayoutRow(layout, FALSE); - - imfptr = RNA_pointer_get(node_ptr, "format"); - imtype = RNA_enum_get(&imfptr, "file_format"); - if (imtype == R_IMF_IMTYPE_MULTILAYER) { - NodeImageMultiFileSocket *input = sock->storage; - RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); - - uiItemL(row, input->layer, ICON_NONE); - } - else { - NodeImageMultiFileSocket *input = sock->storage; - PropertyRNA *imtype_prop; - const char *imtype_name; - uiBlock *block; - RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); - - uiItemL(row, input->path, ICON_NONE); - - if (!RNA_boolean_get(&inputptr, "use_node_format")) - imfptr = RNA_pointer_get(&inputptr, "format"); - - imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); - RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, - RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); - block = uiLayoutGetBlock(row); - uiBlockSetEmboss(block, UI_EMBOSSP); - uiItemL(row, imtype_name, ICON_NONE); - uiBlockSetEmboss(block, UI_EMBOSSN); - } -} static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { PointerRNA imfptr = RNA_pointer_get(ptr, "format"); @@ -2382,7 +2336,6 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_OUTPUT_FILE: ntype->draw_buttons = node_composit_buts_file_output; ntype->draw_buttons_ex = node_composit_buts_file_output_ex; - ntype->draw_input = node_draw_input_file_output; break; case CMP_NODE_DIFF_MATTE: ntype->draw_buttons = node_composit_buts_diff_matte; @@ -2746,8 +2699,6 @@ void ED_node_init_butfuncs(void) NodeTypeUndefined.tweak_area_func = node_tweak_area_default; NodeTypeUndefined.draw_buttons = NULL; NodeTypeUndefined.draw_buttons_ex = NULL; - NodeTypeUndefined.draw_input = node_draw_socket_default; - NodeTypeUndefined.draw_output = node_draw_socket_default; NodeTypeUndefined.resize_area_func = node_resize_area_default; NodeSocketTypeUndefined.draw = node_socket_undefined_draw; @@ -2764,8 +2715,6 @@ void ED_node_init_butfuncs(void) ntype->tweak_area_func = node_tweak_area_default; ntype->draw_buttons = NULL; ntype->draw_buttons_ex = NULL; - ntype->draw_input = node_draw_socket_default; - ntype->draw_output = node_draw_socket_default; ntype->resize_area_func = node_resize_area_default; node_common_set_butfunc(ntype); @@ -2789,8 +2738,6 @@ void ED_init_custom_node_type(bNodeType *ntype) /* default ui functions */ ntype->draw_nodetype = node_draw_default; ntype->draw_nodetype_prepare = node_update_default; - ntype->draw_input = node_draw_socket_default; - ntype->draw_output = node_draw_socket_default; ntype->resize_area_func = node_resize_area_default; ntype->select_area_func = node_select_area_default; ntype->tweak_area_func = node_tweak_area_default; @@ -2828,12 +2775,59 @@ static void std_node_socket_interface_draw_color(bContext *UNUSED(C), PointerRNA copy_v4_v4(r_color, std_node_socket_colors[type]); } +/* draw function for file output node sockets, displays only sub-path and format, no value button */ +static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) +{ + bNodeTree *ntree = ptr->id.data; + bNodeSocket *sock = ptr->data; + uiLayout *row; + PointerRNA inputptr, imfptr; + int imtype; + + row = uiLayoutRow(layout, FALSE); + + imfptr = RNA_pointer_get(node_ptr, "format"); + imtype = RNA_enum_get(&imfptr, "file_format"); + if (imtype == R_IMF_IMTYPE_MULTILAYER) { + NodeImageMultiFileSocket *input = sock->storage; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); + + uiItemL(row, input->layer, ICON_NONE); + } + else { + NodeImageMultiFileSocket *input = sock->storage; + PropertyRNA *imtype_prop; + const char *imtype_name; + uiBlock *block; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); + + uiItemL(row, input->path, ICON_NONE); + + if (!RNA_boolean_get(&inputptr, "use_node_format")) + imfptr = RNA_pointer_get(&inputptr, "format"); + + imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); + RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, + RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); + block = uiLayoutGetBlock(row); + uiBlockSetEmboss(block, UI_EMBOSSP); + uiItemL(row, imtype_name, ICON_NONE); + uiBlockSetEmboss(block, UI_EMBOSSN); + } +} + static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text) { + bNode *node = node_ptr->data; bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ + /* XXX not nice, eventually give this node its own socket type ... */ + if (node->type == CMP_NODE_OUTPUT_FILE) { + node_file_output_socket_draw(C, layout, ptr, node_ptr); + } + if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) { node_socket_button_label(C, layout, ptr, node_ptr, text); return; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 3196e4cc6af..65eb75f8523 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -351,7 +351,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); - node->typeinfo->draw_output((bContext *)C, row, &sockptr, &nodeptr); + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); @@ -437,7 +437,9 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - node->typeinfo->draw_input((bContext *)C, layout, &sockptr, &nodeptr); + row = uiLayoutRow(layout, 1); + + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); uiBlockEndAlign(node->block); uiBlockLayoutResolve(node->block, NULL, &buty); -- cgit v1.2.3 From 8fd52b34330354f5a8d285fd0888ffe7e72895b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 17:28:01 +0000 Subject: style cleanup --- source/blender/editors/sculpt_paint/paint_cursor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index e1a2f645dfa..99339cea995 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -89,7 +89,7 @@ static TexSnapshot secondary_snap = {0}; static CursorSnapshot cursor_snap = {0}; /* delete overlay cursor textures to preserve memory and invalidate all overlay flags */ -void paint_cursor_delete_textures() +void paint_cursor_delete_textures(void) { glDeleteTextures(1, &primary_snap.overlay_texture); glDeleteTextures(1, &secondary_snap.overlay_texture); -- cgit v1.2.3 From e220d3228f48d4cb3256b398b45b40bf6892e550 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 18:18:13 +0000 Subject: add MEM_SIZE_OPTIMAL to avoid memory fragmentation & waste lost to slop-space. --- source/blender/editors/mesh/editmesh_knife.c | 4 ++-- source/blender/editors/sculpt_paint/paint_image_proj.c | 6 +++--- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/editors/uvedit/uvedit_parametrizer.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 5e88ecabd35..9d8b283fe1a 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2131,7 +2131,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) facenet_entry *entry; ListBase *face_nets = MEM_callocN(sizeof(ListBase) * bm->totface, "face_nets"); BMFace **faces = MEM_callocN(sizeof(BMFace *) * bm->totface, "faces knife"); - MemArena *arena = BLI_memarena_new(1 << 16, "knifenet_fill_faces"); + MemArena *arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "knifenet_fill_faces"); SmallHash shash; RNG *rng; int i, j, k = 0, totface = bm->totface; @@ -3159,7 +3159,7 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN), kcd->cagecos, false); - kcd->arena = BLI_memarena_new(1 << 15, "knife"); + kcd->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), "knife"); kcd->vthresh = KMAXDIST - 1; kcd->ethresh = KMAXDIST; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index c90f9756707..4a2046f6682 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -3129,7 +3129,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->thread_tot = 1; for (a = 0; a < ps->thread_tot; a++) { - ps->arena_mt[a] = BLI_memarena_new(1 << 16, "project paint arena"); + ps->arena_mt[a] = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "project paint arena"); } arena = ps->arena_mt[0]; @@ -3841,10 +3841,10 @@ static void *do_projectpaint_thread(void *ph_v) pos_ofs[0] = pos[0] - lastpos[0]; pos_ofs[1] = pos[1] - lastpos[1]; - smearArena = BLI_memarena_new(1 << 16, "paint smear arena"); + smearArena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "paint smear arena"); } else if (tool == PAINT_TOOL_SOFTEN) { - softenArena = BLI_memarena_new(1 << 16, "paint soften arena"); + softenArena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "paint soften arena"); } /* printf("brush bounds %d %d %d %d\n", bucketMin[0], bucketMin[1], bucketMax[0], bucketMax[1]); */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index c3f1e38b663..1c3caf5d8bc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2788,7 +2788,7 @@ static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me) int *origIndex; int i; - vd->polyfacemap_arena = BLI_memarena_new(1 << 13, "vpaint tmp"); + vd->polyfacemap_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "vpaint tmp"); BLI_memarena_use_calloc(vd->polyfacemap_arena); vd->polyfacemap = BLI_memarena_alloc(vd->polyfacemap_arena, sizeof(ListBase) * me->totpoly); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index b8a54c56c63..2d33a2d3937 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -4123,7 +4123,7 @@ static void p_smooth(PChart *chart) MEM_freeN(nodesx); MEM_freeN(nodesy); - arena = BLI_memarena_new(1 << 16, "param smooth arena"); + arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param smooth arena"); root = p_node_new(arena, tri, esize * 2, minv, maxv, 0); for (v = chart->verts; v; v = v->nextlink) @@ -4143,7 +4143,7 @@ ParamHandle *param_construct_begin(void) PHandle *handle = MEM_callocN(sizeof(*handle), "PHandle"); handle->construction_chart = p_chart_new(handle); handle->state = PHANDLE_STATE_ALLOCATED; - handle->arena = BLI_memarena_new((1 << 16), "param construct arena"); + handle->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param construct arena"); handle->aspx = 1.0f; handle->aspy = 1.0f; handle->do_aspect = FALSE; -- cgit v1.2.3 From afab39b9d6a4b3283c42c5b6d7d787fda56327de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 20:22:17 +0000 Subject: code cleanup: use const's for static arrays --- source/blender/editors/curve/editcurve_add.c | 2 +- source/blender/editors/space_view3d/drawarmature.c | 16 ++++++++-------- source/blender/editors/transform/transform_ops.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 0bcb550b930..9b858a2c4e9 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -58,7 +58,7 @@ #include "curve_intern.h" -static float nurbcircle[8][2] = { +static const float nurbcircle[8][2] = { {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0}, {0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0} }; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 2634dd3ec08..de6fafb2cd8 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -304,7 +304,7 @@ static void set_ebone_glColor(const unsigned int boneflag) /* *************** Armature drawing, helper calls for parts ******************* */ /* half the cube, in Y */ -static float cube[8][3] = { +static const float cube[8][3] = { {-1.0, 0.0, -1.0}, {-1.0, 0.0, 1.0}, {-1.0, 1.0, 1.0}, @@ -440,7 +440,7 @@ static void draw_bonevert_solid(void) glCallList(displist); } -static float bone_octahedral_verts[6][3] = { +static const float bone_octahedral_verts[6][3] = { { 0.0f, 0.0f, 0.0f}, { 0.1f, 0.1f, 0.1f}, { 0.1f, 0.1f, -0.1f}, @@ -449,10 +449,10 @@ static float bone_octahedral_verts[6][3] = { { 0.0f, 1.0f, 0.0f} }; -static unsigned int bone_octahedral_wire_sides[8] = {0, 1, 5, 3, 0, 4, 5, 2}; -static unsigned int bone_octahedral_wire_square[8] = {1, 2, 3, 4, 1}; +static const unsigned int bone_octahedral_wire_sides[8] = {0, 1, 5, 3, 0, 4, 5, 2}; +static const unsigned int bone_octahedral_wire_square[8] = {1, 2, 3, 4, 1}; -static unsigned int bone_octahedral_solid_tris[8][3] = { +static const unsigned int bone_octahedral_solid_tris[8][3] = { {2, 1, 0}, /* bottom */ {3, 2, 0}, {4, 3, 0}, @@ -465,7 +465,7 @@ static unsigned int bone_octahedral_solid_tris[8][3] = { }; /* aligned with bone_octahedral_solid_tris */ -static float bone_octahedral_solid_normals[8][3] = { +static const float bone_octahedral_solid_normals[8][3] = { { 0.70710683f, -0.70710683f, 0.00000000f}, {-0.00000000f, -0.70710683f, -0.70710683f}, {-0.70710683f, -0.70710683f, 0.00000000f}, @@ -599,7 +599,7 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, } /* 16 values of sin function (still same result!) */ -static float si[16] = { +static const float si[16] = { 0.00000000f, 0.20129852f, 0.39435585f, 0.57126821f, 0.72479278f, @@ -611,7 +611,7 @@ static float si[16] = { 0.10116832f }; /* 16 values of cos function (still same result!) */ -static float co[16] = { +static const float co[16] = { 1.00000000f, 0.97952994f, 0.91895781f, 0.82076344f, 0.68896691f, diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index e7c22fc0899..2904b37c2e5 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -60,7 +60,7 @@ typedef struct TransformModeItem { void (*opfunc)(wmOperatorType *); } TransformModeItem; -static float VecOne[3] = {1, 1, 1}; +static const float VecOne[3] = {1, 1, 1}; static char OP_TRANSLATION[] = "TRANSFORM_OT_translate"; static char OP_ROTATION[] = "TRANSFORM_OT_rotate"; -- cgit v1.2.3 From cb6e795a47db6f86c6592480a0743eaae33900d4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 20:23:24 +0000 Subject: fix [#37031] bones are not selectable in weight paint mode anymore --- source/blender/editors/sculpt_paint/paint_intern.h | 1 + source/blender/editors/sculpt_paint/paint_ops.c | 11 +++++++++-- source/blender/editors/sculpt_paint/paint_stroke.c | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 607edcab9f8..2545328ec65 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -74,6 +74,7 @@ bool paint_space_stroke_enabled(struct Brush *br, enum PaintMode mode); bool paint_supports_dynamic_size(struct Brush *br, enum PaintMode mode); bool paint_supports_dynamic_tex_coords(struct Brush *br, enum PaintMode mode); bool paint_supports_smooth_stroke(struct Brush *br, enum PaintMode mode); +bool paint_supports_texture(enum PaintMode mode); bool paint_supports_jitter(enum PaintMode mode); struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 0b0607babc1..8b038973831 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -728,9 +728,16 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve static int stencil_control_poll(bContext *C) { - Paint *paint = BKE_paint_get_active_from_context(C); - Brush *br = BKE_paint_brush(paint); + PaintMode mode = BKE_paintmode_get_active_from_context(C); + + Paint *paint; + Brush *br; + + if (!paint_supports_texture(mode)) + return false; + paint = BKE_paint_get_active_from_context(C); + br = BKE_paint_brush(paint); return (br && (br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL || br->mask_mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL)); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 973f6555deb..b00b1c3ecff 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -572,6 +572,12 @@ bool paint_supports_smooth_stroke(Brush *br, PaintMode mode) return true; } +bool paint_supports_texture(PaintMode mode) +{ + /* ommit: PAINT_WEIGHT, PAINT_SCULPT_UV, PAINT_INVALID */ + return ELEM4(mode, PAINT_SCULPT, PAINT_VERTEX, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D); +} + /* return true if the brush size can change during paint (normally used for pressure) */ bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode) { -- cgit v1.2.3 From ecc5eb59c64ac8fd14ac3adc43d05499e88e81d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 21:04:39 +0000 Subject: fix [#37030] Loop Cut and Slide doesn't clear header text if you click a blank area --- source/blender/editors/mesh/editmesh_loopcut.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 892b773b1ba..ae1007cb98a 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -537,7 +537,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_PRESS) { /* finish */ ED_region_tag_redraw(lcd->ar); - + ED_area_headerprint(CTX_wm_area(C), NULL); + if (lcd->eed) { /* set for redo */ BM_mesh_elem_index_ensure(lcd->em->bm, BM_EDGE); @@ -550,9 +551,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) else { return ringcut_cancel(C, op); } - - ED_area_headerprint(CTX_wm_area(C), NULL); - + return OPERATOR_FINISHED; } -- cgit v1.2.3 From 03602dc158de1a2fa7d88c91b0323aaaabb2c246 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 22:30:16 +0000 Subject: use BLI_bitmap for editmesh selection buffer to save some memory. --- source/blender/editors/include/ED_mesh.h | 2 +- source/blender/editors/mesh/editmesh_select.c | 37 +++++++++++++++------- .../blender/editors/space_view3d/view3d_select.c | 6 ++-- 3 files changed, 29 insertions(+), 16 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index b7fd181883b..5d3d72d0e3d 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -152,7 +152,7 @@ void EDBM_select_mirrored(struct BMEditMesh *em, bool extend, void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag); bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); -int EDBM_backbuf_check(unsigned int index); +bool EDBM_backbuf_check(unsigned int index); void EDBM_backbuf_free(void); bool EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2], short tot, diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 4d512fab1c0..094e9f0f72b 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_bitmap.h" #include "BLI_listbase.h" #include "BLI_linklist.h" #include "BLI_linklist_stack.h" @@ -184,7 +185,12 @@ void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag) unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0; /* set in drawobject.c ... for colorindices */ /* facilities for border select and circle select */ -static char *selbuf = NULL; +static BLI_bitmap *selbuf = NULL; + +static BLI_bitmap *edbm_backbuf_alloc(const int size) +{ + return BLI_BITMAP_NEW(size, "selbuf"); +} /* reads rect, and builds selection array for quick lookup */ /* returns if all is OK */ @@ -205,28 +211,31 @@ bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xma dr = buf->rect; /* build selection lookup */ - selbuf = MEM_callocN(bm_vertoffs + 1, "selbuf"); + selbuf = edbm_backbuf_alloc(bm_vertoffs + 1); a = (xmax - xmin + 1) * (ymax - ymin + 1); while (a--) { - if (*dr > 0 && *dr <= bm_vertoffs) - selbuf[*dr] = 1; + if (*dr > 0 && *dr <= bm_vertoffs) { + BLI_BITMAP_SET(selbuf, *dr); + } dr++; } IMB_freeImBuf(buf); return true; } -int EDBM_backbuf_check(unsigned int index) +bool EDBM_backbuf_check(unsigned int index) { /* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled * and just ignore the depth buffer, this is error prone since its possible * code doesn't set the depth buffer by accident, but leave for now. - Campbell */ - if (selbuf == NULL) return 1; + if (selbuf == NULL) + return true; if (index > 0 && index <= bm_vertoffs) - return selbuf[index]; - return 0; + return BLI_BITMAP_GET_BOOL(selbuf, index); + + return false; } void EDBM_backbuf_free(void) @@ -286,11 +295,13 @@ bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short edbm_mask_lasso_px_cb, &lasso_mask_data); /* build selection lookup */ - selbuf = MEM_callocN(bm_vertoffs + 1, "selbuf"); + selbuf = edbm_backbuf_alloc(bm_vertoffs + 1); a = (xmax - xmin + 1) * (ymax - ymin + 1); while (a--) { - if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) selbuf[*dr] = 1; + if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) { + BLI_BITMAP_SET(selbuf, *dr); + } dr++; dr_mask++; } IMB_freeImBuf(buf); @@ -326,12 +337,14 @@ bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) dr = buf->rect; /* build selection lookup */ - selbuf = MEM_callocN(bm_vertoffs + 1, "selbuf"); + selbuf = edbm_backbuf_alloc(bm_vertoffs + 1); radsq = rads * rads; for (yc = -rads; yc <= rads; yc++) { for (xc = -rads; xc <= rads; xc++, dr++) { if (xc * xc + yc * yc < radsq) { - if (*dr > 0 && *dr <= bm_vertoffs) selbuf[*dr] = 1; + if (*dr > 0 && *dr <= bm_vertoffs) { + BLI_BITMAP_SET(selbuf, *dr); + } } } } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 66af2ccb417..c48ce8a2343 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -160,7 +160,7 @@ static void edbm_backbuf_check_and_select_edges(BMEditMesh *em, const bool selec { BMEdge *eed; BMIter iter; - int index = bm_solidoffs; + unsigned int index = bm_solidoffs; BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { @@ -288,12 +288,12 @@ static int view3d_selectable_data(bContext *C) /* helper also for borderselect */ -static int edge_fully_inside_rect(const rctf *rect, const float v1[2], const float v2[2]) +static bool edge_fully_inside_rect(const rctf *rect, const float v1[2], const float v2[2]) { return BLI_rctf_isect_pt_v(rect, v1) && BLI_rctf_isect_pt_v(rect, v2); } -static int edge_inside_rect(const rctf *rect, const float v1[2], const float v2[2]) +static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2[2]) { int d1, d2, d3, d4; -- cgit v1.2.3 From 3f5be1ef0a8fe4bb6ebf3610c2928087e9375a9c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2013 23:18:37 +0000 Subject: fix for select linked walking over the same faces multiple times. (caused gset assertion). --- source/blender/editors/mesh/editmesh_select.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 094e9f0f72b..f975d801d10 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1856,7 +1856,6 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; BMIter iter; - BMVert *v; BMEdge *e; BMWalker walker; @@ -1870,8 +1869,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BMFace *efa; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - BM_elem_flag_set(efa, BM_ELEM_TAG, (BM_elem_flag_test(efa, BM_ELEM_SELECT) && - !BM_elem_flag_test(efa, BM_ELEM_HIDDEN))); + BM_elem_flag_set(efa, BM_ELEM_TAG, BM_elem_flag_test(efa, BM_ELEM_SELECT)); } if (limit) { @@ -1891,6 +1889,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) { BM_face_select_set(bm, efa, true); + BM_elem_flag_disable(efa, BM_ELEM_TAG); } } } @@ -1901,13 +1900,10 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) } } else { + BMVert *v; + BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { - BM_elem_flag_enable(v, BM_ELEM_TAG); - } - else { - BM_elem_flag_disable(v, BM_ELEM_TAG); - } + BM_elem_flag_set(v, BM_ELEM_TAG, BM_elem_flag_test(v, BM_ELEM_SELECT)); } BMW_init(&walker, em->bm, BMW_SHELL, @@ -1919,6 +1915,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) if (BM_elem_flag_test(v, BM_ELEM_TAG)) { for (e = BMW_begin(&walker, v); e; e = BMW_step(&walker)) { BM_edge_select_set(em->bm, e, true); + BM_elem_flag_disable(e, BM_ELEM_TAG); } } } -- cgit v1.2.3 From 187f664c7587d0d8f13b0e71bcc38dc2d7f97693 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 10 Oct 2013 23:33:59 +0000 Subject: Fix #37036, pack and refresh button not aligned anymore. Also add operator for opening images in the image editor header, it's easily one of the most common operations, don't see why it has to be only accessed from menu. --- source/blender/editors/space_image/image_buttons.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 144d2c14e9f..3ff404d38a9 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -640,7 +640,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - row = uiLayoutRow(row, FALSE); + row = uiLayoutRow(row, TRUE); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); -- cgit v1.2.3 From 31d492815e59e5b11b62521da1f97a8d9dd87cec Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Fri, 11 Oct 2013 02:23:20 +0000 Subject: Fix #36905: backport of fix in soc-2013-paint. This commit ensures that during color sampling the cursor of the current brush is disabled. This avoids sampling of the brush cursor for really small brushes. Only caveat is that if operator exec is called then cursor might be visible in new sample location. This is not so common though. --- source/blender/editors/sculpt_paint/paint_image.c | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 34603d7516c..a5d4ff98b4b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -926,9 +926,15 @@ void PAINT_OT_grab_clone(wmOperatorType *ot) } /******************** sample color operator ********************/ +typedef struct { + bool show_cursor; + short event_type; +} SampleColorData; + static int sample_color_exec(bContext *C, wmOperator *op) { - Brush *brush = image_paint_brush(C); + Paint *paint = BKE_paint_get_active_from_context(C); + Brush *brush = BKE_paint_brush(paint); ARegion *ar = CTX_wm_region(C); int location[2]; @@ -942,11 +948,17 @@ static int sample_color_exec(bContext *C, wmOperator *op) static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + Paint *paint = BKE_paint_get_active_from_context(C); + SampleColorData *data = MEM_mallocN(sizeof(SampleColorData), "sample color custom data"); + + data->event_type = event->type; + data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); + op->customdata = data; + paint->flags &= ~PAINT_SHOW_BRUSH; + RNA_int_set_array(op->ptr, "location", event->mval); sample_color_exec(C, op); - op->customdata = SET_INT_IN_POINTER(event->type); - WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -954,8 +966,18 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type == (intptr_t)(op->customdata) && event->val == KM_RELEASE) + SampleColorData *data = op->customdata; + + if ((event->type == data->event_type) && (event->val == KM_RELEASE)) { + Paint *paint = BKE_paint_get_active_from_context(C); + + if(data->show_cursor) { + paint->flags |= PAINT_SHOW_BRUSH; + } + + MEM_freeN(data); return OPERATOR_FINISHED; + } switch (event->type) { case MOUSEMOVE: -- cgit v1.2.3 From 76c94972da8b6b3c6fc4c491dee1f491b0da3ece Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 11 Oct 2013 12:50:19 +0000 Subject: Fix [#37039] Resize lists by new grab handles puts file into unsaved state. Simply do not enable undo for LISTBOX buttons (the same as ROUNDBOX & co). Many thanks to Campbell who did all the work here! --- source/blender/editors/interface/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 91e5f2fe61d..4fc2fb9ab95 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2874,7 +2874,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } /* keep track of UI_interface.h */ - if (ELEM8(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, BUTM, SCROLL, SEPR)) {} + if (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR)) {} else if (but->type >= SEARCH_MENU) {} else but->flag |= UI_BUT_UNDO; -- cgit v1.2.3 From 029f4b9767d149f10317d060fcc521b8b994c6d5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 11 Oct 2013 16:38:04 +0000 Subject: adding WITH_IMAGE_OPENIMAGEIO and removing the PSD build option As per Brecht van Lommel's suggestion. --- source/blender/editors/space_file/CMakeLists.txt | 4 ++-- source/blender/editors/space_image/CMakeLists.txt | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 74f3a425c25..ccf8576d621 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -58,8 +58,8 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() -if(WITH_IMAGE_PSD) - add_definitions(-DWITH_PSD) +if(WITH_OPENIMAGEIO) + add_definitions(-DWITH_OPENIMAGEIO) endif() if(WITH_IMAGE_TIFF) diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index fdc1960d128..50d8051a73e 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -50,6 +50,10 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +if(WITH_OPENIMAGEIO) + add_definitions(-DWITH_OPENIMAGEIO) +endif() + if(WITH_IMAGE_OPENJPEG) add_definitions(-DWITH_OPENJPEG) endif() @@ -58,9 +62,6 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() -if(WITH_IMAGE_PSD) - add_definitions(-DWITH_PSD) -endif() if(WITH_IMAGE_TIFF) add_definitions(-DWITH_TIFF) endif() -- cgit v1.2.3 From b83f755542ca97c025c42bfb0143e78c7cda670f Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Fri, 11 Oct 2013 19:44:56 +0000 Subject: Fix [#37049] Default keybindings: Text editor auto-complete accepts Return, but not Numpad Enter --- source/blender/editors/space_text/text_autocomplete.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index ba61399f6d5..eaba537c0a8 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -361,6 +361,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e } break; case RETKEY: + case PADENTER: if (event->val == KM_PRESS) { if (tools & TOOL_SUGG_LIST) { confirm_suggestion(st->text); -- cgit v1.2.3 From 90cd0a37a9c84964dd0daac3f553800e529fae29 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Fri, 11 Oct 2013 23:14:01 +0000 Subject: Fix build scripts related to PSD support. Both CMake and SCons builds were broken. --- source/blender/editors/space_file/CMakeLists.txt | 2 +- source/blender/editors/space_image/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index ccf8576d621..ce0b08c6708 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -58,7 +58,7 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() -if(WITH_OPENIMAGEIO) +if(WITH_IMAGE_OPENIMAGEIO) add_definitions(-DWITH_OPENIMAGEIO) endif() diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 50d8051a73e..2f78818d012 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -50,7 +50,7 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -if(WITH_OPENIMAGEIO) +if(WITH_IMAGE_OPENIMAGEIO) add_definitions(-DWITH_OPENIMAGEIO) endif() -- cgit v1.2.3 From 312795225995e93ac47c462c0a4c062c9719592a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 12 Oct 2013 00:08:33 +0000 Subject: Fix crash running Blender in background mode, caused by revision 60633. --- source/blender/editors/sculpt_paint/paint_cursor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 99339cea995..56143d00afe 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -91,9 +91,12 @@ static CursorSnapshot cursor_snap = {0}; /* delete overlay cursor textures to preserve memory and invalidate all overlay flags */ void paint_cursor_delete_textures(void) { - glDeleteTextures(1, &primary_snap.overlay_texture); - glDeleteTextures(1, &secondary_snap.overlay_texture); - glDeleteTextures(1, &cursor_snap.overlay_texture); + if (primary_snap.overlay_texture) + glDeleteTextures(1, &primary_snap.overlay_texture); + if (secondary_snap.overlay_texture) + glDeleteTextures(1, &secondary_snap.overlay_texture); + if (cursor_snap.overlay_texture) + glDeleteTextures(1, &cursor_snap.overlay_texture); memset(&primary_snap, 0, sizeof(TexSnapshot)); memset(&secondary_snap, 0, sizeof(TexSnapshot)); -- cgit v1.2.3 From b6db417ee466c6aec5d412a259a6dc7c0b4c1750 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Oct 2013 02:19:37 +0000 Subject: code cleanup: use const's for vector args. --- source/blender/editors/mesh/editmesh_extrude.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 4 ++-- source/blender/editors/space_view3d/view3d_draw.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 300fb67ec80..3df4ad738ae 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -290,7 +290,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) //BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "extrude_face_region geom=%hef", BM_ELEM_SELECT); BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "translate vec=%v verts=%hv", - (float *)dvec, BM_ELEM_SELECT); + dvec, BM_ELEM_SELECT); //extrudeflag(obedit, em, SELECT, nor); //translateflag(em, SELECT, dvec); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 23b80fc5bea..3e27346f9fe 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2043,7 +2043,7 @@ static void draw_dm_face_normals__mapFunc(void *userData, int index, const float if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (!data->uniform_scale) { - mul_v3_m3v3(n, data->tmat, (float *) no); + mul_v3_m3v3(n, data->tmat, no); normalize_v3(n); mul_m3_v3(data->imat, n); } @@ -2108,7 +2108,7 @@ static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float } if (!data->uniform_scale) { - mul_v3_m3v3(n, data->tmat, (float *) no); + mul_v3_m3v3(n, data->tmat, no); normalize_v3(n); mul_m3_v3(data->imat, n); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b737dba1a3b..24edfb413c8 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -113,9 +113,9 @@ static void star_stuff_init_func(void) glPointSize(1.0); glBegin(GL_POINTS); } -static void star_stuff_vertex_func(float *i) +static void star_stuff_vertex_func(const float vec[3]) { - glVertex3fv(i); + glVertex3fv(vec); } static void star_stuff_term_func(void) { -- cgit v1.2.3 From 7998b2f6a7a78cd8d7af135460a50b972cbc2b2d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Oct 2013 03:42:06 +0000 Subject: transform - use 2d float's for the viewport center (allows for vector math functions to be used more easily). --- source/blender/editors/include/ED_transform.h | 2 +- source/blender/editors/mesh/editmesh_bevel.c | 2 +- source/blender/editors/mesh/editmesh_inset.c | 2 +- source/blender/editors/transform/transform.c | 8 ++++---- source/blender/editors/transform/transform.h | 6 +++--- source/blender/editors/transform/transform_generics.c | 8 ++++---- source/blender/editors/transform/transform_input.c | 2 +- source/blender/editors/util/ed_util.c | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 81308dd84f2..eff79b6a039 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -103,7 +103,7 @@ enum TfmMode { * returns 1 if successful, 0 otherwise (usually means there's no selection) * (if 0 is returns, *vec is unmodified) * */ -int calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3], int cent2d[2]); +int calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3], float cent2d[2]); struct TransInfo; struct ScrArea; diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 6033e7ee471..97da0047793 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -64,7 +64,7 @@ typedef struct { float shift_factor; /* The current factor when shift is pressed. Negative when shift not active. */ /* modal only */ - int mcenter[2]; + float mcenter[2]; BMBackup mesh_backup; void *draw_handle_pixel; short twtype; diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 3966826a5b2..71822868026 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -68,7 +68,7 @@ typedef struct { NumInput num_input; /* modal only */ - int mcenter[2]; + float mcenter[2]; BMBackup mesh_backup; void *draw_handle_pixel; short twtype; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ce2f07f1813..239d6297695 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1360,7 +1360,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) } } -int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int cent2d[2]) +int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2]) { TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data"); int success; @@ -1390,7 +1390,7 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int c calculateCenter(t); if (cent2d) { - copy_v2_v2_int(cent2d, t->center2d); + copy_v2_v2(cent2d, t->center2d); } if (cent3d) { @@ -7238,7 +7238,7 @@ int TimeSlide(TransInfo *t, const int mval[2]) void initTimeScale(TransInfo *t) { - int center[2]; + float center[2]; /* this tool is only really available in the Action Editor * AND NLA Editor (for strip scaling) @@ -7253,7 +7253,7 @@ void initTimeScale(TransInfo *t) /* recalculate center2d to use CFRA and mouse Y, since that's * what is used in time scale */ t->center[0] = t->scene->r.cfra; - projectIntView(t, t->center, center); + projectFloatView(t, t->center, center); center[1] = t->imval[1]; /* force a reinit with the center2d used here */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index a4828317604..9355773c47b 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -271,7 +271,7 @@ typedef struct MouseInput { int imval[2]; /* initial mouse position */ char precision; int precision_mval[2]; /* mouse position when precision key was pressed */ - int center[2]; + float center[2]; float factor; void *data; /* additional data, if needed by the particular function */ } MouseInput; @@ -300,7 +300,7 @@ typedef struct TransInfo { float prop_size; /* proportional circle radius */ char proptext[20]; /* proportional falloff text */ float center[3]; /* center of transformation */ - int center2d[2]; /* center in screen coordinates */ + float center2d[2]; /* center in screen coordinates */ int imval[2]; /* initial mouse position */ short event_type; /* event->type used to invoke transform */ short idx_max; /* maximum index on the input vector */ @@ -687,7 +687,7 @@ typedef enum { INPUT_CUSTOM_RATIO_FLIP } MouseInputMode; -void initMouseInput(TransInfo *t, MouseInput *mi, const int center[2], const int mval[2]); +void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2]); void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode); int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event); void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 233ef1d18a5..b6f031614ca 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1484,10 +1484,10 @@ void calculateCenter2D(TransInfo *t) copy_v3_v3(vec, t->center); mul_m4_v3(ob->obmat, vec); - projectIntView(t, vec, t->center2d); + projectFloatView(t, vec, t->center2d); } else { - projectIntView(t, t->center, t->center2d); + projectFloatView(t, t->center, t->center2d); } } @@ -1691,7 +1691,7 @@ void calculateCenter(TransInfo *t) Object *ob = OBACT; if (ob) { copy_v3_v3(t->center, ob->obmat[3]); - projectIntView(t, t->center, t->center2d); + projectFloatView(t, t->center, t->center2d); } } break; @@ -1723,7 +1723,7 @@ void calculateCenter(TransInfo *t) axis[1] = t->center[1] - 6.0f * axis[1]; axis[2] = t->center[2] - 6.0f * axis[2]; - projectIntView(t, axis, t->center2d); + projectFloatView(t, axis, t->center2d); /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */ if (t->mode == TFM_TRANSLATION) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index c035b6173c8..db214e1f6db 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -279,7 +279,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], output[0] = *angle; } -void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const int center[2], const int mval[2]) +void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const float center[2], const int mval[2]) { mi->factor = 0; mi->precision = 0; diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 35e6c40c36b..7424acd752f 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -258,7 +258,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info) { wmWindow *win = CTX_wm_window(C); - const int *mval_src = (int *)arg_info; + const float *mval_src = (float *)arg_info; const int mval_dst[2] = {win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin}; @@ -266,7 +266,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info setlinestyle(3); glBegin(GL_LINE_STRIP); glVertex2iv(mval_dst); - glVertex2iv(mval_src); + glVertex2fv(mval_src); glEnd(); setlinestyle(0); } -- cgit v1.2.3 From 6caacff196e65cbdfadebcb695f54a0bb3dea891 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Sat, 12 Oct 2013 06:11:26 +0000 Subject: More fixes for PSD support in SCons scirpts... --- source/blender/editors/space_file/SConscript | 3 +++ source/blender/editors/space_image/SConscript | 2 ++ 2 files changed, 5 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index e1eadb66a11..d42394454eb 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -55,6 +55,9 @@ if env['WITH_BF_OPENEXR']: if env['WITH_BF_TIFF']: defs.append('WITH_TIFF') +if env['WITH_BF_OIIO']: + defs.append('WITH_OPENIMAGEIO') + if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index 268172b300d..89def32e70f 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -57,6 +57,8 @@ if env['WITH_BF_TIFF']: defs.append('WITH_TIFF') if env['WITH_BF_CINEON']: defs.append('WITH_CINEON') +if env['WITH_BF_OIIO']: + defs.append('WITH_OPENIMAGEIO') if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] -- cgit v1.2.3 From b2d3b0244a8c7f98f74552c42071c8692df09609 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 12 Oct 2013 09:43:57 +0000 Subject: Fix obvious error in expanded enum layout code, given uiname would never be use... --- source/blender/editors/interface/interface_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 4e498476f5d..039556811d1 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -524,7 +524,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt if (!item->identifier[0]) continue; - name = (!uiname || uiname[0]) ? item->name : ""; + name = uiname ? uiname : item->name; icon = item->icon; value = item->value; itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0); -- cgit v1.2.3 From c7109b152eaf3c9e216fe5304a3f5daf55135da9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 12 Oct 2013 11:03:32 +0000 Subject: Followup to own r60700, fix was not correct... In fact, beahivor of expanded enums is not consistent with other properties, as there labels are never shown. Keep it for now, though, as this would break many scripts and ui file, better to do this in bulk! Thanks to DingTo and plasmasolutions for notifying the issue. --- source/blender/editors/interface/interface_layout.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 039556811d1..d5bcb40d5a4 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -503,7 +503,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) } } static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, - const char *uiname, int h, int icon_only) + const char *UNUSED(uiname), int h, int icon_only) { uiBut *but; EnumPropertyItem *item, *item_array; @@ -512,6 +512,14 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free); +#if 0 /* XXX This would be consistent with general uiItemR (i.e. layout.prop() in py) behavior. + * However, so far we never ever shown the label of an expanded enum prop, so for now disable this. + */ + if (uiname && uiname[0]) { + uiItemL(layout, uiname, ICON_NONE); + } +#endif + /* we dont want nested rows, cols in menus */ if (layout->root->type != UI_LAYOUT_MENU) { uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); @@ -524,7 +532,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt if (!item->identifier[0]) continue; - name = uiname ? uiname : item->name; + name = item->name; icon = item->icon; value = item->value; itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0); -- cgit v1.2.3 From e192f5b19834813a94abd31cb7b299d1b9351b7d Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sat, 12 Oct 2013 11:05:12 +0000 Subject: Fix #37047, Expanded Enum Alignment glitching. The enum item buttons in the node header change their alignr when switching the tree type, due to different things being shown in the header (this rarely happens in other panels, so it doesn't turn up easily). The new alignnr needs to be copied to existing block buttons in ui_but_update_from_old_block to ensure the enum items get aligned to each other. --- source/blender/editors/interface/interface.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4fc2fb9ab95..3bad2577409 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -662,6 +662,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut /* drawing */ oldbut->icon = but->icon; oldbut->iconadd = but->iconadd; + oldbut->alignnr = but->alignnr; /* typically the same pointers, but not on undo/redo */ /* XXX some menu buttons store button itself in but->poin. Ugly */ -- cgit v1.2.3 From 11f0e35236b9acf972826d65c9569c754920e0c3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 12 Oct 2013 11:28:37 +0000 Subject: Revert both own r60700 and r60702. API behavior for expanded enums is completly inconsistent, but again, better to do such changes (soft-breaking API) in bulk... --- .../blender/editors/interface/interface_layout.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index d5bcb40d5a4..b453a3b8363 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -503,8 +503,16 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) } } static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, - const char *UNUSED(uiname), int h, int icon_only) -{ + const char *uiname, int h, int icon_only) +{ + /* XXX The way this function currently handles uiname parameter is insane and inconsistent with general UI API: + * * uiname is the *enum property* label. + * * when it is NULL or empty, we do not draw *enum items* labels, this doubles the icon_only parameter. + * * we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag! + * Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/ + * --mont29 + */ + uiBut *but; EnumPropertyItem *item, *item_array; const char *name; @@ -512,14 +520,6 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free); -#if 0 /* XXX This would be consistent with general uiItemR (i.e. layout.prop() in py) behavior. - * However, so far we never ever shown the label of an expanded enum prop, so for now disable this. - */ - if (uiname && uiname[0]) { - uiItemL(layout, uiname, ICON_NONE); - } -#endif - /* we dont want nested rows, cols in menus */ if (layout->root->type != UI_LAYOUT_MENU) { uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); @@ -532,7 +532,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt if (!item->identifier[0]) continue; - name = item->name; + name = (!uiname || uiname[0]) ? item->name : ""; icon = item->icon; value = item->value; itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0); -- cgit v1.2.3 From f0dcff9aa982d32bcb91e594df49a780ac376b5b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 12 Oct 2013 14:08:59 +0000 Subject: Task scheduler ported form CYcles to C Replaces ThreadedWorker and is gonna to be used for threaded object update in the future and some more upcoming changes. But in general, it's to be used for any task based subsystem in Blender. Originally written by Brecht, with some fixes and tweaks by self. --- source/blender/editors/armature/BIF_retarget.h | 4 +- .../editors/armature/editarmature_retarget.c | 46 +++++++--------------- 2 files changed, 17 insertions(+), 33 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h index 2ea0e0ab0d7..21e85b6fe89 100644 --- a/source/blender/editors/armature/BIF_retarget.h +++ b/source/blender/editors/armature/BIF_retarget.h @@ -29,6 +29,7 @@ #include "BLI_graph.h" #include "BLI_ghash.h" +#include "BLI_task.h" #include "BLI_threads.h" #include "reeb.h" @@ -68,7 +69,8 @@ typedef struct RigGraph { ReebGraph *link_mesh; - struct ThreadedWorker *worker; + TaskScheduler *task_scheduler; + TaskPool *task_pool; GHash *bones_map; /* map of editbones by name */ GHash *controls_map; /* map of rigcontrols by bone pointer */ diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 687455495a1..c03e7861307 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -83,7 +83,7 @@ static RigGraph *GLOBAL_RIGG = NULL; /*******************************************************************************************************/ -void *exec_retargetArctoArc(void *param); +void exec_retargetArctoArc(TaskPool *pool, void *taskdata, int threadid); static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second); float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]); @@ -235,9 +235,8 @@ void RIG_freeRigGraph(BGraph *rg) BNode *node; BArc *arc; -#ifdef USE_THREADS - BLI_destroy_worker(rigg->worker); -#endif + BLI_task_pool_free(rigg->task_pool); + BLI_task_scheduler_free(rigg->task_scheduler); if (rigg->link_mesh) { REEB_freeGraph(rigg->link_mesh); @@ -284,12 +283,14 @@ static RigGraph *newRigGraph(void) rg->free_node = NULL; #ifdef USE_THREADS - //totthread = BKE_scene_num_threads(G.scene); - totthread = BLI_system_thread_count(); - - rg->worker = BLI_create_worker(exec_retargetArctoArc, totthread, 20); /* fix number of threads */ + totthread = TASK_SCHEDULER_AUTO_THREADS; +#else + totthread = TASK_SCHEDULER_SINGLE_THREAD; #endif - + + rg->task_scheduler = BLI_task_scheduler_create(totthread); + rg->task_pool = BLI_task_pool_create(rg->task_scheduler, NULL); + return rg; } @@ -2133,7 +2134,6 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start) { -#ifdef USE_THREADS RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam"); p->rigg = rigg; @@ -2141,22 +2141,12 @@ static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode p->inode_start = inode_start; p->context = C; - BLI_insert_work(rigg->worker, p); -#else - RetargetParam p; - - p.rigg = rigg; - p.iarc = iarc; - p.inode_start = inode_start; - p.context = C; - - exec_retargetArctoArc(&p); -#endif + BLI_task_pool_push(rigg->task_pool, exec_retargetArctoArc, p, true, TASK_PRIORITY_HIGH); } -void *exec_retargetArctoArc(void *param) +void exec_retargetArctoArc(TaskPool *UNUSED(pool), void *taskdata, int UNUSED(threadid)) { - RetargetParam *p = (RetargetParam *)param; + RetargetParam *p = (RetargetParam *)taskdata; RigGraph *rigg = p->rigg; RigArc *iarc = p->iarc; bContext *C = p->context; @@ -2183,12 +2173,6 @@ void *exec_retargetArctoArc(void *param) retargetArctoArcLength(C, rigg, iarc, inode_start); } } - -#ifdef USE_THREADS - MEM_freeN(p); -#endif - - return NULL; } static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *top_node) @@ -2414,9 +2398,7 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig static void finishRetarget(RigGraph *rigg) { -#ifdef USE_THREADS - BLI_end_worker(rigg->worker); -#endif + BLI_task_pool_work_and_wait(rigg->task_pool); } static void adjustGraphs(bContext *C, RigGraph *rigg) -- cgit v1.2.3 From d7983e3638896e5742fcf1bafe49c49a6b0aa08f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 12 Oct 2013 14:09:05 +0000 Subject: Option to overlay mask over the footage Currently supports only two modes: - Show alpha channel of the mask - Multiply footage by the mask, which will give you final-looking combined image. TODO: Currently rasterization happens on every redraw, need to cache rasterized mask somewhere to make redraw more realtime. --- source/blender/editors/include/ED_mask.h | 2 +- source/blender/editors/mask/mask_draw.c | 118 ++++++++++++++++++++- source/blender/editors/screen/glutil.c | 2 +- source/blender/editors/space_clip/space_clip.c | 4 +- source/blender/editors/space_image/space_image.c | 7 +- .../editors/space_sequencer/sequencer_draw.c | 2 +- 6 files changed, 128 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index 3e2dbe255df..8da36f015dc 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -57,7 +57,7 @@ void ED_operatormacros_mask(void); /* mask_draw.c */ void ED_mask_draw(const struct bContext *C, const char draw_flag, const char draw_type); void ED_mask_draw_region(struct Mask *mask, struct ARegion *ar, - const char draw_flag, const char draw_type, + const char draw_flag, const char draw_type, const char overlay_mode, const int width_i, const int height_i, const float aspx, const float aspy, const short do_scale_applied, const short do_draw_cb, diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index fec4ab87996..50d8e653737 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -35,6 +35,7 @@ #include "BLI_utildefines.h" #include "BLI_math.h" #include "BLI_rect.h" +#include "BLI_task.h" #include "BKE_context.h" #include "BKE_mask.h" @@ -48,6 +49,7 @@ #include "ED_mask.h" /* own include */ #include "ED_space_api.h" #include "BIF_gl.h" +#include "BIF_glutil.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -535,10 +537,93 @@ void ED_mask_draw(const bContext *C, draw_masklays(C, mask, draw_flag, draw_type, width, height); } +typedef struct ThreadedMaskRasterizeState { + MaskRasterHandle *handle; + float *buffer; + int width, height; +} ThreadedMaskRasterizeState; + +typedef struct ThreadedMaskRasterizeData { + int start_scanline; + int num_scanlines; +} ThreadedMaskRasterizeData; + +static void mask_rasterize_func(TaskPool *pool, void *taskdata, int UNUSED(threadid)) +{ + ThreadedMaskRasterizeState *state = (ThreadedMaskRasterizeState *) BLI_task_pool_userdata(pool); + ThreadedMaskRasterizeData *data = (ThreadedMaskRasterizeData *) taskdata; + int scanline; + + for (scanline = 0; scanline < data->num_scanlines; scanline++) { + int x, y = data->start_scanline + scanline; + for (x = 0; x < state->width; x++) { + int index = y * state->width + x; + float xy[2]; + + xy[0] = (float) x / state->width; + xy[1] = (float) y / state->height; + + state->buffer[index] = BKE_maskrasterize_handle_sample(state->handle, xy); + } + } +} + +static float *threaded_mask_rasterize(Mask *mask, const int width, const int height) +{ + TaskScheduler *task_scheduler = BLI_task_scheduler_get(); + TaskPool *task_pool; + MaskRasterHandle *handle; + ThreadedMaskRasterizeState state; + float *buffer; + int i, num_threads = BLI_task_scheduler_num_threads(task_scheduler), scanlines_per_thread; + + buffer = MEM_mallocN(sizeof(float) * height * width, "rasterized mask buffer"); + + /* Initialize rasterization handle. */ + handle = BKE_maskrasterize_handle_new(); + BKE_maskrasterize_handle_init(handle, mask, width, height, TRUE, TRUE, TRUE); + + state.handle = handle; + state.buffer = buffer; + state.width = width; + state.height = height; + + task_pool = BLI_task_pool_create(task_scheduler, &state); + + BLI_begin_threaded_malloc(); + + scanlines_per_thread = height / num_threads; + for (i = 0; i < num_threads; i++) { + ThreadedMaskRasterizeData *data = MEM_mallocN(sizeof(ThreadedMaskRasterizeData), + "threaded mask rasterize data"); + + data->start_scanline = i * scanlines_per_thread; + + if (i < num_threads - 1) { + data->num_scanlines = scanlines_per_thread; + } + else { + data->num_scanlines = height - data->start_scanline; + } + + BLI_task_pool_push(task_pool, mask_rasterize_func, data, true, TASK_PRIORITY_LOW); + } + + /* work and wait until tasks are done */ + BLI_task_pool_work_and_wait(task_pool); + + /* Free memory. */ + BLI_task_pool_free(task_pool); + BLI_end_threaded_malloc(); + BKE_maskrasterize_handle_free(handle); + + return buffer; +} + /* sets up the opengl context. * width, height are to match the values from ED_mask_get_size() */ void ED_mask_draw_region(Mask *mask, ARegion *ar, - const char draw_flag, const char draw_type, + const char draw_flag, const char draw_type, const char overlay_mode, const int width_i, const int height_i, /* convert directly into aspect corrected vars */ const float aspx, const float aspy, const short do_scale_applied, const short do_draw_cb, @@ -592,6 +677,37 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, yofs = ((width - height) / -2.0f) * zoomy; } + if (draw_flag & MASK_DRAWFLAG_OVERLAY) { + float *buffer = threaded_mask_rasterize(mask, width, height); + int format; + + if (overlay_mode == MASK_OVERLAY_ALPHACHANNEL) { + glColor3f(1.0f, 1.0f, 1.0f); + format = GL_LUMINANCE; + } + else { + /* More blending types could be supported in the future. */ + glEnable(GL_BLEND); + glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); + format = GL_ALPHA; + } + + glPushMatrix(); + glTranslatef(x, y, 0); + glScalef(zoomx, zoomy, 0); + if (stabmat) { + glMultMatrixf(stabmat); + } + glaDrawPixelsTex(0.0f, 0.0f, width, height, format, GL_FLOAT, GL_NEAREST, buffer); + glPopMatrix(); + + if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { + glDisable(GL_BLEND); + } + + MEM_freeN(buffer); + } + /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ glPushMatrix(); glTranslatef(x + xofs, y + yofs, 0); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index b70b06f2aa4..d356c3d8de3 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -531,7 +531,7 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, components = 4; else if (format == GL_RGB) components = 3; - else if (format == GL_LUMINANCE) + else if (ELEM(format, GL_LUMINANCE, GL_ALPHA)) components = 1; else { BLI_assert(!"Incompatible format passed to glaDrawPixelsTexScaled"); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 3ede63adb72..adc902bf4ba 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1191,7 +1191,9 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) int mask_width, mask_height; ED_mask_get_size(sa, &mask_width, &mask_height); ED_mask_draw_region(mask, ar, - sc->mask_info.draw_flag, sc->mask_info.draw_type, + sc->mask_info.draw_flag, + sc->mask_info.draw_type, + sc->mask_info.overlay_mode, mask_width, mask_height, aspx, aspy, TRUE, TRUE, diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5a8292abcab..7b20af340ae 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -674,7 +674,6 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) } else if (sima->mode == SI_MODE_MASK) { mask = ED_space_image_get_mask(sima); - draw_image_cursor(ar, sima->cursor); } ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); @@ -715,7 +714,9 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) BLI_unlock_thread(LOCK_DRAW_IMAGE); ED_mask_draw_region(mask, ar, - sima->mask_info.draw_flag, sima->mask_info.draw_type, + sima->mask_info.draw_flag, + sima->mask_info.draw_type, + sima->mask_info.overlay_mode, width, height, aspx, aspy, TRUE, FALSE, @@ -723,7 +724,9 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) ED_mask_draw_frames(mask, ar, CFRA, mask->sfra, mask->efra); + UI_view2d_view_ortho(v2d); draw_image_cursor(ar, sima->cursor); + UI_view2d_view_restore(C); } /* scrollers? */ diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index dca1b481334..cb69a7fe654 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1251,7 +1251,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq height = (scene->r.size * scene->r.ysch) / 100; ED_mask_draw_region(mask, ar, - 0, 0, /* TODO */ + 0, 0, 0, /* TODO */ width, height, aspx, aspy, FALSE, TRUE, -- cgit v1.2.3 From d06bc3408842f2b9afa0a0dde755fe9b3a390695 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 12 Oct 2013 14:47:04 +0000 Subject: Fix for prefetch not working correct if last frame was loaded --- source/blender/editors/space_clip/clip_editor.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 0d64a3ce594..f5db34d87d7 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -710,8 +710,14 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip if (queue->direction > 0) { current_frame = prefetch_find_uncached_frame(clip, queue->current_frame + 1, queue->end_frame, queue->render_size, queue->render_flag, 1); + /* switch direction if read frames from current up to scene end frames */ + if (current_frame >= queue->end_frame) { + queue->current_frame = queue->initial_frame; + queue->direction = -1; + } } - else { + + if (queue->direction < 0) { current_frame = prefetch_find_uncached_frame(clip, queue->current_frame - 1, queue->start_frame, queue->render_size, queue->render_flag, -1); } @@ -736,12 +742,6 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip *queue->do_update = 1; *queue->progress = (float)frames_processed / (queue->end_frame - queue->start_frame); - - /* switch direction if read frames from current up to scene end frames */ - if (current_frame == queue->end_frame) { - queue->current_frame = queue->initial_frame; - queue->direction = -1; - } } } BLI_spin_unlock(&queue->spin); -- cgit v1.2.3 From 3e79a0a5e0cd1cc080ffae17528914d812861f28 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Oct 2013 18:11:54 +0000 Subject: fix for possible eyedropper NULL pointer use. --- source/blender/editors/interface/interface_eyedropper.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 56dd18565dc..783a777a2fe 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -116,9 +116,10 @@ static void eyedropper_exit(bContext *C, wmOperator *op) { WM_cursor_modal_restore(CTX_wm_window(C)); - if (op->customdata) + if (op->customdata) { MEM_freeN(op->customdata); - op->customdata = NULL; + op->customdata = NULL; + } } static int eyedropper_cancel(bContext *C, wmOperator *op) @@ -433,15 +434,17 @@ static int datadropper_init(bContext *C, wmOperator *op) static void datadropper_exit(bContext *C, wmOperator *op) { - DataDropper *ddr = (DataDropper *)op->customdata; - WM_cursor_modal_restore(CTX_wm_window(C)); - ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel); + if (op->customdata) { + DataDropper *ddr = (DataDropper *)op->customdata; + + ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel); - if (op->customdata) MEM_freeN(op->customdata); - op->customdata = NULL; + + op->customdata = NULL; + } } static int datadropper_cancel(bContext *C, wmOperator *op) -- cgit v1.2.3 From 2ce3bd0d672e7e26e1a8710444872ad6478a7565 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Oct 2013 22:31:02 +0000 Subject: code cleanup: use more obvious assignments for transform snapping angles. --- source/blender/editors/transform/transform.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 239d6297695..b08f66d0454 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2600,8 +2600,8 @@ void initWarp(TransInfo *t) t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; - t->snap[1] = 5.0f / 180.0f * (float)M_PI; - t->snap[2] = 1.0f / 180.0f * (float)M_PI; + t->snap[1] = DEG2RAD(5.0); + t->snap[2] = DEG2RAD(1.0); t->num.increment = 1.0f; @@ -3369,8 +3369,8 @@ void initRotation(TransInfo *t) t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; - t->snap[1] = (float)((5.0 / 180) * M_PI); - t->snap[2] = t->snap[1] * 0.2f; + t->snap[1] = DEG2RAD(5.0); + t->snap[2] = DEG2RAD(1.0); t->num.increment = 1.0f; @@ -3701,8 +3701,8 @@ void initTrackball(TransInfo *t) t->idx_max = 1; t->num.idx_max = 1; t->snap[0] = 0.0f; - t->snap[1] = (float)((5.0 / 180) * M_PI); - t->snap[2] = t->snap[1] * 0.2f; + t->snap[1] = DEG2RAD(5.0); + t->snap[2] = DEG2RAD(1.0); t->num.increment = 1.0f; @@ -4149,8 +4149,8 @@ void initTilt(TransInfo *t) t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; - t->snap[1] = (float)((5.0 / 180) * M_PI); - t->snap[2] = t->snap[1] * 0.2f; + t->snap[1] = DEG2RAD(5.0); + t->snap[2] = DEG2RAD(1.0); t->num.increment = t->snap[1]; @@ -6435,8 +6435,8 @@ void initBoneRoll(TransInfo *t) t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; - t->snap[1] = (float)((5.0 / 180) * M_PI); - t->snap[2] = t->snap[1] * 0.2f; + t->snap[1] = DEG2RAD(5.0); + t->snap[2] = DEG2RAD(1.0); t->num.increment = 1.0f; -- cgit v1.2.3 From 7c2fae19b4cf6357def1d2bbe3a75696fd61bc86 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 12 Oct 2013 23:56:21 +0000 Subject: cmake/openimageio - partially reverting #60692 We now have openimageio building when cycles builds or when it's manually set to build. (I reverted the _IMAGE_ in the define name because I think the closer the cmake flags match the defines in the software the better, and there is no reason to rename all the existent WITH_OPENIMAGEIO references in CMakeLists.txt - which would be the alternative) --- source/blender/editors/space_file/CMakeLists.txt | 4 ++-- source/blender/editors/space_image/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index ce0b08c6708..3b2db3ee7bc 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -58,8 +58,8 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() -if(WITH_IMAGE_OPENIMAGEIO) - add_definitions(-DWITH_OPENIMAGEIO) +if(WITH_OPENIMAGEIO) + add_definitions(-DWITH_OPENIMAGEIO) endif() if(WITH_IMAGE_TIFF) diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 2f78818d012..50d8051a73e 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -50,7 +50,7 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -if(WITH_IMAGE_OPENIMAGEIO) +if(WITH_OPENIMAGEIO) add_definitions(-DWITH_OPENIMAGEIO) endif() -- cgit v1.2.3 From eabf7ab3351ade8415cd38d6faf2cfba79ba7400 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Oct 2013 00:32:31 +0000 Subject: code cleanup: utility function for getting a bool as a string. --- source/blender/editors/mesh/editmesh_inset.c | 8 ++++---- source/blender/editors/mesh/editmesh_knife.c | 8 ++++---- source/blender/editors/transform/transform.c | 20 +++++++------------- 3 files changed, 15 insertions(+), 21 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 71822868026..eb66cf50a1e 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -96,10 +96,10 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) BLI_snprintf(msg, HEADER_LENGTH, str, flts_str, flts_str + NUM_STR_REP_LEN, - opdata->modify_depth ? IFACE_("On") : IFACE_("Off"), - RNA_boolean_get(op->ptr, "use_outset") ? IFACE_("On") : IFACE_("Off"), - RNA_boolean_get(op->ptr, "use_boundary") ? IFACE_("On") : IFACE_("Off"), - RNA_boolean_get(op->ptr, "use_individual") ? IFACE_("On") : IFACE_("Off") + WM_bool_as_string(opdata->modify_depth), + WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")), + WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")), + WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual")) ); ED_area_headerprint(sa, msg); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 9d8b283fe1a..b0dc30d73f7 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -230,10 +230,10 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd) BLI_snprintf(header, HEADER_LENGTH, IFACE_("LMB: define cut lines, Return/Spacebar: confirm, Esc or RMB: cancel, " "E: new cut, Ctrl: midpoint snap (%s), Shift: ignore snap (%s), " "C: angle constrain (%s), Z: cut through (%s)"), - kcd->snap_midpoints ? IFACE_("On") : IFACE_("Off"), - kcd->ignore_edge_snapping ? IFACE_("On") : IFACE_("Off"), - kcd->angle_snapping ? IFACE_("On") : IFACE_("Off"), - kcd->cut_through ? IFACE_("On") : IFACE_("Off")); + WM_bool_as_string(kcd->snap_midpoints), + WM_bool_as_string(kcd->ignore_edge_snapping), + WM_bool_as_string(kcd->angle_snapping), + WM_bool_as_string(kcd->cut_through)); ED_area_headerprint(CTX_wm_area(C), header); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b08f66d0454..ba7bdebd5bf 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4107,7 +4107,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) } } BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"), - (t->flag & T_ALT_TRANSFORM) ? IFACE_("ON") : IFACE_("OFF")); + WM_bool_as_string(t->flag & T_ALT_TRANSFORM)); /* done with header string */ @@ -5875,9 +5875,6 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) bool flipped = sld->flipped_vtx; bool is_proportional = sld->is_proportional; - const char *on_str = IFACE_("ON"); - const char *off_str = IFACE_("OFF"); - final = t->values[0]; snapGrid(t, &final); @@ -5893,11 +5890,11 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c); BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %s (E)ven: %s, (F)lipped: %s"), - &c[0], !is_proportional ? on_str : off_str, flipped ? on_str : off_str); + &c[0], WM_bool_as_string(!is_proportional), WM_bool_as_string(flipped)); } else { BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %.4f (E)ven: %s, (F)lipped: %s"), - final, !is_proportional ? on_str : off_str, flipped ? on_str : off_str); + final, WM_bool_as_string(!is_proportional), WM_bool_as_string(flipped)); } CLAMP(final, -1.0f, 1.0f); @@ -6382,9 +6379,6 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2])) const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num)); - const char *on_str = IFACE_("ON"); - const char *off_str = IFACE_("OFF"); - final = t->values[0]; snapGrid(t, &final); @@ -6405,11 +6399,11 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2])) else { ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%.4f ", final); } - ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(E)ven: %s, "), !is_proportional ? on_str : off_str); + ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(E)ven: %s, "), WM_bool_as_string(!is_proportional)); if (!is_proportional) { - ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(F)lipped: %s, "), flipped ? on_str : off_str); + ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(F)lipped: %s, "), WM_bool_as_string(flipped)); } - ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), is_clamp ? on_str : off_str); + ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), WM_bool_as_string(is_clamp)); /* done with header string */ /* do stuff here */ @@ -6741,7 +6735,7 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str) } } ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"), - (t->flag & T_ALT_TRANSFORM) ? IFACE_("ON") : IFACE_("OFF")); + WM_bool_as_string(t->flag & T_ALT_TRANSFORM)); } static void applySeqSlide(TransInfo *t, const float val[2]) -- cgit v1.2.3 From b00a8122e3e5fa88e3870ca20eedbd251d245237 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Oct 2013 01:09:23 +0000 Subject: improve warp transform so it can be used as a general bending tool too. --- source/blender/editors/transform/transform.c | 225 ++++++++++++--------- source/blender/editors/transform/transform.h | 1 + .../blender/editors/transform/transform_generics.c | 5 + source/blender/editors/transform/transform_input.c | 16 ++ 4 files changed, 150 insertions(+), 97 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ba7bdebd5bf..ea039c15be4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -105,6 +105,8 @@ static int doVertSlide(TransInfo *t, float perc); static void drawEdgeSlide(const struct bContext *C, TransInfo *t); static void drawVertSlide(const struct bContext *C, TransInfo *t); +static void len_v3_ensure(float v[3], const float length); +static void postInputRotation(TransInfo *t, float values[3]); static bool transdata_check_local_center(TransInfo *t) { @@ -2576,29 +2578,33 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* ************************** WARP *************************** */ -static void postInputWarp(TransInfo *t, float values[3]) -{ - mul_v3_fl(values, (float)(M_PI * 2)); +struct WarpCustomData { + float warp_sta[3]; + float warp_end[3]; - if (t->customData) { /* non-null value indicates reversed input */ - negate_v3(values); - } -} + float warp_nor[3]; + float warp_tan[3]; + + /* for applying the mouse distance */ + float warp_init_dist; +}; void initWarp(TransInfo *t) { - float max[3], min[3]; - int i; + const float mval_fl[2] = {UNPACK2(t->mval)}; + const float *curs; + float tvec[3]; + struct WarpCustomData *data; t->mode = TFM_WARP; t->transform = Warp; t->handleEvent = handleEventWarp; - setInputPostFct(&t->mouse, postInputWarp); - initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); + setInputPostFct(&t->mouse, postInputRotation); + initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING); - t->idx_max = 0; - t->num.idx_max = 0; + t->idx_max = 1; + t->num.idx_max = 1; t->snap[0] = 0.0f; t->snap[1] = DEG2RAD(5.0); t->snap[2] = DEG2RAD(1.0); @@ -2606,28 +2612,33 @@ void initWarp(TransInfo *t) t->num.increment = 1.0f; t->flag |= T_NO_CONSTRAINT; - - /* we need min/max in view space */ - for (i = 0; i < t->total; i++) { - float center[3]; - copy_v3_v3(center, t->data[i].center); - mul_m3_v3(t->data[i].mtx, center); - mul_m4_v3(t->viewmat, center); - sub_v3_v3(center, t->viewmat[3]); - if (i) { - minmax_v3v3_v3(min, max, center); - } - else { - copy_v3_v3(max, center); - copy_v3_v3(min, center); - } + + //copy_v3_v3(t->center, give_cursor(t->scene, t->view)); + calculateCenterCursor(t); + + t->val = 0.0f; + + data = MEM_callocN(sizeof(*data), __func__); + + curs = give_cursor(t->scene, t->view); + copy_v3_v3(data->warp_sta, curs); + ED_view3d_win_to_3d(t->ar, curs, mval_fl, data->warp_end); + + copy_v3_v3(data->warp_nor, t->viewinv[2]); + if (t->flag & T_EDIT) { + sub_v3_v3(data->warp_sta, t->obedit->obmat[3]); + sub_v3_v3(data->warp_end, t->obedit->obmat[3]); } + normalize_v3(data->warp_nor); - mid_v3_v3v3(t->center, min, max); + /* tangent */ + sub_v3_v3v3(tvec, data->warp_end, data->warp_sta); + cross_v3_v3v3(data->warp_tan, tvec, data->warp_nor); + normalize_v3(data->warp_tan); - if (max[0] == min[0]) - max[0] += 0.1f; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ - t->val = (max[0] - min[0]) / 2.0f; /* t->val is X dimension projected boundbox */ + data->warp_init_dist = len_v3v3(data->warp_end, data->warp_sta); + + t->customData = data; } int handleEventWarp(TransInfo *t, const wmEvent *event) @@ -2635,11 +2646,7 @@ int handleEventWarp(TransInfo *t, const wmEvent *event) int status = 0; if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { - // Use customData pointer to signal warp direction - if (t->customData == NULL) - t->customData = (void *)1; - else - t->customData = NULL; + (void)t; status = 1; } @@ -2650,91 +2657,115 @@ int handleEventWarp(TransInfo *t, const wmEvent *event) int Warp(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; - float vec[3], circumfac, dist, phi0, co, si, cursor[3], gcursor[3]; - const float *curs; + float vec[3]; + float pivot[3]; + float warp_end_radius[3]; int i; char str[MAX_INFO_LEN]; - - curs = give_cursor(t->scene, t->view); - /* - * gcursor is the one used for helpline. - * It has to be in the same space as the drawing loop - * (that means it needs to be in the object's space when in edit mode and - * in global space in object mode) - * - * cursor is used for calculations. - * It needs to be in view space, but we need to take object's offset - * into account if in Edit mode. - */ - copy_v3_v3(cursor, curs); - copy_v3_v3(gcursor, cursor); - if (t->flag & T_EDIT) { - sub_v3_v3(cursor, t->obedit->obmat[3]); - sub_v3_v3(gcursor, t->obedit->obmat[3]); - mul_m3_v3(t->data->smtx, gcursor); - } - mul_m4_v3(t->viewmat, cursor); - sub_v3_v3(cursor, t->viewmat[3]); - + const struct WarpCustomData *data = t->customData; + const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0; + + union { + struct { float angle, scale; }; + float vector[2]; + } values; + /* amount of radians for warp */ - circumfac = t->values[0]; - - snapGrid(t, &circumfac); - applyNumInput(&t->num, &circumfac); + copy_v2_v2(values.vector, t->values); + +#if 0 + snapGrid(t, angle_rad); +#else + /* hrmf, snapping radius is using 'angle' steps, need to convert to something else + * this isnt essential but nicer to give reasonable snapping values for radius */ + if (t->tsnap.mode == SCE_SNAP_MODE_INCREMENT) { + const float radius_snap = 0.1f; + const float snap_hack = (t->snap[1] * data->warp_init_dist) / radius_snap; + values.scale *= snap_hack; + snapGrid(t, values.vector); + values.scale /= snap_hack; + } +#endif /* header print for NumInput */ if (hasNumInput(&t->num)) { - char c[NUM_STR_REP_LEN]; + char c[NUM_STR_REP_LEN * 2]; + applyNumInput(&t->num, values.vector); + outputNumInput(&(t->num), c); - BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp: %s"), c); + BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp Angle: %s Radius: %s Alt, Clamp %s"), + &c[0], &c[NUM_STR_REP_LEN], + WM_bool_as_string(is_clamp)); - circumfac = DEG2RADF(circumfac); + values.angle = DEG2RADF(values.angle); + values.scale = values.scale / data->warp_init_dist; } else { /* default header print */ - BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp: %.3f"), RAD2DEGF(circumfac)); + BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp Angle: %.3f Radius: %.4f, Alt, Clamp %s"), + RAD2DEGF(values.angle), values.scale * data->warp_init_dist, + WM_bool_as_string(is_clamp)); } - t->values[0] = circumfac; + copy_v2_v2(t->values, values.vector); - circumfac /= 2; /* only need 180 on each side to make 360 */ + values.angle *= -1.0f; + values.scale *= data->warp_init_dist; + /* calc 'data->warp_end' from 'data->warp_end_init' */ + copy_v3_v3(warp_end_radius, data->warp_end); + dist_ensure_v3_v3fl(warp_end_radius, data->warp_sta, values.scale); + /* done */ + + /* calculate pivot */ + copy_v3_v3(pivot, data->warp_sta); + if (values.angle > 0.0f) { + madd_v3_v3fl(pivot, data->warp_tan, -values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle)); + } + else { + madd_v3_v3fl(pivot, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle)); + } + for (i = 0; i < t->total; i++, td++) { - float loc[3]; + float mat[3][3]; + float delta[3]; + float fac, fac_scaled; + if (td->flag & TD_NOACTION) break; if (td->flag & TD_SKIP) continue; - - /* translate point to center, rotate in such a way that outline==distance */ + + if (UNLIKELY(values.angle == 0.0f)) { + copy_v3_v3(td->loc, td->iloc); + continue; + } + copy_v3_v3(vec, td->iloc); mul_m3_v3(td->mtx, vec); - mul_m4_v3(t->viewmat, vec); - sub_v3_v3(vec, t->viewmat[3]); - - dist = vec[0] - cursor[0]; - - /* t->val is X dimension projected boundbox */ - phi0 = (circumfac * dist / t->val); - - vec[1] = (vec[1] - cursor[1]); - - co = cosf(phi0); - si = sinf(phi0); - loc[0] = -si * vec[1] + cursor[0]; - loc[1] = co * vec[1] + cursor[1]; - loc[2] = vec[2]; - - mul_m4_v3(t->viewinv, loc); - sub_v3_v3(loc, t->viewinv[3]); - mul_m3_v3(td->smtx, loc); - - sub_v3_v3(loc, td->iloc); - mul_v3_fl(loc, td->factor); - add_v3_v3v3(td->loc, td->iloc, loc); + + fac = line_point_factor_v3(vec, data->warp_sta, warp_end_radius); + if (is_clamp) { + CLAMP(fac, 0.0f, 1.0f); + } + + fac_scaled = fac * td->factor; + axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled); + interp_v3_v3v3(delta, data->warp_sta, warp_end_radius, fac_scaled); + sub_v3_v3(delta, data->warp_sta); + + /* delta is subtracted, rotation adds back this offset */ + sub_v3_v3(vec, delta); + + sub_v3_v3(vec, pivot); + mul_m3_v3(mat, vec); + add_v3_v3(vec, pivot); + + mul_m3_v3(td->smtx, vec); + copy_v3_v3(td->loc, vec); } recalcData(t); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 9355773c47b..b32ba5ad527 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -678,6 +678,7 @@ typedef enum { INPUT_SPRING, INPUT_SPRING_FLIP, INPUT_ANGLE, + INPUT_ANGLE_SPRING, INPUT_TRACKBALL, INPUT_HORIZONTAL_RATIO, INPUT_HORIZONTAL_ABSOLUTE, diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index b6f031614ca..94f481d8dfc 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1145,6 +1145,11 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; t->around = v3d->around; + /* warp always uses the cursor */ + if (t->mode == TFM_WARP) { + t->around = V3D_CURSOR; + } + if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) && RNA_property_is_set(op->ptr, prop))) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index db214e1f6db..ee993129303 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -279,6 +279,16 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], output[0] = *angle; } +static void InputAngleSpring(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) +{ + float toutput[3]; + + InputAngle(t, mi, mval, output); + InputSpring(t, mi, mval, toutput); + + output[1] = toutput[0]; +} + void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const float center[2], const int mval[2]) { mi->factor = 0; @@ -328,6 +338,12 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) mi->apply = InputAngle; t->helpline = HLP_ANGLE; break; + case INPUT_ANGLE_SPRING: + calcSpringFactor(mi); + mi->data = MEM_callocN(sizeof(double), "angle accumulator"); + mi->apply = InputAngleSpring; + t->helpline = HLP_ANGLE; + break; case INPUT_TRACKBALL: /* factor has to become setting or so */ mi->factor = 0.01f; -- cgit v1.2.3 From cb0c279d4dd1994adf4a5fc6742549cdd1d09905 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Oct 2013 09:27:48 +0000 Subject: * Fix scons compilation on Windows, missing pthreads include. --- source/blender/editors/mask/SConscript | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mask/SConscript b/source/blender/editors/mask/SConscript index a80d3317c89..9dd521e3a7c 100644 --- a/source/blender/editors/mask/SConscript +++ b/source/blender/editors/mask/SConscript @@ -41,5 +41,8 @@ incs = [ '../../makesrna', '../../windowmanager', ] + +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): + incs.append(env['BF_PTHREADS_INC']) env.BlenderLib('bf_editors_mask', sources, incs, defs, libtype=['core'], priority=[100]) -- cgit v1.2.3