Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_bisect.c
| Show All 26 Lines | |||||
| * \ingroup edmesh | * \ingroup edmesh | ||||
| */ | */ | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_string.h" | |||||
| #include "BLF_translation.h" | |||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | static bool mesh_bisect_interactive_calc( | ||||
| opdata->is_first = false; | opdata->is_first = false; | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
brecht: This is not necessary, you can use sizeof(header) for BLI_snprintf. | |||||
| BMEditMesh *em = BKE_editmesh_from_object(obedit); | BMEditMesh *em = BKE_editmesh_from_object(obedit); | ||||
| int ret; | int ret; | ||||
| if (em->bm->totedgesel == 0) { | if (em->bm->totedgesel == 0) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Selected edges/faces required"); | BKE_report(op->reports, RPT_ERROR, "Selected edges/faces required"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Show All 19 Lines | if (ret & OPERATOR_RUNNING_MODAL) { | ||||
| opdata->mesh_backup = EDBM_redo_state_store(em); | opdata->mesh_backup = EDBM_redo_state_store(em); | ||||
| opdata->is_first = true; | opdata->is_first = true; | ||||
| gesture->userdata = opdata; | gesture->userdata = opdata; | ||||
| /* misc other vars */ | /* misc other vars */ | ||||
| G.moving = G_TRANSFORM_EDIT; | G.moving = G_TRANSFORM_EDIT; | ||||
| opdata->twtype = v3d->twtype; | opdata->twtype = v3d->twtype; | ||||
| v3d->twtype = 0; | v3d->twtype = 0; | ||||
| /* initialize modal callout */ | |||||
| ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Click and drag to draw cut line")); | |||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
Not Done Inline ActionsActually you don't need BLI_snprintf at all, you can pass IFACE_("LMB: Click and drag to draw cut line") directly to ED_area_headerprint or assign it to a const char*, no need to do printf when it's a plain string. brecht: Actually you don't need BLI_snprintf at all, you can pass `IFACE_("LMB: Click and drag to draw… | |||||
| static void edbm_bisect_exit(bContext *C, BisectData *opdata) | static void edbm_bisect_exit(bContext *C, BisectData *opdata) | ||||
| { | { | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); | EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); | ||||
| v3d->twtype = opdata->twtype; | v3d->twtype = opdata->twtype; | ||||
| G.moving = 0; | G.moving = 0; | ||||
| } | } | ||||
| static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) | static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmGesture *gesture = op->customdata; | wmGesture *gesture = op->customdata; | ||||
| BisectData *opdata = gesture->userdata; | BisectData *opdata = gesture->userdata; | ||||
| BisectData opdata_back = *opdata; /* annoyance, WM_gesture_straightline_modal, frees */ | BisectData opdata_back = *opdata; /* annoyance, WM_gesture_straightline_modal, frees */ | ||||
| int ret; | int ret; | ||||
| ret = WM_gesture_straightline_modal(C, op, event); | ret = WM_gesture_straightline_modal(C, op, event); | ||||
| /* update or clear modal callout */ | |||||
| if (event->type == EVT_MODAL_MAP) { | |||||
| if(event->val == GESTURE_MODAL_BEGIN) { | |||||
| ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Release to confirm cut line")); | |||||
| } | |||||
| else { | |||||
| ED_area_headerprint(CTX_wm_area(C), NULL); | |||||
| } | |||||
| } | |||||
| if (ret & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { | if (ret & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { | ||||
| edbm_bisect_exit(C, &opdata_back); | edbm_bisect_exit(C, &opdata_back); | ||||
| } | } | ||||
| return ret; | return ret; | ||||
Not Done Inline ActionsCode style convention is }
else {brecht: Code style convention is
}
else { | |||||
| } | } | ||||
| /* End Model Helpers */ | /* End Model Helpers */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| static int mesh_bisect_exec(bContext *C, wmOperator *op) | static int mesh_bisect_exec(bContext *C, wmOperator *op) | ||||
| ▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines | |||||
This is not necessary, you can use sizeof(header) for BLI_snprintf.