DRW: Remove more DRWView getters

No functional change expected.
This commit is contained in:
Clément Foucault
2024-12-05 17:33:26 +01:00
parent 1f9ecca872
commit ad770b0359
5 changed files with 7 additions and 45 deletions

View File

@@ -82,7 +82,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd,
rescale_m4(mat, size);
/* BBox space to World. */
mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat);
if (DRW_view_is_persp_get(nullptr)) {
if (blender::draw::View::default_get().is_persp()) {
/* BBox center to camera vector. */
sub_v3_v3v3(tgp_ob->plane_normal, pd->camera_pos, mat[3]);
}

View File

@@ -182,7 +182,7 @@ static void GPENCIL_render_result_z(RenderLayer *rl,
int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
/* Convert GPU depth [0..1] to view Z [near..far] */
if (DRW_view_is_persp_get(nullptr)) {
if (blender::draw::View::default_get().is_persp()) {
for (int i = 0; i < pix_num; i++) {
if (ro_buffer_data[i] == 1.0f) {
ro_buffer_data[i] = 1e10f; /* Background */
@@ -195,8 +195,8 @@ static void GPENCIL_render_result_z(RenderLayer *rl,
}
else {
/* Keep in mind, near and far distance are negatives. */
float near = DRW_view_near_distance_get(nullptr);
float far = DRW_view_far_distance_get(nullptr);
float near = blender::draw::View::default_get().near_clip();
float far = blender::draw::View::default_get().far_clip();
float range = fabsf(far - near);
for (int i = 0; i < pix_num; i++) {

View File

@@ -680,7 +680,7 @@ static void write_render_z_output(RenderLayer *layer,
int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
/* Convert GPU depth [0..1] to view Z [near..far] */
if (DRW_view_is_persp_get(nullptr)) {
if (blender::draw::View::default_get().is_persp()) {
for (float &z : MutableSpan(rp->ibuf->float_buffer.data, pix_num)) {
if (z == 1.0f) {
z = 1e10f; /* Background */
@@ -693,8 +693,8 @@ static void write_render_z_output(RenderLayer *layer,
}
else {
/* Keep in mind, near and far distance are negatives. */
float near = DRW_view_near_distance_get(nullptr);
float far = DRW_view_far_distance_get(nullptr);
float near = blender::draw::View::default_get().near_clip();
float far = blender::draw::View::default_get().far_clip();
float range = fabsf(far - near);
for (float &z : MutableSpan(rp->ibuf->float_buffer.data, pix_num)) {

View File

@@ -340,14 +340,6 @@ void DRW_view_frustum_corners_get(const DRWView *view, BoundBox *corners);
*/
std::array<float4, 6> DRW_view_frustum_planes_get(const DRWView *view);
/**
* These are in view-space, so negative if in perspective.
* Extract near and far clip distance from the projection matrix.
*/
float DRW_view_near_distance_get(const DRWView *view);
float DRW_view_far_distance_get(const DRWView *view);
bool DRW_view_is_persp_get(const DRWView *view);
/* Culling, return true if object is inside view frustum. */
/**

View File

@@ -409,34 +409,4 @@ std::array<float4, 6> DRW_view_frustum_planes_get(const DRWView *view)
return planes;
}
bool DRW_view_is_persp_get(const DRWView *view)
{
view = (view) ? view : DST.view_default;
return view->storage.winmat[3][3] == 0.0f;
}
float DRW_view_near_distance_get(const DRWView *view)
{
view = (view) ? view : DST.view_default;
const float4x4 &projmat = view->storage.winmat;
if (DRW_view_is_persp_get(view)) {
return -projmat[3][2] / (projmat[2][2] - 1.0f);
}
return -(projmat[3][2] + 1.0f) / projmat[2][2];
}
float DRW_view_far_distance_get(const DRWView *view)
{
view = (view) ? view : DST.view_default;
const float4x4 &projmat = view->storage.winmat;
if (DRW_view_is_persp_get(view)) {
return -projmat[3][2] / (projmat[2][2] + 1.0f);
}
return -(projmat[3][2] - 1.0f) / projmat[2][2];
}
/** \} */