mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 20:15:07 +00:00

The `ClipPlane` enum is being looped over at run-time performing run-time dispatch to determine the comparison operation in `point_within_clip_plane`. Change this `for` loop to be linear code which dispatches using a template parameter. This allows for the `point_within_clip_plane` function to do compile-time dispatch. Note: This linear code can become a compile-time loop when static reflection lands in C++2[y|z] allowing looping over the reflected `enum class`.
36 lines
603 B
C++
36 lines
603 B
C++
/*
|
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <LibGfx/Vector4.h>
|
|
#include <LibSoftGPU/Vertex.h>
|
|
|
|
namespace SoftGPU {
|
|
|
|
class Clipper final {
|
|
public:
|
|
enum class ClipPlane : u8 {
|
|
LEFT = 0,
|
|
RIGHT,
|
|
TOP,
|
|
BOTTOM,
|
|
NEAR,
|
|
FAR
|
|
};
|
|
|
|
Clipper() = default;
|
|
|
|
void clip_triangle_against_frustum(Vector<Vertex>& input_vecs);
|
|
|
|
private:
|
|
Vector<Vertex> list_a;
|
|
Vector<Vertex> list_b;
|
|
};
|
|
|
|
}
|