Commit: ae6e84471ab4fbf7c1f9b16b5184ca2b3040d65c Author: Campbell Barton Date: Wed Nov 14 09:50:04 2018 +1100 Branches: blender2.8 https://developer.blender.org/rBae6e84471ab4fbf7c1f9b16b5184ca2b3040d65c
Merge branch 'master' into blender2.8 =================================================================== =================================================================== diff --cc source/blender/editors/interface/interface_layout.c index e608058dd99,922b5779c9f..76296b12898 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@@ -2259,79 -1979,11 +2259,81 @@@ void uiItemM(uiLayout *layout, const ch if (layout->root->type == UI_LAYOUT_MENU && !icon) icon = ICON_BLANK1; - ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, TIP_(mt->description), false); + ui_item_menu( + layout, name, icon, ui_item_menutype_func, mt, NULL, + mt->description ? TIP_(mt->description) : "", false); } +/* popover */ +void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *C, PanelType *pt, const char *name, int icon) +{ + if (!name) { + name = CTX_IFACE_(pt->translation_context, pt->label); + } + + if (layout->root->type == UI_LAYOUT_MENU && !icon) { + icon = ICON_BLANK1; + } + + const bool ok = (pt->poll == NULL) || pt->poll(C, pt); + if (ok && (pt->draw_header != NULL)) { + layout = uiLayoutRow(layout, true); + Panel panel = { + .type = pt, + .layout = layout, + .flag = PNL_POPOVER, + }; + pt->draw_header(C, &panel); + } + uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, pt, NULL, NULL, true); + but->type = UI_BTYPE_POPOVER; + if (!ok) { + but->flag |= UI_BUT_DISABLED; + } +} + +void uiItemPopoverPanel( + uiLayout *layout, bContext *C, + const char *panel_type, const char *name, int icon) +{ + PanelType *pt = WM_paneltype_find(panel_type, true); + if (pt == NULL) { + RNA_warning("Panel type not found '%s'", panel_type); + return; + } + uiItemPopoverPanel_ptr(layout, C, pt, name, icon); +} + +void uiItemPopoverPanelFromGroup( + uiLayout *layout, bContext *C, + int space_id, int region_id, const char *context, const char *category) +{ + SpaceType *st = BKE_spacetype_from_id(space_id); + if (st == NULL) { + RNA_warning("space type not found %d", space_id); + return; + } + ARegionType *art = BKE_regiontype_from_id(st, region_id); + if (art == NULL) { + RNA_warning("region type not found %d", region_id); + return; + } + + for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) { + /* Causes too many panels, check context. */ + if (pt->parent_id[0] == '\0') { + if (/* (*context == '\0') || */ STREQ(pt->context, context)) { + if ((*category == '\0') || STREQ(pt->category, category)) { + if (pt->poll == NULL || pt->poll(C, pt)) { + uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE); + } + } + } + } + } +} + + /* label item */ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) { diff --cc source/blender/editors/mesh/editmesh_polybuild.c index bf927478187,00000000000..882ee3092b4 mode 100644,000000..100644 --- a/source/blender/editors/mesh/editmesh_polybuild.c +++ b/source/blender/editors/mesh/editmesh_polybuild.c @@@ -1,499 -1,0 +1,496 @@@ +/* + * ***** 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. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/mesh/editmesh_polybuild.c + * \ingroup edmesh + * + * Tools to implement polygon building tool, + * an experimental tool for quickly constructing/manipulating faces. + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_object_types.h" + +#include "BLI_math.h" + +#include "BKE_context.h" +#include "BKE_report.h" +#include "BKE_editmesh.h" +#include "BKE_mesh.h" +#include "BKE_layer.h" + +#include "WM_types.h" + +#include "ED_object.h" +#include "ED_mesh.h" +#include "ED_scene.h" +#include "ED_screen.h" +#include "ED_transform.h" +#include "ED_view3d.h" + +#include "bmesh.h" + +#include "mesh_intern.h" /* own include */ + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" + +#include "DEG_depsgraph.h" + +/* -------------------------------------------------------------------- */ +/** \name Local Utilities + * \{ */ + +static void edbm_selectmode_ensure(Scene *scene, BMEditMesh *em, short selectmode) +{ + if ((scene->toolsettings->selectmode & selectmode) == 0) { + scene->toolsettings->selectmode |= selectmode; + em->selectmode = scene->toolsettings->selectmode; + EDBM_selectmode_set(em); + } +} + +/* Could make public, for now just keep here. */ +static void edbm_flag_disable_all_multi(ViewLayer *view_layer, const char hflag) +{ + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *ob_iter = objects[ob_index]; + BMEditMesh *em_iter = BKE_editmesh_from_object(ob_iter); + BMesh *bm_iter = em_iter->bm; + if (bm_iter->totvertsel) { + EDBM_flag_disable_all(em_iter, hflag); + DEG_id_tag_update(ob_iter->data, DEG_TAG_SELECT_UPDATE); + } + } + MEM_freeN(objects); +} + +/* When accessed as a tool, get the active edge from the preselection gizmo. */ +static bool edbm_preselect_or_active( + bContext *C, + Base **r_base, + BMElem **r_ele) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + ARegion *ar = CTX_wm_region(C); + wmGizmoMap *gzmap = ar->gizmo_map; + wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "VIEW3D_GGT_mesh_preselect_elem") : NULL; + if (gzgroup != NULL) { + wmGizmo *gz = gzgroup->gizmos.first; + const int object_index = RNA_int_get(gz->ptr, "object_index"); + + /* weak, allocate an array just to access the index. */ + Base *base = NULL; + Object *obedit = NULL; + { + uint bases_len; + Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, &bases_len); + if (object_index < bases_len) { + base = bases[object_index]; + obedit = base->object; + } + MEM_freeN(bases); + } + + *r_base = base; + *r_ele = NULL; + + if (obedit) { + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BMesh *bm = em->bm; + const int vert_index = RNA_int_get(gz->ptr, "vert_index"); + const int edge_index = RNA_int_get(gz->ptr, "edge_index"); + const int face_index = RNA_int_get(gz->ptr, "face_index"); + if (vert_index != -1) { + *r_ele = (BMElem *)BM_vert_at_index_find(bm, vert_index); + } + else if (edge_index != -1) { + *r_ele = (BMElem *)BM_edge_at_index_find(bm, edge_index); + } + else if (face_index != -1) { + *r_ele = (BMElem *)BM_face_at_index_find(bm, face_index); + } + } + } + else { + Base *base = view_layer->basact; + Object *obedit = base->object; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BMesh *bm = em->bm; + *r_base = base; + *r_ele = BM_mesh_active_elem_get(bm); + } + return (*r_ele != NULL); +} + +static bool edbm_preselect_or_active_init_viewcontext( + bContext *C, + ViewContext *vc, + Base **r_base, + BMElem **r_ele) +{ + em_setup_viewcontext(C, vc); + bool ok = edbm_preselect_or_active(C, r_base, r_ele); + if (ok) { + ED_view3d_viewcontext_init_object(vc, (*r_base)->object); + } + return ok; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Face at Cursor + * \{ */ + +static int edbm_polybuild_face_at_cursor_invoke( + bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +{ + float center[3]; + bool changed = false; + + ViewContext vc; + Base *basact = NULL; + BMElem *ele_act = NULL; + edbm_preselect_or_active_init_viewcontext(C, &vc, &basact, &ele_act); + BMEditMesh *em = vc.em; + BMesh *bm = em->bm; + + invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); + ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); + + edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); + + if (ele_act == NULL || ele_act->head.htype == BM_FACE) { + /* Just add vert */ + copy_v3_v3(center, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location); + mul_v3_m4v3(center, vc.obedit->obmat, center); + ED_view3d_win_to_3d_int(vc.v3d, vc.ar, center, event->mval, center); + mul_m4_v3(vc.obedit->imat, center); + + BMVert *v_new = BM_vert_create(bm, center, NULL, BM_CREATE_NOP); + edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT); + BM_vert_select_set(bm, v_new, true); + BM_select_history_store(bm, v_new); + changed = true; + } + else if (ele_act->head.htype == BM_EDGE) { + BMEdge *e_act = (BMEdge *)ele_act; + BMFace *f_reference = e_act->l ? e_act->l->f : NULL; + + mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); + mul_m4_v3(vc.obedit->obmat, center); + ED_view3d_win_to_3d_int(vc.v3d, vc.ar, center, event->mval, center); + mul_m4_v3(vc.obedit->imat, center); + + BMVert *v_tri[3]; + v_tri[0] = e_act->v1; + v_tri[1] = e_act->v2; + v_tri[2] = BM_vert_create(bm, center, NULL, BM_CREATE_NOP); + if (e_act->l && e_act->l->v == v_tri[0]) { + SWAP(BMVert *, v_tri[0], v_tri[1]); + } + // BMFace *f_new = + BM_face_create_verts(bm, v_tri, 3, f_reference, BM_CREATE_NOP, true); + + edbm_flag_disable_all_multi(vc.view_layer, BM_ELEM_SELECT); + BM_vert_select_set(bm, v_tri[2], true); + BM_select_history_store(bm, v_tri[2]); + changed = true; + } + else if (ele_act->head.htype == BM_VERT) { + BMVert *v_act = (BMVert *)ele_act; + BMEdge *e_pair[2] = {NULL}; + + if (v_act->e != NULL) { + for (uint allow_wire = 0; allow_wire < 2 && (e_pair[1] == NULL @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs