DRW: Invalid clip data if view is from planar reflection

The plane and corner extraction code was just not correct.

Fix #122067
Pull Request: https://projects.blender.org/blender/blender/pulls/122516
This commit is contained in:
Clément Foucault 2024-05-31 16:15:52 +02:00 committed by Clément Foucault
parent 5f11ae70ea
commit 62bfb3623d

@ -80,14 +80,10 @@ void View::frustum_boundbox_calc(int view_id)
corners[1][1] = corners[5][1] = bottom;
corners[2][1] = corners[6][1] = top;
const float4x4 &view_inv = data_[view_id].viewinv;
/* Transform into world space. */
for (float4 &corner : corners) {
mul_m4_v3(data_[view_id].viewinv.ptr(), corner);
corner.w = 1.0;
/* Special case for planar reflection. */
if (is_inverted_) {
corner.z = -corner.z;
}
corner = float4(math::transform_point(view_inv, float3(corner)), 1.0);
}
}
@ -101,15 +97,9 @@ void View::frustum_culling_planes_calc(int view_id)
culling_[view_id].frustum_planes.planes[3],
culling_[view_id].frustum_planes.planes[4],
culling_[view_id].frustum_planes.planes[2]);
/* Normalize. */
for (float4 &plane : culling_[view_id].frustum_planes.planes) {
plane.w /= normalize_v3(plane);
/* Special case for planar reflection. */
if (is_inverted_) {
plane.z = -plane.z;
}
plane /= math::length(plane.xyz());
}
}