mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:57:46 +00:00
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.
This commit is contained in:
parent
d1a87f1219
commit
25272cabef
2 changed files with 51 additions and 58 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue