Fix #112083: Loop cut requires GL only in interactive mode #112121

Merged
YimingWu merged 2 commits from ChengduLittleA/blender:fix-112083 into main 2023-09-18 15:45:24 +02:00
1 changed files with 10 additions and 3 deletions

View File

@ -374,7 +374,11 @@ static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines)
/* called by both init() and exec() */
static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
{
const bool is_interactive = (event != nullptr);
/* Check whether both `rv3d` and `event` is present, this way we allow the loopcut operator to
* run non-interactively no matter whether the graphical UI is present or not (e.g. from scripts
ChengduLittleA marked this conversation as resolved Outdated

It would be good to note here why check both the rv3d and the event is needed.

It would be good to note here why check both the rv3d and the event is needed.
* with UI running, or entirely in the background with `blender -b`). */
RegionView3D *rv3d = CTX_wm_region_view3d(C);
const bool is_interactive = (rv3d != nullptr) && (event != nullptr);
/* Use for redo - intentionally wrap int to uint. */
struct {
@ -404,7 +408,9 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
}
}
view3d_operator_needs_opengl(C);
if (is_interactive) {
view3d_operator_needs_opengl(C);
}
/* for re-execution, check edge index is in range before we setup ringsel */
bool ok = true;
@ -737,7 +743,8 @@ void MESH_OT_loopcut(wmOperatorType *ot)
ot->exec = loopcut_exec;
ot->modal = loopcut_modal;
ot->cancel = ringcut_cancel;
ot->poll = ED_operator_editmesh_region_view3d;
/* Note the #RegionView3D is needed for interactive use, the operator must check this. */
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;