Revert "3D View: Do not recalculate the depth buffer for 'Auto Depth'"

This reverts commit d33eb78de3 and c26efccf61

They came in without a review.
This commit is contained in:
Germano Cavalcante 2023-09-29 17:55:50 -03:00
parent c26efccf61
commit 90ec11b823
7 changed files with 16 additions and 41 deletions

View File

@ -849,15 +849,18 @@ 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.
*
* \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(ARegion *region,
bool ED_view3d_autodist(Depsgraph *depsgraph,
ARegion *region,
View3D *v3d,
const int mval[2],
float mouse_worldloc[3],
bool alphaoverride,
const float fallback_depth_pt[3]);
/**

View File

@ -177,9 +177,7 @@ static void depthdropper_depth_sample_pt(bContext *C,
view3d_operator_needs_opengl(C);
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
if (ED_view3d_autodist(region, v3d, mval, co, nullptr)) {
if (ED_view3d_autodist(depsgraph, region, v3d, mval, co, true, nullptr)) {
const float mval_center_fl[2] = {float(region->winx) / 2, float(region->winy) / 2};
float co_align[3];

View File

@ -5831,10 +5831,7 @@ void paint_proj_stroke(const bContext *C,
view3d_operator_needs_opengl(C);
/* Get Z Depths, needed for perspective, nice for ortho */
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
if (!ED_view3d_autodist(region, v3d, mval_i, cursor, nullptr)) {
if (!ED_view3d_autodist(depsgraph, region, v3d, mval_i, cursor, false, nullptr)) {
return;
}

View File

@ -854,10 +854,7 @@ void ED_view3d_cursor3d_position(bContext *C,
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
view3d_operator_needs_opengl(C);
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
if (ED_view3d_autodist(region, v3d, mval, cursor_co, nullptr)) {
if (ED_view3d_autodist(depsgraph, region, v3d, mval, cursor_co, true, nullptr)) {
depth_used = true;
}
}

View File

@ -31,8 +31,6 @@
#include "DEG_depsgraph_query.hh"
#include "DRW_engine.h"
#include "ED_mesh.hh"
#include "ED_particle.hh"
#include "ED_screen.hh"
@ -220,31 +218,11 @@ static eViewOpsFlag navigate_pivot_get(bContext *C,
ED_view3d_autodist_last_get(win, r_pivot);
}
else {
/* TODO: Implement 'Alpha Override'. We don't want to zoom into billboards. */
float fallback_depth_pt[3];
negate_v3_v3(fallback_depth_pt, static_cast<RegionView3D *>(region->regiondata)->ofs);
const char *engine_name = DEG_get_evaluated_scene(depsgraph)->r.engine;
bool has_overlays = !(v3d->flag2 & V3D_HIDE_OVERLAYS);
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 &&
strcmp(engine_name, RE_engine_id_BLENDER_EEVEE) == 0;
bool is_viewport_render_workbench = v3d->shading.type == OB_RENDER &&
strcmp(engine_name, RE_engine_id_BLENDER_WORKBENCH) == 0;
bool has_depth_buffer = has_overlays || is_viewport_preview_solid ||
is_viewport_preview_material || is_viewport_wire_no_xray ||
is_viewport_render_eevee || is_viewport_render_workbench;
if (!has_depth_buffer) {
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);
const bool is_set = ED_view3d_autodist(
depsgraph, region, v3d, event->mval, r_pivot, true, fallback_depth_pt);
ED_view3d_autodist_last_set(win, event, r_pivot, is_set);
}

View File

@ -64,10 +64,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
view3d_operator_needs_opengl(C);
/* Get Z Depths, needed for perspective, nice for ortho */
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, nullptr);
if (ED_view3d_autodist(region, v3d, event->mval, new_ofs, nullptr)) {
if (ED_view3d_autodist(depsgraph, region, v3d, event->mval, new_ofs, false, nullptr)) {
/* pass */
}
else {

View File

@ -1106,16 +1106,21 @@ static float view_autodist_depth_margin(ARegion *region, const int mval[2], int
return depth_close;
}
bool ED_view3d_autodist(ARegion *region,
bool ED_view3d_autodist(Depsgraph *depsgraph,
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 {