3D View: Do not recalculate the depth buffer for 'Auto Depth' #113026
|
@ -188,6 +188,8 @@ enum eV3DDepthOverrideMode {
|
|||
};
|
||||
/**
|
||||
* Redraw the viewport depth buffer.
|
||||
* Call #view3d_has_depth_buffer_being_used if you want to check if the viewport already has depth
|
||||
* buffer updated.
|
||||
*/
|
||||
void ED_view3d_depth_override(Depsgraph *depsgraph,
|
||||
ARegion *region,
|
||||
|
@ -209,6 +211,8 @@ bool ED_view3d_depth_unproject_v3(const ARegion *region,
|
|||
double depth,
|
||||
float r_location_world[3]);
|
||||
|
||||
bool view3d_has_depth_buffer_being_used(const Depsgraph *depsgraph, const View3D *v3d);
|
||||
|
||||
|
||||
/**
|
||||
* Utilities to perform navigation.
|
||||
* Call `ED_view3d_navigation_init` to create a context and `ED_view3d_navigation_do` to perform
|
||||
|
@ -850,18 +854,16 @@ void ED_view3d_autodist_last_clear(wmWindow *win);
|
|||
|
||||
/**
|
||||
* Get the world-space 3d location from a screen-space 2d point.
|
||||
* TODO: Implement #alphaoverride. We don't want to zoom into billboards.
|
||||
* It may be useful to call #ED_view3d_depth_override before.
|
||||
*
|
||||
* \param mval: Input screen-space pixel location.
|
||||
* \param mouse_worldloc: Output world-space location.
|
||||
* \param fallback_depth_pt: Use this points depth when no depth can be found.
|
||||
*/
|
||||
bool ED_view3d_autodist(Depsgraph *depsgraph,
|
||||
ARegion *region,
|
||||
bool ED_view3d_autodist(ARegion *region,
|
||||
View3D *v3d,
|
||||
const int mval[2],
|
||||
float mouse_worldloc[3],
|
||||
bool alphaoverride,
|
||||
const float fallback_depth_pt[3]);
|
||||
|
||||
/**
|
||||
|
|
|
@ -179,7 +179,10 @@ static void depthdropper_depth_sample_pt(bContext *C,
|
|||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
if (ED_view3d_autodist(depsgraph, region, v3d, mval, co, true, nullptr)) {
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||
|
||||
if (ED_view3d_autodist(region, v3d, mval, co, nullptr)) {
|
||||
const float mval_center_fl[2] = {float(region->winx) / 2, float(region->winy) / 2};
|
||||
float co_align[3];
|
||||
|
||||
|
|
|
@ -5800,7 +5800,10 @@ void paint_proj_stroke(const bContext *C,
|
|||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
if (!ED_view3d_autodist(depsgraph, region, v3d, mval_i, cursor, false, nullptr)) {
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||
|
||||
if (!ED_view3d_autodist(region, v3d, mval_i, cursor, nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2440,6 +2440,28 @@ void ED_view3d_depths_free(ViewDepths *depths)
|
|||
MEM_freeN(depths);
|
||||
}
|
||||
|
||||
bool ED_view3d_has_depth_buffer_being_used(const Depsgraph *depsgraph, const View3D *v3d)
|
||||
{
|
||||
const char *engine_name = DEG_get_evaluated_scene(depsgraph)->r.engine;
|
||||
RenderEngineType *engine_type = RE_engines_find(engine_name);
|
||||
|
||||
bool is_viewport_wire_no_xray = v3d->shading.type < OB_SOLID && !XRAY_ENABLED(v3d);
|
||||
bool is_viewport_preview_solid = v3d->shading.type == OB_SOLID;
|
||||
bool is_viewport_preview_material = v3d->shading.type == OB_MATERIAL;
|
||||
bool is_viewport_render_eevee = v3d->shading.type == OB_RENDER &&
|
||||
(STREQ(engine_name, RE_engine_id_BLENDER_EEVEE) ||
|
||||
STREQ(engine_name, RE_engine_id_BLENDER_EEVEE_NEXT));
|
||||
bool is_viewport_render_workbench = v3d->shading.type == OB_RENDER &&
|
||||
STREQ(engine_name, RE_engine_id_BLENDER_WORKBENCH);
|
||||
bool is_viewport_render_external_with_overlay = v3d->shading.type == OB_RENDER &&
|
||||
!(engine_type->flag & RE_INTERNAL) &&
|
||||
!(v3d->flag2 & V3D_HIDE_OVERLAYS);
|
||||
|
||||
return is_viewport_preview_solid || is_viewport_preview_material || is_viewport_wire_no_xray ||
|
||||
is_viewport_render_eevee || is_viewport_render_workbench ||
|
||||
is_viewport_render_external_with_overlay;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
|
@ -854,7 +854,11 @@ void ED_view3d_cursor3d_position(bContext *C,
|
|||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
if (ED_view3d_autodist(depsgraph, region, v3d, mval, cursor_co, true, nullptr)) {
|
||||
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||
|
||||
if (ED_view3d_autodist(region, v3d, mval, cursor_co, nullptr)) {
|
||||
depth_used = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,19 +8,15 @@
|
|||
|
||||
#include "DNA_curve_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_math_geom.h"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_layer.hh"
|
||||
#include "BKE_object.hh"
|
||||
#include "BKE_object_types.hh"
|
||||
#include "BKE_paint.hh"
|
||||
#include "BKE_vfont.hh"
|
||||
|
||||
|
@ -210,8 +206,11 @@ static eViewOpsFlag navigate_pivot_get(bContext *C,
|
|||
float fallback_depth_pt[3];
|
||||
negate_v3_v3(fallback_depth_pt, static_cast<RegionView3D *>(region->regiondata)->ofs);
|
||||
|
||||
const bool is_set = ED_view3d_autodist(
|
||||
depsgraph, region, v3d, event->mval, r_pivot, true, fallback_depth_pt);
|
||||
if (!ED_view3d_has_depth_buffer_being_used(depsgraph, v3d)) {
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||
}
|
||||
|
||||
const bool is_set = ED_view3d_autodist(region, v3d, event->mval, r_pivot, fallback_depth_pt);
|
||||
|
||||
ED_view3d_autodist_last_set(win, event, r_pivot, is_set);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,10 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
|||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
if (ED_view3d_autodist(depsgraph, region, v3d, event->mval, new_ofs, false, nullptr)) {
|
||||
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||
|
||||
if (ED_view3d_autodist(region, v3d, event->mval, new_ofs, nullptr)) {
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1101,21 +1101,16 @@ static float view_autodist_depth_margin(ARegion *region, const int mval[2], int
|
|||
return depth_close;
|
||||
}
|
||||
|
||||
bool ED_view3d_autodist(Depsgraph *depsgraph,
|
||||
ARegion *region,
|
||||
bool ED_view3d_autodist(ARegion *region,
|
||||
View3D *v3d,
|
||||
const int mval[2],
|
||||
float mouse_worldloc[3],
|
||||
const bool /*alphaoverride*/,
|
||||
const float fallback_depth_pt[3])
|
||||
{
|
||||
float depth_close;
|
||||
int margin_arr[] = {0, 2, 4};
|
||||
bool depth_ok = false;
|
||||
|
||||
/* Get Z Depths, needed for perspective, nice for ortho */
|
||||
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
|
||||
|
||||
/* Attempt with low margin's first */
|
||||
int i = 0;
|
||||
do {
|
||||
|
|
Loading…
Reference in New Issue
Shouldn't it have the
ED
prefix since it's a public API function?