Cleanup: rename "opengl" to "gpu" for 3D viewport utilities
This commit is contained in:
@@ -325,7 +325,7 @@ static void *ed_armature_pick_bone_impl(
|
||||
/* Don't use hits with this ID, (armature drawing uses this). */
|
||||
const int select_id_ignore = -1;
|
||||
|
||||
hits = view3d_opengl_select_with_id_filter(
|
||||
hits = view3d_gpu_select_with_id_filter(
|
||||
&vc, &buffer, &rect, VIEW3D_SELECT_PICK_NEAREST, VIEW3D_SELECT_FILTER_NOP, select_id_ignore);
|
||||
|
||||
*r_base = nullptr;
|
||||
@@ -556,7 +556,7 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const
|
||||
const bool select = !RNA_boolean_get(op->ptr, "deselect");
|
||||
const bool all_forks = RNA_boolean_get(op->ptr, "all_forks");
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
|
||||
Base *base = nullptr;
|
||||
@@ -673,7 +673,7 @@ static EditBone *get_nearest_editbonepoint(
|
||||
const int select_id_ignore = -1;
|
||||
|
||||
/* we _must_ end cache before return, use 'goto cache_end' */
|
||||
view3d_opengl_select_cache_begin();
|
||||
view3d_gpu_select_cache_begin();
|
||||
|
||||
{
|
||||
const eV3DSelectObjectFilter select_filter = VIEW3D_SELECT_FILTER_NOP;
|
||||
@@ -683,7 +683,7 @@ static EditBone *get_nearest_editbonepoint(
|
||||
BLI_rcti_init_pt_radius(&rect, vc->mval, 12);
|
||||
/* VIEW3D_SELECT_PICK_ALL needs to be used or unselectable bones can block selectability of
|
||||
* bones further back. See #123963. */
|
||||
const int hits12 = view3d_opengl_select_with_id_filter(
|
||||
const int hits12 = view3d_gpu_select_with_id_filter(
|
||||
vc, &buffer, &rect, VIEW3D_SELECT_PICK_ALL, select_filter, select_id_ignore);
|
||||
|
||||
if (hits12 == 1) {
|
||||
@@ -692,7 +692,7 @@ static EditBone *get_nearest_editbonepoint(
|
||||
}
|
||||
else if (hits12 > 0) {
|
||||
BLI_rcti_init_pt_radius(&rect, vc->mval, 5);
|
||||
const int hits5 = view3d_opengl_select_with_id_filter(
|
||||
const int hits5 = view3d_gpu_select_with_id_filter(
|
||||
vc, &buffer, &rect, VIEW3D_SELECT_PICK_ALL, select_filter, select_id_ignore);
|
||||
|
||||
if (hits5 == 1) {
|
||||
@@ -712,7 +712,7 @@ static EditBone *get_nearest_editbonepoint(
|
||||
}
|
||||
|
||||
cache_end:
|
||||
view3d_opengl_select_cache_end();
|
||||
view3d_gpu_select_cache_end();
|
||||
|
||||
Vector<Base *> bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
|
||||
vc->scene, vc->view_layer, vc->v3d);
|
||||
@@ -2261,7 +2261,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const
|
||||
bool changed;
|
||||
Base *base_dst = nullptr;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
|
||||
ebone_src = arm->act_edbone;
|
||||
|
||||
@@ -424,7 +424,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
|
||||
Bone *bone, *curBone, *next = nullptr;
|
||||
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
Base *base = nullptr;
|
||||
bone = ED_armature_pick_bone(C, event->mval, !extend, &base);
|
||||
|
||||
@@ -4840,7 +4840,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
|
||||
short hand;
|
||||
bool changed = false;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
copy_v2_v2_int(vc.mval, mval);
|
||||
|
||||
|
||||
@@ -1108,7 +1108,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
else {
|
||||
if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) && (v3d->shading.type > OB_WIRE)) {
|
||||
/* needed or else the draw matrix can be incorrect */
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
eV3DDepthOverrideMode depth_mode = V3D_DEPTH_ALL;
|
||||
if (cps->flag & CURVE_PAINT_FLAG_DEPTH_ONLY_SELECTED) {
|
||||
|
||||
@@ -696,7 +696,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
const bool select = !RNA_boolean_get(op->ptr, "deselect");
|
||||
Base *basact = nullptr;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
copy_v2_v2_int(vc.mval, event->mval);
|
||||
|
||||
@@ -2005,7 +2005,7 @@ static int edcu_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
|
||||
void *vert_dst_p;
|
||||
Base *basact = nullptr;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
copy_v2_v2_int(vc.mval, event->mval);
|
||||
|
||||
|
||||
@@ -1092,7 +1092,7 @@ static int curves_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
else {
|
||||
if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) && (v3d->shading.type > OB_WIRE)) {
|
||||
/* needed or else the draw matrix can be incorrect */
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
eV3DDepthOverrideMode depth_mode = V3D_DEPTH_ALL;
|
||||
if (cps->flag & CURVE_PAINT_FLAG_DEPTH_ONLY_SELECTED) {
|
||||
|
||||
@@ -661,7 +661,7 @@ static short annotation_stroke_addpoint(tGPsdata *p,
|
||||
}
|
||||
}
|
||||
|
||||
view3d_region_operator_needs_opengl(p->region);
|
||||
view3d_region_operator_needs_gpu(p->region);
|
||||
ED_view3d_depth_override(p->depsgraph, p->region, v3d, nullptr, mode, false, nullptr);
|
||||
}
|
||||
|
||||
@@ -1221,7 +1221,7 @@ static void annotation_stroke_doeraser(tGPsdata *p)
|
||||
if (p->area->spacetype == SPACE_VIEW3D) {
|
||||
if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
|
||||
View3D *v3d = static_cast<View3D *>(p->area->spacedata.first);
|
||||
view3d_region_operator_needs_opengl(p->region);
|
||||
view3d_region_operator_needs_gpu(p->region);
|
||||
ED_view3d_depth_override(
|
||||
p->depsgraph, p->region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, false, &p->depths);
|
||||
}
|
||||
@@ -1691,7 +1691,7 @@ static void annotation_paint_strokeend(tGPsdata *p)
|
||||
}
|
||||
}
|
||||
/* need to restore the original projection settings before packing up */
|
||||
view3d_region_operator_needs_opengl(p->region);
|
||||
view3d_region_operator_needs_gpu(p->region);
|
||||
ED_view3d_depth_override(
|
||||
p->depsgraph, p->region, v3d, nullptr, mode, false, is_eraser ? nullptr : &p->depths);
|
||||
}
|
||||
|
||||
@@ -958,33 +958,33 @@ enum eV3DSelectObjectFilter {
|
||||
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, const Object *obact);
|
||||
|
||||
/**
|
||||
* Optionally cache data for multiple calls to #view3d_opengl_select
|
||||
* Optionally cache data for multiple calls to #view3d_gpu_select
|
||||
*
|
||||
* just avoid GPU_select headers outside this file
|
||||
*/
|
||||
void view3d_opengl_select_cache_begin();
|
||||
void view3d_opengl_select_cache_end();
|
||||
void view3d_gpu_select_cache_begin();
|
||||
void view3d_gpu_select_cache_end();
|
||||
|
||||
/**
|
||||
* \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection.
|
||||
*/
|
||||
int view3d_opengl_select_ex(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
bool do_material_slot_selection);
|
||||
int view3d_opengl_select(const ViewContext *vc,
|
||||
int view3d_gpu_select_ex(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter);
|
||||
int view3d_opengl_select_with_id_filter(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
uint select_id);
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
bool do_material_slot_selection);
|
||||
int view3d_gpu_select(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter);
|
||||
int view3d_gpu_select_with_id_filter(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
uint select_id);
|
||||
|
||||
/* `view3d_select.cc` */
|
||||
|
||||
@@ -1011,8 +1011,8 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact);
|
||||
* Use this call when executing an operator,
|
||||
* event system doesn't set for each event the OpenGL drawing context.
|
||||
*/
|
||||
void view3d_operator_needs_opengl(const bContext *C);
|
||||
void view3d_region_operator_needs_opengl(ARegion *region);
|
||||
void view3d_operator_needs_gpu(const bContext *C);
|
||||
void view3d_region_operator_needs_gpu(ARegion *region);
|
||||
|
||||
/** XXX: should move to BLI_math */
|
||||
bool edge_inside_circle(const float cent[2],
|
||||
|
||||
@@ -266,7 +266,7 @@ static void depthdropper_depth_sample_pt(bContext *C,
|
||||
/* Unfortunately it's necessary to always draw otherwise we leave stale text. */
|
||||
ED_region_tag_redraw(region);
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(
|
||||
|
||||
@@ -394,7 +394,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
|
||||
if (is_interactive) {
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
}
|
||||
|
||||
/* for re-execution, check edge index is in range before we setup ringsel */
|
||||
@@ -555,7 +555,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
lcd->vc = em_setup_viewcontext(C);
|
||||
lcd->region = lcd->vc.region;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* using the keyboard to input the number of cuts */
|
||||
/* Modal numinput active, try to handle numeric inputs first... */
|
||||
|
||||
@@ -727,7 +727,7 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
|
||||
Base *basact = BKE_view_layer_active_base_get(vc.view_layer);
|
||||
BMEditMesh *em = vc.em;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
{
|
||||
int base_index = -1;
|
||||
|
||||
@@ -1943,7 +1943,7 @@ static bool mouse_mesh_loop(
|
||||
static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
if (mouse_mesh_loop(C,
|
||||
event->mval,
|
||||
@@ -3711,7 +3711,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE
|
||||
}
|
||||
|
||||
/* #unified_findnearest needs OpenGL. */
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* Setup view context for argument to callbacks. */
|
||||
ViewContext vc = em_setup_viewcontext(C);
|
||||
|
||||
@@ -8304,7 +8304,7 @@ static int edbm_point_normals_modal(bContext *C, wmOperator *op, const wmEvent *
|
||||
|
||||
case EDBM_CLNOR_MODAL_POINTTO_SET_USE_SELECTED: {
|
||||
new_mode = EDBM_CLNOR_POINTTO_MODE_COORDINATES;
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
SelectPick_Params params{};
|
||||
params.sel_op = SEL_OP_SET;
|
||||
if (EDBM_select_pick(C, event->mval, ¶ms)) {
|
||||
|
||||
@@ -783,11 +783,11 @@ static bool ed_mball_findnearest_metaelem(bContext *C,
|
||||
|
||||
BLI_rcti_init_pt_radius(&rect, mval, 12);
|
||||
|
||||
hits = view3d_opengl_select(&vc,
|
||||
&buffer,
|
||||
&rect,
|
||||
use_cycle ? VIEW3D_SELECT_PICK_ALL : VIEW3D_SELECT_PICK_NEAREST,
|
||||
VIEW3D_SELECT_FILTER_NOP);
|
||||
hits = view3d_gpu_select(&vc,
|
||||
&buffer,
|
||||
&rect,
|
||||
use_cycle ? VIEW3D_SELECT_PICK_ALL : VIEW3D_SELECT_PICK_NEAREST,
|
||||
VIEW3D_SELECT_FILTER_NOP);
|
||||
|
||||
if (hits == 0) {
|
||||
return false;
|
||||
|
||||
@@ -2145,7 +2145,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
|
||||
XFormAxisData *xfd = static_cast<XFormAxisData *>(op->customdata);
|
||||
ARegion *region = xfd->vc.region;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
const bool is_translate = event->modifier & KM_CTRL;
|
||||
const bool is_translate_init = is_translate && (xfd->is_translate != is_translate);
|
||||
|
||||
@@ -4799,7 +4799,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
|
||||
PEData data = bedit->data;
|
||||
data.context = C; /* TODO(mai): why isn't this set in bedit->data? */
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
selected = short(count_selected_keys(scene, edit));
|
||||
|
||||
dmax = max_ff(fabsf(dx), fabsf(dy));
|
||||
|
||||
@@ -945,7 +945,7 @@ static void min_distance_edit_draw(bContext *C, int /*x*/, int /*y*/, void *cust
|
||||
RegionView3D *rv3d = op_data.rv3d;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
/* It does the same as: `view3d_operator_needs_opengl(C);`. */
|
||||
/* It does the same as: `view3d_operator_needs_gpu(C);`. */
|
||||
wmViewport(®ion->winrct);
|
||||
GPU_matrix_projection_set(rv3d->winmat);
|
||||
GPU_matrix_set(rv3d->viewmat);
|
||||
|
||||
@@ -5812,7 +5812,7 @@ void paint_proj_stroke(const bContext *C,
|
||||
float *cursor = scene->cursor.location;
|
||||
const int mval_i[2] = {int(pos[0]), int(pos[1])};
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(
|
||||
@@ -5960,7 +5960,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
|
||||
if (mode == BRUSH_STROKE_INVERT) {
|
||||
/* Bypass regular stroke logic. */
|
||||
if (ps_handle->brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_CLONE) {
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ps_handle->is_clone_cursor_pick = true;
|
||||
return ps_handle;
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ void PAINT_OT_face_select_linked(wmOperatorType *ot)
|
||||
static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
const bool select = !RNA_boolean_get(op->ptr, "deselect");
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
paintface_select_linked(C, CTX_data_active_object(C), event->mval, select);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -684,7 +684,7 @@ static int paintface_select_loop_invoke(bContext *C, wmOperator *op, const wmEve
|
||||
if (!extend) {
|
||||
paintface_deselect_all_visible(C, CTX_data_active_object(C), SEL_DESELECT, false);
|
||||
}
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
paintface_select_loop(C, CTX_data_active_object(C), event->mval, select);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -783,7 +783,7 @@ void PAINT_OT_vert_select_linked(wmOperatorType *ot)
|
||||
static int paintvert_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
const bool select = RNA_boolean_get(op->ptr, "select");
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
paintvert_select_linked_pick(C, CTX_data_active_object(C), event->mval, select);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
@@ -180,7 +180,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
int v_idx_best = -1;
|
||||
uint index;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
|
||||
|
||||
if (use_vert_sel) {
|
||||
@@ -330,7 +330,7 @@ static int weight_sample_group_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
|
||||
bool found = false;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);
|
||||
|
||||
if (use_vert_sel) {
|
||||
|
||||
@@ -1816,7 +1816,7 @@ static void wpaint_stroke_update_step(bContext *C,
|
||||
vc = &wpd->vc;
|
||||
ob = vc->obact;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
ED_view3d_init_mats_rv3d(ob, vc->rv3d);
|
||||
|
||||
mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world().ptr());
|
||||
|
||||
@@ -4927,7 +4927,7 @@ static void brush_stroke_init(bContext *C)
|
||||
const Brush *brush = BKE_paint_brush_for_read(&sd.paint);
|
||||
|
||||
if (!G.background) {
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
}
|
||||
brush_init_tex(sd, ss);
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ float strip_handle_draw_size_get(const Scene *scene, Strip *strip, float pixelx)
|
||||
/* void seq_reset_imageofs(SpaceSeq *sseq); */
|
||||
|
||||
/**
|
||||
* Rendering using opengl will change the current viewport/context.
|
||||
* Rendering using the GPU will change the current viewport/context.
|
||||
* This is why we need the \a region, to set back the render area.
|
||||
*
|
||||
* TODO: do not rely on such hack and just update the \a ibuf outside of
|
||||
|
||||
@@ -189,7 +189,7 @@ static void view3d_main_region_setup_view(Depsgraph *depsgraph,
|
||||
|
||||
ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, rect, false);
|
||||
|
||||
/* set for opengl */
|
||||
/* Set for GPU drawing. */
|
||||
GPU_matrix_projection_set(rv3d->winmat);
|
||||
GPU_matrix_set(rv3d->viewmat);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ static void view3d_main_region_setup_offscreen(Depsgraph *depsgraph,
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
ED_view3d_update_viewmat(depsgraph, scene, v3d, region, viewmat, winmat, nullptr, true);
|
||||
|
||||
/* set for opengl */
|
||||
/* Set for GPU drawing. */
|
||||
GPU_matrix_projection_set(rv3d->winmat);
|
||||
GPU_matrix_set(rv3d->viewmat);
|
||||
}
|
||||
@@ -2245,7 +2245,7 @@ static void validate_object_select_id(Depsgraph *depsgraph,
|
||||
|
||||
/* Avoid calling this function multiple times in sequence to prevent frequent CPU-GPU
|
||||
* synchronization (which can be very slow). */
|
||||
static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data)
|
||||
static void view3d_gpu_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data)
|
||||
{
|
||||
GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport);
|
||||
|
||||
@@ -2319,7 +2319,7 @@ void view3d_depths_rect_create(ARegion *region, rcti *rect, ViewDepths *r_d)
|
||||
|
||||
{
|
||||
GPUViewport *viewport = WM_draw_region_get_viewport(region);
|
||||
view3d_opengl_read_Z_pixels(viewport, rect, r_d->depths);
|
||||
view3d_gpu_read_Z_pixels(viewport, rect, r_d->depths);
|
||||
/* Range is assumed to be this as they are never changed. */
|
||||
r_d->depth_range[0] = 0.0;
|
||||
r_d->depth_range[1] = 1.0;
|
||||
|
||||
@@ -858,7 +858,7 @@ void ED_view3d_cursor3d_position(bContext *C,
|
||||
if (use_depth) { /* maybe this should be accessed some other way */
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_ALL, false, nullptr);
|
||||
|
||||
@@ -33,7 +33,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
|
||||
ED_view3d_smooth_view_force_finish(C, v3d, region);
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, true, nullptr);
|
||||
|
||||
@@ -48,7 +48,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
|
||||
float cent[2], p[3];
|
||||
|
||||
/* NOTE: otherwise opengl won't work. */
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* get box select values using rna */
|
||||
WM_operator_properties_border_to_rcti(op, &rect);
|
||||
|
||||
@@ -1469,7 +1469,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
|
||||
/* setup view context for argument to callbacks */
|
||||
@@ -2087,11 +2087,11 @@ static int mixed_bones_object_selectbuffer(const ViewContext *vc,
|
||||
}
|
||||
|
||||
/* we _must_ end cache before return, use 'goto finally' */
|
||||
view3d_opengl_select_cache_begin();
|
||||
view3d_gpu_select_cache_begin();
|
||||
|
||||
GPUSelectStorage &storage = buffer->storage;
|
||||
BLI_rcti_init_pt_radius(&rect, mval, 14);
|
||||
hits15 = view3d_opengl_select_ex(
|
||||
hits15 = view3d_gpu_select_ex(
|
||||
vc, buffer, &rect, select_mode, select_filter, do_material_slot_selection);
|
||||
if (hits15 == 1) {
|
||||
hits = selectbuffer_ret_hits_15(storage.as_mutable_span(), hits15);
|
||||
@@ -2103,7 +2103,7 @@ static int mixed_bones_object_selectbuffer(const ViewContext *vc,
|
||||
|
||||
ofs = hits15;
|
||||
BLI_rcti_init_pt_radius(&rect, mval, 9);
|
||||
hits9 = view3d_opengl_select(vc, buffer, &rect, select_mode, select_filter);
|
||||
hits9 = view3d_gpu_select(vc, buffer, &rect, select_mode, select_filter);
|
||||
if (hits9 == 1) {
|
||||
hits = selectbuffer_ret_hits_9(storage.as_mutable_span(), hits15, hits9);
|
||||
goto finally;
|
||||
@@ -2113,7 +2113,7 @@ static int mixed_bones_object_selectbuffer(const ViewContext *vc,
|
||||
|
||||
ofs += hits9;
|
||||
BLI_rcti_init_pt_radius(&rect, mval, 5);
|
||||
hits5 = view3d_opengl_select(vc, buffer, &rect, select_mode, select_filter);
|
||||
hits5 = view3d_gpu_select(vc, buffer, &rect, select_mode, select_filter);
|
||||
if (hits5 == 1) {
|
||||
hits = selectbuffer_ret_hits_5(storage.as_mutable_span(), hits15, hits9, hits5);
|
||||
goto finally;
|
||||
@@ -2151,7 +2151,7 @@ static int mixed_bones_object_selectbuffer(const ViewContext *vc,
|
||||
}
|
||||
|
||||
finally:
|
||||
view3d_opengl_select_cache_end();
|
||||
view3d_gpu_select_cache_end();
|
||||
return hits;
|
||||
}
|
||||
|
||||
@@ -2407,7 +2407,7 @@ static Base *ed_view3d_give_base_under_cursor_ex(bContext *C,
|
||||
GPUSelectBuffer buffer;
|
||||
|
||||
/* setup view context for argument to callbacks */
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
|
||||
const ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
@@ -2585,7 +2585,7 @@ static bool ed_object_select_pick(bContext *C,
|
||||
|
||||
const bool is_obedit = (vc.obedit != nullptr);
|
||||
if (object_only) {
|
||||
/* Signal for #view3d_opengl_select to skip edit-mode objects. */
|
||||
/* Signal for #view3d_gpu_select to skip edit-mode objects. */
|
||||
vc.obedit = nullptr;
|
||||
}
|
||||
|
||||
@@ -3410,7 +3410,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
|
||||
|
||||
RNA_int_get_array(op->ptr, "location", mval);
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
|
||||
if (obedit && object_only == false) {
|
||||
@@ -3985,7 +3985,7 @@ static bool do_meta_box_select(const ViewContext *vc, const rcti *rect, const eS
|
||||
GPUSelectBuffer buffer;
|
||||
int hits;
|
||||
|
||||
hits = view3d_opengl_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
|
||||
hits = view3d_gpu_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
|
||||
|
||||
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
||||
changed |= BKE_mball_deselect_all(mb);
|
||||
@@ -4053,7 +4053,7 @@ static bool do_armature_box_select(const ViewContext *vc, const rcti *rect, cons
|
||||
GPUSelectBuffer buffer;
|
||||
int hits;
|
||||
|
||||
hits = view3d_opengl_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
|
||||
hits = view3d_gpu_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP);
|
||||
|
||||
Vector<Base *> bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
|
||||
vc->scene, vc->view_layer, vc->v3d);
|
||||
@@ -4101,7 +4101,7 @@ static bool do_armature_box_select(const ViewContext *vc, const rcti *rect, cons
|
||||
* Compare result of 'GPU_select': 'GPUSelectResult',
|
||||
* needed for when we need to align with object draw-order.
|
||||
*/
|
||||
static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p)
|
||||
static int gpu_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p)
|
||||
{
|
||||
uint sel_a = ((GPUSelectResult *)sel_a_p)->id;
|
||||
uint sel_b = ((GPUSelectResult *)sel_b_p)->id;
|
||||
@@ -4130,7 +4130,7 @@ static bool do_object_box_select(bContext *C,
|
||||
GPUSelectBuffer buffer;
|
||||
const eV3DSelectObjectFilter select_filter = ED_view3d_select_filter_from_mode(vc->scene,
|
||||
vc->obact);
|
||||
const int hits = view3d_opengl_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, select_filter);
|
||||
const int hits = view3d_gpu_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, select_filter);
|
||||
BKE_view_layer_synced_ensure(vc->scene, vc->view_layer);
|
||||
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(vc->view_layer)) {
|
||||
base->object->id.tag &= ~ID_TAG_DOIT;
|
||||
@@ -4157,7 +4157,7 @@ static bool do_object_box_select(bContext *C,
|
||||
}
|
||||
|
||||
/* The draw order doesn't always match the order we populate the engine, see: #51695. */
|
||||
qsort(buffer.storage.data(), hits, sizeof(GPUSelectResult), opengl_bone_select_buffer_cmp);
|
||||
qsort(buffer.storage.data(), hits, sizeof(GPUSelectResult), gpu_bone_select_buffer_cmp);
|
||||
|
||||
for (const GPUSelectResult *buf_iter = buffer.storage.data(), *buf_end = buf_iter + hits;
|
||||
buf_iter < buf_end;
|
||||
@@ -4204,7 +4204,7 @@ static bool do_pose_box_select(bContext *C,
|
||||
GPUSelectBuffer buffer;
|
||||
const eV3DSelectObjectFilter select_filter = ED_view3d_select_filter_from_mode(vc->scene,
|
||||
vc->obact);
|
||||
const int hits = view3d_opengl_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, select_filter);
|
||||
const int hits = view3d_gpu_select(vc, &buffer, rect, VIEW3D_SELECT_ALL, select_filter);
|
||||
/*
|
||||
* NOTE(@theeth): Regarding the logic use here.
|
||||
* The buffer and #ListBase have the same relative order, which makes the selection
|
||||
@@ -4217,7 +4217,7 @@ static bool do_pose_box_select(bContext *C,
|
||||
/* no need to loop if there's no hit */
|
||||
|
||||
/* The draw order doesn't always match the order we populate the engine, see: #51695. */
|
||||
qsort(buffer.storage.data(), hits, sizeof(GPUSelectResult), opengl_bone_select_buffer_cmp);
|
||||
qsort(buffer.storage.data(), hits, sizeof(GPUSelectResult), gpu_bone_select_buffer_cmp);
|
||||
|
||||
for (const GPUSelectResult *buf_iter = buffer.storage.data(), *buf_end = buf_iter + hits;
|
||||
buf_iter < buf_end;
|
||||
@@ -4320,7 +4320,7 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op)
|
||||
wmGenericUserData wm_userdata_buf = {nullptr, nullptr, false};
|
||||
wmGenericUserData *wm_userdata = &wm_userdata_buf;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
|
||||
/* setup view context for argument to callbacks */
|
||||
@@ -5358,7 +5358,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit = vc.obedit;
|
||||
|
||||
if (obedit || BKE_paint_select_elem_test(obact) || (obact && (obact->mode & OB_MODE_POSE))) {
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
if (obedit == nullptr) {
|
||||
BKE_object_update_select_id(CTX_data_main(C));
|
||||
}
|
||||
|
||||
@@ -218,18 +218,18 @@ bool ED_view3d_viewplane_get(const Depsgraph *depsgraph,
|
||||
/** \name View State/Context Utilities
|
||||
* \{ */
|
||||
|
||||
void view3d_operator_needs_opengl(const bContext *C)
|
||||
void view3d_operator_needs_gpu(const bContext *C)
|
||||
{
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
view3d_region_operator_needs_opengl(region);
|
||||
view3d_region_operator_needs_gpu(region);
|
||||
}
|
||||
|
||||
void view3d_region_operator_needs_opengl(ARegion *region)
|
||||
void view3d_region_operator_needs_gpu(ARegion *region)
|
||||
{
|
||||
/* for debugging purpose, context should always be OK */
|
||||
if ((region == nullptr) || (region->regiontype != RGN_TYPE_WINDOW)) {
|
||||
printf("view3d_region_operator_needs_opengl error, wrong region\n");
|
||||
printf("view3d_region_operator_needs_gpu error, wrong region\n");
|
||||
}
|
||||
else {
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
|
||||
@@ -468,15 +468,15 @@ void view3d_viewmatrix_set(const Depsgraph *depsgraph,
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name OpenGL Select Utilities
|
||||
/** \name GPU Select Utilities
|
||||
* \{ */
|
||||
|
||||
void view3d_opengl_select_cache_begin()
|
||||
void view3d_gpu_select_cache_begin()
|
||||
{
|
||||
GPU_select_cache_begin();
|
||||
}
|
||||
|
||||
void view3d_opengl_select_cache_end()
|
||||
void view3d_gpu_select_cache_end()
|
||||
{
|
||||
GPU_select_cache_end();
|
||||
}
|
||||
@@ -542,12 +542,12 @@ static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void
|
||||
return ob_pose_list && (BLI_linklist_index(ob_pose_list, DEG_get_original_object(ob)) != -1);
|
||||
}
|
||||
|
||||
int view3d_opengl_select_ex(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
const bool do_material_slot_selection)
|
||||
int view3d_gpu_select_ex(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
const bool do_material_slot_selection)
|
||||
{
|
||||
bThemeState theme_state;
|
||||
const wmWindowManager *wm = CTX_wm_manager(vc->C);
|
||||
@@ -662,7 +662,7 @@ int view3d_opengl_select_ex(const ViewContext *vc,
|
||||
/* If in X-ray mode, we select the wires in priority. */
|
||||
if (XRAY_ACTIVE(v3d) && use_nearest) {
|
||||
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
|
||||
* because the OpenGL context created & destroyed inside this function. */
|
||||
* because the GPU context created & destroyed inside this function. */
|
||||
DrawSelectLoopUserData drw_select_loop_user_data = {};
|
||||
drw_select_loop_user_data.pass = 0;
|
||||
drw_select_loop_user_data.hits = 0;
|
||||
@@ -691,7 +691,7 @@ int view3d_opengl_select_ex(const ViewContext *vc,
|
||||
|
||||
if (hits == 0) {
|
||||
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
|
||||
* because the OpenGL context created & destroyed inside this function. */
|
||||
* because the GPU context created & destroyed inside this function. */
|
||||
DrawSelectLoopUserData drw_select_loop_user_data = {};
|
||||
drw_select_loop_user_data.pass = 0;
|
||||
drw_select_loop_user_data.hits = 0;
|
||||
@@ -732,24 +732,24 @@ finally:
|
||||
return hits;
|
||||
}
|
||||
|
||||
int view3d_opengl_select(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter)
|
||||
int view3d_gpu_select(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter)
|
||||
{
|
||||
return view3d_opengl_select_ex(vc, buffer, input, select_mode, select_filter, false);
|
||||
return view3d_gpu_select_ex(vc, buffer, input, select_mode, select_filter, false);
|
||||
}
|
||||
|
||||
int view3d_opengl_select_with_id_filter(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
uint select_id)
|
||||
int view3d_gpu_select_with_id_filter(const ViewContext *vc,
|
||||
GPUSelectBuffer *buffer,
|
||||
const rcti *input,
|
||||
eV3DSelectMode select_mode,
|
||||
eV3DSelectObjectFilter select_filter,
|
||||
uint select_id)
|
||||
{
|
||||
const int64_t start = buffer->storage.size();
|
||||
int hits = view3d_opengl_select(vc, buffer, input, select_mode, select_filter);
|
||||
int hits = view3d_gpu_select(vc, buffer, input, select_mode, select_filter);
|
||||
|
||||
/* Selection sometimes uses -1 for an invalid selection ID, remove these as they
|
||||
* interfere with detection of actual number of hits in the selection. */
|
||||
|
||||
@@ -661,7 +661,7 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C,
|
||||
*r_part = 0;
|
||||
|
||||
/* Set up view matrices. */
|
||||
view3d_operator_needs_opengl(C);
|
||||
view3d_operator_needs_gpu(C);
|
||||
|
||||
/* Search for 3D gizmo's that use the 2D callback for checking intersections. */
|
||||
bool has_3d = false;
|
||||
|
||||
Reference in New Issue
Block a user