From a12f0862c9db66c7002c1e536311e38677d9cae3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 26 Mar 2017 17:12:20 +0200 Subject: [PATCH] - remove softpoly intersection math class --- src/CMakeLists.txt | 1 - src/polyrenderer/drawers/poly_draw_args.cpp | 10 +- src/polyrenderer/drawers/poly_draw_args.h | 11 +- src/polyrenderer/math/poly_intersection.cpp | 235 -------------------- src/polyrenderer/math/poly_intersection.h | 179 --------------- src/polyrenderer/poly_all.cpp | 1 - src/polyrenderer/poly_renderer.cpp | 2 +- src/polyrenderer/scene/poly_cull.cpp | 17 +- src/polyrenderer/scene/poly_cull.h | 6 +- src/polyrenderer/scene/poly_decal.cpp | 6 +- src/polyrenderer/scene/poly_decal.h | 6 +- src/polyrenderer/scene/poly_particle.cpp | 4 +- src/polyrenderer/scene/poly_particle.h | 4 +- src/polyrenderer/scene/poly_plane.cpp | 10 +- src/polyrenderer/scene/poly_plane.h | 7 +- src/polyrenderer/scene/poly_portal.cpp | 14 +- src/polyrenderer/scene/poly_scene.cpp | 8 +- src/polyrenderer/scene/poly_scene.h | 5 +- src/polyrenderer/scene/poly_sky.cpp | 2 +- src/polyrenderer/scene/poly_sprite.cpp | 5 +- src/polyrenderer/scene/poly_sprite.h | 4 +- src/polyrenderer/scene/poly_wall.cpp | 8 +- src/polyrenderer/scene/poly_wall.h | 7 +- src/polyrenderer/scene/poly_wallsprite.cpp | 4 +- src/polyrenderer/scene/poly_wallsprite.h | 4 +- 25 files changed, 59 insertions(+), 501 deletions(-) delete mode 100644 src/polyrenderer/math/poly_intersection.cpp delete mode 100644 src/polyrenderer/math/poly_intersection.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0100d5c31..3a3efad30 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -872,7 +872,6 @@ set( POLYRENDER_SOURCES polyrenderer/drawers/poly_draw_args.cpp polyrenderer/drawers/screen_triangle.cpp polyrenderer/math/tri_matrix.cpp - polyrenderer/math/poly_intersection.cpp ) # These files will be flagged as "headers" so that they appear in project files diff --git a/src/polyrenderer/drawers/poly_draw_args.cpp b/src/polyrenderer/drawers/poly_draw_args.cpp index e647b203a..eaa812dc9 100644 --- a/src/polyrenderer/drawers/poly_draw_args.cpp +++ b/src/polyrenderer/drawers/poly_draw_args.cpp @@ -37,12 +37,12 @@ #include "poly_draw_args.h" #include "swrenderer/viewport/r_viewport.h" -void PolyDrawArgs::SetClipPlane(float a, float b, float c, float d) +void PolyDrawArgs::SetClipPlane(const PolyClipPlane &plane) { - mClipPlane[0] = a; - mClipPlane[1] = b; - mClipPlane[2] = c; - mClipPlane[3] = d; + mClipPlane[0] = plane.A; + mClipPlane[1] = plane.B; + mClipPlane[2] = plane.C; + mClipPlane[3] = plane.D; } void PolyDrawArgs::SetTexture(FTexture *texture) diff --git a/src/polyrenderer/drawers/poly_draw_args.h b/src/polyrenderer/drawers/poly_draw_args.h index 84645adef..20c73ec58 100644 --- a/src/polyrenderer/drawers/poly_draw_args.h +++ b/src/polyrenderer/drawers/poly_draw_args.h @@ -36,10 +36,19 @@ enum class PolyDrawMode TriangleStrip }; +class PolyClipPlane +{ +public: + PolyClipPlane() : A(0.0f), B(0.0f), C(0.0f), D(1.0f) { } + PolyClipPlane(float a, float b, float c, float d) : A(a), B(b), C(c), D(d) { } + + float A, B, C, D; +}; + class PolyDrawArgs { public: - void SetClipPlane(float a, float b, float c, float d); + void SetClipPlane(const PolyClipPlane &plane); void SetTexture(FTexture *texture); void SetTexture(FTexture *texture, uint32_t translationID, bool forcePal = false); void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed); diff --git a/src/polyrenderer/math/poly_intersection.cpp b/src/polyrenderer/math/poly_intersection.cpp deleted file mode 100644 index ed5e8ef43..000000000 --- a/src/polyrenderer/math/poly_intersection.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* -** Various 3D intersection tests -** Copyright (c) 1997-2015 The UICore Team -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#include -#include "templates.h" -#include "doomdef.h" -#include "poly_intersection.h" - -IntersectionTest::Result IntersectionTest::plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb) -{ - Vec3f center = aabb.center(); - Vec3f extents = aabb.extents(); - float e = extents.x * std::abs(plane.x) + extents.y * std::abs(plane.y) + extents.z * std::abs(plane.z); - float s = center.x * plane.x + center.y * plane.y + center.z * plane.z + plane.w; - if (s - e > 0) - return inside; - else if (s + e < 0) - return outside; - else - return intersecting; -} - -IntersectionTest::Result IntersectionTest::plane_obb(const Vec4f &plane, const OrientedBoundingBox &obb) -{ - Vec3f n(plane); - float d = plane.w; - float e = obb.extents.x * std::abs(Vec3f::dot(obb.axis_x, n)) + obb.extents.y * std::abs(Vec3f::dot(obb.axis_y, n)) + obb.extents.z * std::abs(Vec3f::dot(obb.axis_z, n)); - float s = Vec3f::dot(obb.center, n) + d; - if (s - e > 0) - return inside; - else if (s + e < 0) - return outside; - else - return intersecting; -} - -IntersectionTest::OverlapResult IntersectionTest::sphere(const Vec3f ¢er1, float radius1, const Vec3f ¢er2, float radius2) -{ - Vec3f h = center1 - center2; - float square_distance = Vec3f::dot(h, h); - float radius_sum = radius1 + radius2; - if (square_distance > radius_sum * radius_sum) - return disjoint; - else - return overlap; -} - -IntersectionTest::OverlapResult IntersectionTest::sphere_aabb(const Vec3f ¢er, float radius, const AxisAlignedBoundingBox &aabb) -{ - Vec3f a = aabb.aabb_min - center; - Vec3f b = center - aabb.aabb_max; - a.x = std::max(a.x, 0.0f); - a.y = std::max(a.y, 0.0f); - a.z = std::max(a.z, 0.0f); - b.x = std::max(b.x, 0.0f); - b.y = std::max(b.y, 0.0f); - b.z = std::max(b.z, 0.0f); - Vec3f e = a + b; - float d = Vec3f::dot(e, e); - if (d > radius * radius) - return disjoint; - else - return overlap; -} - -IntersectionTest::OverlapResult IntersectionTest::aabb(const AxisAlignedBoundingBox &a, const AxisAlignedBoundingBox &b) -{ - if (a.aabb_min.x > b.aabb_max.x || b.aabb_min.x > a.aabb_max.x || - a.aabb_min.y > b.aabb_max.y || b.aabb_min.y > a.aabb_max.y || - a.aabb_min.z > b.aabb_max.z || b.aabb_min.z > a.aabb_max.z) - { - return disjoint; - } - else - { - return overlap; - } -} - -IntersectionTest::Result IntersectionTest::frustum_aabb(const FrustumPlanes &frustum, const AxisAlignedBoundingBox &box) -{ - bool is_intersecting = false; - for (int i = 0; i < 6; i++) - { - Result result = plane_aabb(frustum.planes[i], box); - if (result == outside) - return outside; - else if (result == intersecting) - is_intersecting = true; - break; - } - if (is_intersecting) - return intersecting; - else - return inside; -} - -IntersectionTest::Result IntersectionTest::frustum_obb(const FrustumPlanes &frustum, const OrientedBoundingBox &box) -{ - bool is_intersecting = false; - for (int i = 0; i < 6; i++) - { - Result result = plane_obb(frustum.planes[i], box); - if (result == outside) - return outside; - else if (result == intersecting) - is_intersecting = true; - } - if (is_intersecting) - return intersecting; - else - return inside; -} - -IntersectionTest::OverlapResult IntersectionTest::ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &aabb) -{ - Vec3f c = (ray_start + ray_end) * 0.5f; - Vec3f w = ray_end - c; - Vec3f h = aabb.extents(); - - c -= aabb.center(); - - Vec3f v(std::abs(w.x), std::abs(w.y), std::abs(w.z)); - - if (std::abs(c.x) > v.x + h.x || std::abs(c.y) > v.y + h.y || std::abs(c.z) > v.z + h.z) - return disjoint; - - if (std::abs(c.y * w.z - c.z * w.y) > h.y * v.z + h.z * v.y || - std::abs(c.x * w.z - c.z * w.x) > h.x * v.z + h.z * v.x || - std::abs(c.x * w.y - c.y * w.x) > h.x * v.y + h.y * v.x) - return disjoint; - - return overlap; -} - -///////////////////////////////////////////////////////////////////////////// - -FrustumPlanes::FrustumPlanes() -{ -} - -FrustumPlanes::FrustumPlanes(const Mat4f &world_to_projection) -{ - planes[0] = near_frustum_plane(world_to_projection); - planes[1] = far_frustum_plane(world_to_projection); - planes[2] = left_frustum_plane(world_to_projection); - planes[3] = right_frustum_plane(world_to_projection); - planes[4] = top_frustum_plane(world_to_projection); - planes[5] = bottom_frustum_plane(world_to_projection); -} - -Vec4f FrustumPlanes::left_frustum_plane(const Mat4f &m) -{ - Vec4f plane( - m.matrix[3 + 0 * 4] + m.matrix[0 + 0 * 4], - m.matrix[3 + 1 * 4] + m.matrix[0 + 1 * 4], - m.matrix[3 + 2 * 4] + m.matrix[0 + 2 * 4], - m.matrix[3 + 3 * 4] + m.matrix[0 + 3 * 4]); - plane /= plane.length3(); - return plane; -} - -Vec4f FrustumPlanes::right_frustum_plane(const Mat4f &m) -{ - Vec4f plane( - m.matrix[3 + 0 * 4] - m.matrix[0 + 0 * 4], - m.matrix[3 + 1 * 4] - m.matrix[0 + 1 * 4], - m.matrix[3 + 2 * 4] - m.matrix[0 + 2 * 4], - m.matrix[3 + 3 * 4] - m.matrix[0 + 3 * 4]); - plane /= plane.length3(); - return plane; -} - -Vec4f FrustumPlanes::top_frustum_plane(const Mat4f &m) -{ - Vec4f plane( - m.matrix[3 + 0 * 4] - m.matrix[1 + 0 * 4], - m.matrix[3 + 1 * 4] - m.matrix[1 + 1 * 4], - m.matrix[3 + 2 * 4] - m.matrix[1 + 2 * 4], - m.matrix[3 + 3 * 4] - m.matrix[1 + 3 * 4]); - plane /= plane.length3(); - return plane; -} - -Vec4f FrustumPlanes::bottom_frustum_plane(const Mat4f &m) -{ - Vec4f plane( - m.matrix[3 + 0 * 4] + m.matrix[1 + 0 * 4], - m.matrix[3 + 1 * 4] + m.matrix[1 + 1 * 4], - m.matrix[3 + 2 * 4] + m.matrix[1 + 2 * 4], - m.matrix[3 + 3 * 4] + m.matrix[1 + 3 * 4]); - plane /= plane.length3(); - return plane; -} - -Vec4f FrustumPlanes::near_frustum_plane(const Mat4f &m) -{ - Vec4f plane( - m.matrix[3 + 0 * 4] + m.matrix[2 + 0 * 4], - m.matrix[3 + 1 * 4] + m.matrix[2 + 1 * 4], - m.matrix[3 + 2 * 4] + m.matrix[2 + 2 * 4], - m.matrix[3 + 3 * 4] + m.matrix[2 + 3 * 4]); - plane /= plane.length3(); - return plane; -} - -Vec4f FrustumPlanes::far_frustum_plane(const Mat4f &m) -{ - Vec4f plane( - m.matrix[3 + 0 * 4] - m.matrix[2 + 0 * 4], - m.matrix[3 + 1 * 4] - m.matrix[2 + 1 * 4], - m.matrix[3 + 2 * 4] - m.matrix[2 + 2 * 4], - m.matrix[3 + 3 * 4] - m.matrix[2 + 3 * 4]); - plane /= plane.length3(); - return plane; -} diff --git a/src/polyrenderer/math/poly_intersection.h b/src/polyrenderer/math/poly_intersection.h deleted file mode 100644 index 438146fce..000000000 --- a/src/polyrenderer/math/poly_intersection.h +++ /dev/null @@ -1,179 +0,0 @@ -/* -** Various 3D intersection tests -** Copyright (c) 1997-2015 The UICore Team -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#pragma once - -#include "polyrenderer/drawers/poly_triangle.h" -#include -#include - -class Vec3f; - -class Vec4f -{ -public: - Vec4f() = default; - Vec4f(const Vec4f &) = default; - Vec4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } - Vec4f(float v) : x(v), y(v), z(v), w(v) { } - Vec4f(const Vec3f &xyz, float w); - - static float dot(const Vec4f &a, const Vec4f &b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } - static float dot3(const Vec4f &a, const Vec4f &b) { return a.x * b.x + a.y * b.y + a.z * b.z; } - float length3() const { return std::sqrt(dot3(*this, *this)); } - float magnitude() const { return std::sqrt(dot(*this, *this)); } - - Vec4f &operator+=(const Vec4f &b) { *this = Vec4f(x + b.x, y + b.y, z + b.z, w + b.w); return *this; } - Vec4f &operator-=(const Vec4f &b) { *this = Vec4f(x - b.x, y - b.y, z - b.z, w - b.w); return *this; } - Vec4f &operator*=(const Vec4f &b) { *this = Vec4f(x * b.x, y * b.y, z * b.z, w * b.w); return *this; } - Vec4f &operator/=(const Vec4f &b) { *this = Vec4f(x / b.x, y / b.y, z / b.z, w / b.w); return *this; } - Vec4f &operator+=(float b) { *this = Vec4f(x + b, y + b, z + b, w + b); return *this; } - Vec4f &operator-=(float b) { *this = Vec4f(x - b, y - b, z - b, w - b); return *this; } - Vec4f &operator*=(float b) { *this = Vec4f(x * b, y * b, z * b, w * b); return *this; } - Vec4f &operator/=(float b) { *this = Vec4f(x / b, y / b, z / b, w / b); return *this; } - - float x, y, z, w; -}; - -inline bool operator==(const Vec4f &a, const Vec4f &b) { return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w; } -inline bool operator!=(const Vec4f &a, const Vec4f &b) { return a.x != b.x || a.y != b.y || a.z != b.z || a.w == b.w; } - -class Vec3f -{ -public: - Vec3f() = default; - Vec3f(const Vec3f &) = default; - Vec3f(const Vec4f &v) : x(v.x), y(v.y), z(v.z) { } - Vec3f(float x, float y, float z) : x(x), y(y), z(z) { } - Vec3f(float v) : x(v), y(v), z(v) { } - - static float dot(const Vec3f &a, const Vec3f &b) { return a.x * b.x + a.y * b.y + a.z * b.z; } - float length() const { return std::sqrt(dot(*this, *this)); } - - Vec3f &operator+=(const Vec3f &b) { *this = Vec3f(x + b.x, y + b.y, z + b.z); return *this; } - Vec3f &operator-=(const Vec3f &b) { *this = Vec3f(x - b.x, y - b.y, z - b.z); return *this; } - Vec3f &operator*=(const Vec3f &b) { *this = Vec3f(x * b.x, y * b.y, z * b.z); return *this; } - Vec3f &operator/=(const Vec3f &b) { *this = Vec3f(x / b.x, y / b.y, z / b.z); return *this; } - Vec3f &operator+=(float b) { *this = Vec3f(x + b, y + b, z + b); return *this; } - Vec3f &operator-=(float b) { *this = Vec3f(x - b, y - b, z - b); return *this; } - Vec3f &operator*=(float b) { *this = Vec3f(x * b, y * b, z * b); return *this; } - Vec3f &operator/=(float b) { *this = Vec3f(x / b, y / b, z / b); return *this; } - - float x, y, z; -}; - -inline bool operator==(const Vec3f &a, const Vec3f &b) { return a.x == b.x && a.y == b.y && a.z == b.z; } -inline bool operator!=(const Vec3f &a, const Vec3f &b) { return a.x != b.x || a.y != b.y || a.z != b.z; } - -inline Vec3f operator+(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x + b.x, a.y + b.y, a.z + b.z); } -inline Vec3f operator-(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x - b.x, a.y - b.y, a.z - b.z); } -inline Vec3f operator*(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x * b.x, a.y * b.y, a.z * b.z); } -inline Vec3f operator/(const Vec3f &a, const Vec3f &b) { return Vec3f(a.x / b.x, a.y / b.y, a.z / b.z); } - -inline Vec3f operator+(const Vec3f &a, float b) { return Vec3f(a.x + b, a.y + b, a.z + b); } -inline Vec3f operator-(const Vec3f &a, float b) { return Vec3f(a.x - b, a.y - b, a.z - b); } -inline Vec3f operator*(const Vec3f &a, float b) { return Vec3f(a.x * b, a.y * b, a.z * b); } -inline Vec3f operator/(const Vec3f &a, float b) { return Vec3f(a.x / b, a.y / b, a.z / b); } - -inline Vec3f operator+(float a, const Vec3f &b) { return Vec3f(a + b.x, a + b.y, a + b.z); } -inline Vec3f operator-(float a, const Vec3f &b) { return Vec3f(a - b.x, a - b.y, a - b.z); } -inline Vec3f operator*(float a, const Vec3f &b) { return Vec3f(a * b.x, a * b.y, a * b.z); } -inline Vec3f operator/(float a, const Vec3f &b) { return Vec3f(a / b.x, a / b.y, a / b.z); } - -inline Vec4f::Vec4f(const Vec3f &xyz, float w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w) { } - -typedef TriMatrix Mat4f; - -class AxisAlignedBoundingBox -{ -public: - AxisAlignedBoundingBox() : aabb_min(), aabb_max() {} - AxisAlignedBoundingBox(const Vec3f &aabb_min, const Vec3f &aabb_max) : aabb_min(aabb_min), aabb_max(aabb_max) { } - AxisAlignedBoundingBox(const AxisAlignedBoundingBox &aabb, const Vec3f &barycentric_min, const Vec3f &barycentric_max) - : aabb_min(mix(aabb.aabb_min, aabb.aabb_max, barycentric_min)), aabb_max(mix(aabb.aabb_min, aabb.aabb_max, barycentric_max)) { } - - Vec3f center() const { return (aabb_max + aabb_min) * 0.5f; } - Vec3f extents() const { return (aabb_max - aabb_min) * 0.5f; } - - Vec3f aabb_min; - Vec3f aabb_max; - -private: - template - inline A mix(A a, B b, C mix) - { - return a * (C(1) - mix) + b * mix; - } -}; - -class OrientedBoundingBox -{ -public: - Vec3f center; - Vec3f extents; - Vec3f axis_x; - Vec3f axis_y; - Vec3f axis_z; -}; - -class FrustumPlanes -{ -public: - FrustumPlanes(); - explicit FrustumPlanes(const Mat4f &world_to_projection); - - Vec4f planes[6]; - -private: - static Vec4f left_frustum_plane(const Mat4f &matrix); - static Vec4f right_frustum_plane(const Mat4f &matrix); - static Vec4f top_frustum_plane(const Mat4f &matrix); - static Vec4f bottom_frustum_plane(const Mat4f &matrix); - static Vec4f near_frustum_plane(const Mat4f &matrix); - static Vec4f far_frustum_plane(const Mat4f &matrix); -}; - -class IntersectionTest -{ -public: - enum Result - { - outside, - inside, - intersecting, - }; - - enum OverlapResult - { - disjoint, - overlap - }; - - static Result plane_aabb(const Vec4f &plane, const AxisAlignedBoundingBox &aabb); - static Result plane_obb(const Vec4f &plane, const OrientedBoundingBox &obb); - static OverlapResult sphere(const Vec3f ¢er1, float radius1, const Vec3f ¢er2, float radius2); - static OverlapResult sphere_aabb(const Vec3f ¢er, float radius, const AxisAlignedBoundingBox &aabb); - static OverlapResult aabb(const AxisAlignedBoundingBox &a, const AxisAlignedBoundingBox &b); - static Result frustum_aabb(const FrustumPlanes &frustum, const AxisAlignedBoundingBox &box); - static Result frustum_obb(const FrustumPlanes &frustum, const OrientedBoundingBox &box); - static OverlapResult ray_aabb(const Vec3f &ray_start, const Vec3f &ray_end, const AxisAlignedBoundingBox &box); -}; diff --git a/src/polyrenderer/poly_all.cpp b/src/polyrenderer/poly_all.cpp index 2ad4b45a4..286dae4cb 100644 --- a/src/polyrenderer/poly_all.cpp +++ b/src/polyrenderer/poly_all.cpp @@ -3,7 +3,6 @@ #include "drawers/poly_draw_args.cpp" #include "drawers/poly_triangle.cpp" #include "drawers/screen_triangle.cpp" -#include "math/poly_intersection.cpp" #include "math/tri_matrix.cpp" #include "scene/poly_cull.cpp" #include "scene/poly_decal.cpp" diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 2e400975f..1fb6de710 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -135,7 +135,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines) ClearBuffers(); SetSceneViewport(); SetupPerspectiveMatrix(); - MainPortal.SetViewpoint(WorldToClip, Vec4f(0.0f, 0.0f, 0.0f, 1.0f), GetNextStencilValue()); + MainPortal.SetViewpoint(WorldToClip, PolyClipPlane(0.0f, 0.0f, 0.0f, 1.0f), GetNextStencilValue()); MainPortal.Render(0); Skydome.Render(WorldToClip); MainPortal.RenderTranslucent(0); diff --git a/src/polyrenderer/scene/poly_cull.cpp b/src/polyrenderer/scene/poly_cull.cpp index 01f157a93..623b6e9df 100644 --- a/src/polyrenderer/scene/poly_cull.cpp +++ b/src/polyrenderer/scene/poly_cull.cpp @@ -28,10 +28,9 @@ #include "poly_cull.h" #include "polyrenderer/poly_renderer.h" -void PolyCull::CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane) +void PolyCull::CullScene(const TriMatrix &worldToClip, const PolyClipPlane &portalClipPlane) { PvsSectors.clear(); - frustumPlanes = FrustumPlanes(worldToClip); PortalClipPlane = portalClipPlane; // Cull front to back @@ -210,20 +209,6 @@ int PolyCull::PointOnSide(const DVector2 &pos, const node_t *node) bool PolyCull::CheckBBox(float *bspcoord) { -#if 0 // This doesn't work because it creates gaps in the angle based clipper segment list :( - // Start using a quick frustum AABB test: - - AxisAlignedBoundingBox aabb(Vec3f(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], (float)PolyRenderer::Instance()->Viewpoint.Pos.Z - 1000.0f), Vec3f(bspcoord[BOXRIGHT], bspcoord[BOXTOP], (float)PolyRenderer::Instance()->Viewpoint.Pos.Z + 1000.0f)); - auto result = IntersectionTest::frustum_aabb(frustumPlanes, aabb); - if (result == IntersectionTest::outside) - return false; - - // Skip if its in front of the portal: - - if (IntersectionTest::plane_aabb(PortalClipPlane, aabb) == IntersectionTest::outside) - return false; -#endif - // Occlusion test using solid segments: static const uint8_t checkcoord[12][4] = { diff --git a/src/polyrenderer/scene/poly_cull.h b/src/polyrenderer/scene/poly_cull.h index d0430501d..64e4d5739 100644 --- a/src/polyrenderer/scene/poly_cull.h +++ b/src/polyrenderer/scene/poly_cull.h @@ -23,13 +23,12 @@ #pragma once #include "polyrenderer/drawers/poly_triangle.h" -#include "polyrenderer/math/poly_intersection.h" class PolyCull { public: void ClearSolidSegments(); - void CullScene(const TriMatrix &worldToClip, const Vec4f &portalClipPlane); + void CullScene(const TriMatrix &worldToClip, const PolyClipPlane &portalClipPlane); bool GetAnglesForLine(double x1, double y1, double x2, double y2, angle_t &angle1, angle_t &angle2) const; void MarkSegmentCulled(angle_t angle1, angle_t angle2); @@ -61,8 +60,7 @@ private: const int SolidCullScale = 3000; bool FirstSkyHeight = true; - FrustumPlanes frustumPlanes; - Vec4f PortalClipPlane; + PolyClipPlane PortalClipPlane; static angle_t PointToPseudoAngle(double x, double y); static angle_t AngleToPseudo(angle_t ang); diff --git a/src/polyrenderer/scene/poly_decal.cpp b/src/polyrenderer/scene/poly_decal.cpp index cf49bc0b1..829f444b6 100644 --- a/src/polyrenderer/scene/poly_decal.cpp +++ b/src/polyrenderer/scene/poly_decal.cpp @@ -31,7 +31,7 @@ #include "a_sharedglobal.h" #include "swrenderer/scene/r_scene.h" -void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const Vec4f &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) { if (line->linedef == nullptr && line->sidedef == nullptr) return; @@ -43,7 +43,7 @@ void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const Vec4f } } -void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue) { if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid()) return; @@ -142,7 +142,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.SetFaceCullCCW(true); args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); args.SetSubsectorDepthTest(true); args.SetWriteStencil(false); args.SetWriteSubsectorDepth(false); diff --git a/src/polyrenderer/scene/poly_decal.h b/src/polyrenderer/scene/poly_decal.h index 48907780a..a0d676951 100644 --- a/src/polyrenderer/scene/poly_decal.h +++ b/src/polyrenderer/scene/poly_decal.h @@ -24,13 +24,11 @@ #include "polyrenderer/drawers/poly_triangle.h" -class Vec4f; - class RenderPolyDecal { public: - static void RenderWallDecals(const TriMatrix &worldToClip, const Vec4f &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); + static void RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); private: - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue); }; diff --git a/src/polyrenderer/scene/poly_particle.cpp b/src/polyrenderer/scene/poly_particle.cpp index eb6fc3c95..d4a49334b 100644 --- a/src/polyrenderer/scene/poly_particle.cpp +++ b/src/polyrenderer/scene/poly_particle.cpp @@ -29,7 +29,7 @@ #include "polyrenderer/poly_renderer.h" #include "polyrenderer/scene/poly_light.h" -void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { DVector3 pos = particle->Pos; double psize = particle->size / 8.0; @@ -82,6 +82,6 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP args.SetStencilTestValue(stencilValue); args.SetWriteStencil(false); args.SetWriteSubsectorDepth(false); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan); } diff --git a/src/polyrenderer/scene/poly_particle.h b/src/polyrenderer/scene/poly_particle.h index b3b25b996..e91174591 100644 --- a/src/polyrenderer/scene/poly_particle.h +++ b/src/polyrenderer/scene/poly_particle.h @@ -25,10 +25,8 @@ #include "polyrenderer/drawers/poly_triangle.h" #include "p_effect.h" -class Vec4f; - class RenderPolyParticle { public: - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); }; diff --git a/src/polyrenderer/scene/poly_plane.cpp b/src/polyrenderer/scene/poly_plane.cpp index 5ae891bfd..d41328d57 100644 --- a/src/polyrenderer/scene/poly_plane.cpp +++ b/src/polyrenderer/scene/poly_plane.cpp @@ -33,7 +33,7 @@ EXTERN_CVAR(Int, r_3dfloors) -void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) +void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals) { RenderPolyPlane plane; @@ -91,7 +91,7 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const Vec4f &cl plane.Render(worldToClip, clipPlane, cull, sub, subsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals); } -void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) +void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor) { FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture; FTexture *tex = TexMan(picnum); @@ -138,11 +138,11 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue + 1); args.SetTexture(tex); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); args.DrawArray(vertices, sub->numlines, PolyDrawMode::TriangleFan); } -void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) +void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals) { const auto &viewpoint = PolyRenderer::Instance()->Viewpoint; bool foggy = false; @@ -307,7 +307,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.SetFaceCullCCW(ccw); args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue + 1); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); if (!isSky) { diff --git a/src/polyrenderer/scene/poly_plane.h b/src/polyrenderer/scene/poly_plane.h index bf844dcc2..ce2192594 100644 --- a/src/polyrenderer/scene/poly_plane.h +++ b/src/polyrenderer/scene/poly_plane.h @@ -26,12 +26,11 @@ class PolyDrawSectorPortal; class PolyCull; -class Vec4f; class RenderPolyPlane { public: - static void RenderPlanes(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); + static void RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector> §orPortals); private: struct UVTransform @@ -48,7 +47,7 @@ private: float xOffs, yOffs; }; - void Render3DFloor(const TriMatrix &worldToClip, const Vec4f &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); + void Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector> §orPortals); TriVertex PlaneVertex(vertex_t *v1, double height, const UVTransform &transform); }; diff --git a/src/polyrenderer/scene/poly_portal.cpp b/src/polyrenderer/scene/poly_portal.cpp index f26213455..0e0ffbf38 100644 --- a/src/polyrenderer/scene/poly_portal.cpp +++ b/src/polyrenderer/scene/poly_portal.cpp @@ -45,7 +45,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) const auto &viewpoint = PolyRenderer::Instance()->Viewpoint; - Vec4f portalPlane = Vec4f(0.0f); + PolyClipPlane portalPlane(0.0f, 0.0f, 0.0f, 1.0f); if (Portal->mType != PORTS_SKYVIEWPOINT) { float minHeight; @@ -71,17 +71,11 @@ void PolyDrawSectorPortal::Render(int portalDepth) if (!first && minHeight > viewpoint.Pos.Z) { - portalPlane.x = 0.0f; - portalPlane.y = 0.0f; - portalPlane.z = 1.0f; - portalPlane.w = -minHeight; + portalPlane = PolyClipPlane(0.0f, 0.0f, 1.0f, -minHeight); } else if (!first && maxHeight < viewpoint.Pos.Z) { - portalPlane.x = 0.0f; - portalPlane.y = 0.0f; - portalPlane.z = -1.0f; - portalPlane.w = maxHeight; + portalPlane = PolyClipPlane(0.0f, 0.0f, -1.0f, maxHeight); } } @@ -223,7 +217,7 @@ void PolyDrawLinePortal::Render(int portalDepth) DVector2 planeNormal = (clipLine->v2->fPos() - clipLine->v1->fPos()).Rotated90CW(); planeNormal.MakeUnit(); double planeD = -(planeNormal | (planePos + planeNormal * 0.001)); - Vec4f portalPlane((float)planeNormal.X, (float)planeNormal.Y, 0.0f, (float)planeD); + PolyClipPlane portalPlane((float)planeNormal.X, (float)planeNormal.Y, (float)0.0f, (float)planeD); RenderPortal.SetViewpoint(worldToClip, portalPlane, StencilValue); RenderPortal.SetPortalSegments(Segments); diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 2ea63f439..3aeda994c 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -43,7 +43,7 @@ RenderPolyScene::~RenderPolyScene() { } -void RenderPolyScene::SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue) +void RenderPolyScene::SetViewpoint(const TriMatrix &worldToClip, const PolyClipPlane &portalPlane, uint32_t stencilValue) { WorldToClip = worldToClip; StencilValue = stencilValue; @@ -252,7 +252,7 @@ void RenderPolyScene::RenderPortals(int portalDepth) args.SetTransform(&WorldToClip); args.SetLight(&NormalLight, 255, PolyRenderer::Instance()->Light.WallGlobVis(foggy), true); args.SetColor(0, 0); - args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); + args.SetClipPlane(PortalPlane); args.SetStyle(TriBlendMode::Copy); for (auto &portal : SectorPortals) @@ -294,7 +294,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) args.SetTransform(&WorldToClip); args.SetStencilTestValue(portal->StencilValue + 1); args.SetWriteStencil(true, StencilValue + 1); - args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); + args.SetClipPlane(PortalPlane); for (const auto &verts : portal->Shape) { args.SetFaceCullCCW(verts.Ccw); @@ -313,7 +313,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth) args.SetTransform(&WorldToClip); args.SetStencilTestValue(portal->StencilValue + 1); args.SetWriteStencil(true, StencilValue + 1); - args.SetClipPlane(PortalPlane.x, PortalPlane.y, PortalPlane.z, PortalPlane.w); + args.SetClipPlane(PortalPlane); for (const auto &verts : portal->Shape) { args.SetFaceCullCCW(verts.Ccw); diff --git a/src/polyrenderer/scene/poly_scene.h b/src/polyrenderer/scene/poly_scene.h index 77c7925c0..707ee87a3 100644 --- a/src/polyrenderer/scene/poly_scene.h +++ b/src/polyrenderer/scene/poly_scene.h @@ -29,7 +29,6 @@ #include "doomdata.h" #include "r_utility.h" #include "polyrenderer/drawers/poly_triangle.h" -#include "polyrenderer/math/poly_intersection.h" #include "poly_wall.h" #include "poly_sprite.h" #include "poly_wallsprite.h" @@ -74,7 +73,7 @@ class RenderPolyScene public: RenderPolyScene(); ~RenderPolyScene(); - void SetViewpoint(const TriMatrix &worldToClip, const Vec4f &portalPlane, uint32_t stencilValue); + void SetViewpoint(const TriMatrix &worldToClip, const PolyClipPlane &portalPlane, uint32_t stencilValue); void SetPortalSegments(const std::vector &segments); void Render(int portalDepth); void RenderTranslucent(int portalDepth); @@ -91,7 +90,7 @@ private: void RenderSprite(AActor *thing, double sortDistance, DVector2 left, DVector2 right, double t1, double t2, void *node); TriMatrix WorldToClip; - Vec4f PortalPlane; + PolyClipPlane PortalPlane; uint32_t StencilValue = 0; PolyCull Cull; uint32_t NextSubsectorDepth = 0; diff --git a/src/polyrenderer/scene/poly_sky.cpp b/src/polyrenderer/scene/poly_sky.cpp index a38845ebe..374163f96 100644 --- a/src/polyrenderer/scene/poly_sky.cpp +++ b/src/polyrenderer/scene/poly_sky.cpp @@ -61,7 +61,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) args.SetTransform(&objectToClip); args.SetStencilTestValue(255); args.SetWriteStencil(true, 1); - args.SetClipPlane(0.0f, 0.0f, 0.0f, 0.0f); + args.SetClipPlane(PolyClipPlane(0.0f, 0.0f, 0.0f, 1.0f)); RenderCapColorRow(args, frontskytex, 0, false); RenderCapColorRow(args, frontskytex, rc, true); diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index ff3303ea0..2a98af721 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -27,7 +27,6 @@ #include "r_data/r_translate.h" #include "poly_sprite.h" #include "polyrenderer/poly_renderer.h" -#include "polyrenderer/math/poly_intersection.h" #include "polyrenderer/scene/poly_light.h" EXTERN_CVAR(Float, transsouls) @@ -65,7 +64,7 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right) return true; } -void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2) +void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2) { DVector2 line[2]; if (!GetLine(thing, line[0], line[1])) @@ -146,7 +145,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla args.SetStencilTestValue(stencilValue); args.SetWriteStencil(true, stencilValue); args.SetTexture(tex, thing->Translation); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); if (thing->RenderStyle == LegacyRenderStyles[STYLE_Normal] || (r_drawfuzz == 0 && thing->RenderStyle == LegacyRenderStyles[STYLE_OptFuzzy])) diff --git a/src/polyrenderer/scene/poly_sprite.h b/src/polyrenderer/scene/poly_sprite.h index a61c7f4b5..e190d9ee6 100644 --- a/src/polyrenderer/scene/poly_sprite.h +++ b/src/polyrenderer/scene/poly_sprite.h @@ -24,12 +24,10 @@ #include "polyrenderer/drawers/poly_triangle.h" -class Vec4f; - class RenderPolySprite { public: - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2); static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right); static bool IsThingCulled(AActor *thing); diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index 8164d71ef..263487f70 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -37,7 +37,7 @@ EXTERN_CVAR(Bool, r_drawmirrors) -bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) +bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals) { PolyDrawLinePortal *polyportal = nullptr; if (line->backsector == nullptr && line->linedef && line->sidedef == line->linedef->sidedef[0] && (line->linedef->special == Line_Mirror && r_drawmirrors)) @@ -165,7 +165,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const Vec4f &clipP return polyportal != nullptr; } -void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) +void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput) { double frontceilz1 = fakeFloor->top.plane->ZatPoint(line->v1); double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); @@ -198,7 +198,7 @@ void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ce this->floor2 = floor2; } -void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull) +void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull) { bool foggy = false; FTexture *tex = GetTexture(); @@ -256,7 +256,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane args.SetWriteStencil(true, StencilValue + 1); if (tex) args.SetTexture(tex); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); if (Polyportal) { diff --git a/src/polyrenderer/scene/poly_wall.h b/src/polyrenderer/scene/poly_wall.h index a435201b2..dda2cdc2a 100644 --- a/src/polyrenderer/scene/poly_wall.h +++ b/src/polyrenderer/scene/poly_wall.h @@ -27,16 +27,15 @@ class PolyTranslucentObject; class PolyDrawLinePortal; class PolyCull; -class Vec4f; class RenderPolyWall { public: - static bool RenderLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); - static void Render3DFloorLine(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); + static bool RenderLine(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, std::vector &translucentWallsOutput, std::vector> &linePortals); + static void Render3DFloorLine(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth, uint32_t stencilValue, F3DFloor *fakeFloor, std::vector &translucentWallsOutput); void SetCoords(const DVector2 &v1, const DVector2 &v2, double ceil1, double floor1, double ceil2, double floor2); - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull); DVector2 v1; DVector2 v2; diff --git a/src/polyrenderer/scene/poly_wallsprite.cpp b/src/polyrenderer/scene/poly_wallsprite.cpp index 9e4e2498c..8108849b9 100644 --- a/src/polyrenderer/scene/poly_wallsprite.cpp +++ b/src/polyrenderer/scene/poly_wallsprite.cpp @@ -29,7 +29,7 @@ #include "polyrenderer/poly_renderer.h" #include "polyrenderer/scene/poly_light.h" -void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) +void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue) { if (RenderPolySprite::IsThingCulled(thing)) return; @@ -105,7 +105,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli args.SetFaceCullCCW(true); args.SetStencilTestValue(stencilValue); args.SetTexture(tex); - args.SetClipPlane(clipPlane.x, clipPlane.y, clipPlane.z, clipPlane.w); + args.SetClipPlane(clipPlane); args.SetSubsectorDepthTest(true); args.SetWriteSubsectorDepth(false); args.SetWriteStencil(false); diff --git a/src/polyrenderer/scene/poly_wallsprite.h b/src/polyrenderer/scene/poly_wallsprite.h index 75a550748..c0c0005b8 100644 --- a/src/polyrenderer/scene/poly_wallsprite.h +++ b/src/polyrenderer/scene/poly_wallsprite.h @@ -24,10 +24,8 @@ #include "polyrenderer/drawers/poly_triangle.h" -class Vec4f; - class RenderPolyWallSprite { public: - void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); + void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue); };