diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2022-01-08 13:55:23 -0700 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-27 20:42:28 +0000 |
commit | 25272cabef3b18359a0fe3532ce2117161382849 (patch) | |
tree | dcc2e10e834f92f1dd7244ccfc6eecc9a2aa8bd6 /Userland/Libraries/LibSoftGPU/Clipper.h | |
parent | d1a87f1219a2768e5bbd120d1bae43add8bce2dc (diff) | |
download | serenity-25272cabef3b18359a0fe3532ce2117161382849.zip |
LibSoftGPU: Reduce Clipper class interface to minimum
Much of the `Clipper` class can be made free functions and their scope
limited.
The purpose of this is to prepare the interface for a change to more
compile-time dispatch.
Diffstat (limited to 'Userland/Libraries/LibSoftGPU/Clipper.h')
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Clipper.h | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/Userland/Libraries/LibSoftGPU/Clipper.h b/Userland/Libraries/LibSoftGPU/Clipper.h index d2bf2c85ba..87b14c4c4a 100644 --- a/Userland/Libraries/LibSoftGPU/Clipper.h +++ b/Userland/Libraries/LibSoftGPU/Clipper.h @@ -13,7 +13,10 @@ namespace SoftGPU { class Clipper final { - enum ClipPlane : u8 { + static constexpr u8 NUMBER_OF_CLIPPING_PLANES = 6; + +public: + enum class ClipPlane : u8 { LEFT = 0, RIGHT, TOP, @@ -22,35 +25,11 @@ class Clipper final { FAR }; - static constexpr u8 NUMBER_OF_CLIPPING_PLANES = 6; - static constexpr u8 MAX_CLIPPED_VERTS = 6; - - static constexpr FloatVector4 clip_planes[] = { - { -1, 0, 0, 1 }, // Left Plane - { 1, 0, 0, 1 }, // Right Plane - { 0, 1, 0, 1 }, // Top Plane - { 0, -1, 0, 1 }, // Bottom plane - { 0, 0, 1, 1 }, // Near Plane - { 0, 0, -1, 1 } // Far Plane - }; - - static constexpr FloatVector4 clip_plane_normals[] = { - { 1, 0, 0, 0 }, // Left Plane - { -1, 0, 0, 0 }, // Right Plane - { 0, -1, 0, 0 }, // Top Plane - { 0, 1, 0, 0 }, // Bottom plane - { 0, 0, 1, 0 }, // Near Plane - { 0, 0, -1, 0 } // Far Plane - }; - -public: - Clipper() { } + Clipper() = default; void clip_triangle_against_frustum(Vector<Vertex>& input_vecs); private: - bool point_within_clip_plane(FloatVector4 const& vertex, ClipPlane plane) const; - Vertex clip_intersection_point(Vertex const& vec, Vertex const& prev_vec, ClipPlane plane_index) const; Vector<Vertex> list_a; Vector<Vertex> list_b; }; |