diff --git a/include/rendering/frustum.hpp b/include/rendering/frustum.hpp index 80c123e0..15b66893 100644 --- a/include/rendering/frustum.hpp +++ b/include/rendering/frustum.hpp @@ -33,12 +33,12 @@ struct Plane { class Frustum { public: enum Side { - LEFT = 0, - RIGHT, - BOTTOM, - TOP, - NEAR, - FAR + PLANE_LEFT = 0, + PLANE_RIGHT, + PLANE_BOTTOM, + PLANE_TOP, + PLANE_NEAR, + PLANE_FAR }; Frustum() = default; diff --git a/src/rendering/frustum.cpp b/src/rendering/frustum.cpp index 45e9ff60..5df490fc 100644 --- a/src/rendering/frustum.cpp +++ b/src/rendering/frustum.cpp @@ -16,50 +16,50 @@ void Frustum::extractFromMatrix(const glm::mat4& vp) { // assignments so the enum names match the geometric meaning.) // Left plane: row4 + row1 (x_clip >= -w_clip) - planes[LEFT].normal.x = vp[0][3] + vp[0][0]; - planes[LEFT].normal.y = vp[1][3] + vp[1][0]; - planes[LEFT].normal.z = vp[2][3] + vp[2][0]; - planes[LEFT].distance = vp[3][3] + vp[3][0]; - normalizePlane(planes[LEFT]); + planes[PLANE_LEFT].normal.x = vp[0][3] + vp[0][0]; + planes[PLANE_LEFT].normal.y = vp[1][3] + vp[1][0]; + planes[PLANE_LEFT].normal.z = vp[2][3] + vp[2][0]; + planes[PLANE_LEFT].distance = vp[3][3] + vp[3][0]; + normalizePlane(planes[PLANE_LEFT]); // Right plane: row4 - row1 (x_clip <= w_clip) - planes[RIGHT].normal.x = vp[0][3] - vp[0][0]; - planes[RIGHT].normal.y = vp[1][3] - vp[1][0]; - planes[RIGHT].normal.z = vp[2][3] - vp[2][0]; - planes[RIGHT].distance = vp[3][3] - vp[3][0]; - normalizePlane(planes[RIGHT]); + planes[PLANE_RIGHT].normal.x = vp[0][3] - vp[0][0]; + planes[PLANE_RIGHT].normal.y = vp[1][3] - vp[1][0]; + planes[PLANE_RIGHT].normal.z = vp[2][3] - vp[2][0]; + planes[PLANE_RIGHT].distance = vp[3][3] - vp[3][0]; + normalizePlane(planes[PLANE_RIGHT]); // With the Vulkan Y-flip (proj[1][1] negated), row4+row2 extracts // what is geometrically the TOP plane and row4-row2 extracts BOTTOM. // Swap the assignments so enum labels match geometry. // Top plane (geometric): row4 - row2 after Y-flip - planes[TOP].normal.x = vp[0][3] + vp[0][1]; - planes[TOP].normal.y = vp[1][3] + vp[1][1]; - planes[TOP].normal.z = vp[2][3] + vp[2][1]; - planes[TOP].distance = vp[3][3] + vp[3][1]; - normalizePlane(planes[TOP]); + planes[PLANE_TOP].normal.x = vp[0][3] + vp[0][1]; + planes[PLANE_TOP].normal.y = vp[1][3] + vp[1][1]; + planes[PLANE_TOP].normal.z = vp[2][3] + vp[2][1]; + planes[PLANE_TOP].distance = vp[3][3] + vp[3][1]; + normalizePlane(planes[PLANE_TOP]); // Bottom plane (geometric): row4 + row2 after Y-flip - planes[BOTTOM].normal.x = vp[0][3] - vp[0][1]; - planes[BOTTOM].normal.y = vp[1][3] - vp[1][1]; - planes[BOTTOM].normal.z = vp[2][3] - vp[2][1]; - planes[BOTTOM].distance = vp[3][3] - vp[3][1]; - normalizePlane(planes[BOTTOM]); + planes[PLANE_BOTTOM].normal.x = vp[0][3] - vp[0][1]; + planes[PLANE_BOTTOM].normal.y = vp[1][3] - vp[1][1]; + planes[PLANE_BOTTOM].normal.z = vp[2][3] - vp[2][1]; + planes[PLANE_BOTTOM].distance = vp[3][3] - vp[3][1]; + normalizePlane(planes[PLANE_BOTTOM]); // Near plane: row3 (z_clip >= 0 in Vulkan depth [0,1]) - planes[NEAR].normal.x = vp[0][2]; - planes[NEAR].normal.y = vp[1][2]; - planes[NEAR].normal.z = vp[2][2]; - planes[NEAR].distance = vp[3][2]; - normalizePlane(planes[NEAR]); + planes[PLANE_NEAR].normal.x = vp[0][2]; + planes[PLANE_NEAR].normal.y = vp[1][2]; + planes[PLANE_NEAR].normal.z = vp[2][2]; + planes[PLANE_NEAR].distance = vp[3][2]; + normalizePlane(planes[PLANE_NEAR]); // Far plane: row4 - row3 (z_clip <= w_clip) - planes[FAR].normal.x = vp[0][3] - vp[0][2]; - planes[FAR].normal.y = vp[1][3] - vp[1][2]; - planes[FAR].normal.z = vp[2][3] - vp[2][2]; - planes[FAR].distance = vp[3][3] - vp[3][2]; - normalizePlane(planes[FAR]); + planes[PLANE_FAR].normal.x = vp[0][3] - vp[0][2]; + planes[PLANE_FAR].normal.y = vp[1][3] - vp[1][2]; + planes[PLANE_FAR].normal.z = vp[2][3] - vp[2][2]; + planes[PLANE_FAR].distance = vp[3][3] - vp[3][2]; + normalizePlane(planes[PLANE_FAR]); } void Frustum::normalizePlane(Plane& plane) {