1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

LibSoftGPU: Switch to using east const in Clipper.[h,cpp]

This commit is contained in:
Lenny Maiorani 2022-01-23 12:39:16 -07:00 committed by Linus Groh
parent 66216d3af6
commit 0da3a2ddde
2 changed files with 6 additions and 6 deletions

View file

@ -11,7 +11,7 @@
namespace SoftGPU { namespace SoftGPU {
bool Clipper::point_within_clip_plane(const FloatVector4& vertex, ClipPlane plane) bool Clipper::point_within_clip_plane(FloatVector4 const& vertex, ClipPlane plane)
{ {
switch (plane) { switch (plane) {
case ClipPlane::LEFT: case ClipPlane::LEFT:
@ -31,7 +31,7 @@ bool Clipper::point_within_clip_plane(const FloatVector4& vertex, ClipPlane plan
return false; return false;
} }
Vertex Clipper::clip_intersection_point(const Vertex& p1, const Vertex& p2, ClipPlane plane_index) Vertex Clipper::clip_intersection_point(Vertex const& p1, Vertex const& p2, ClipPlane plane_index)
{ {
// See https://www.microsoft.com/en-us/research/wp-content/uploads/1978/01/p245-blinn.pdf // See https://www.microsoft.com/en-us/research/wp-content/uploads/1978/01/p245-blinn.pdf
// "Clipping Using Homogeneous Coordinates" Blinn/Newell, 1978 // "Clipping Using Homogeneous Coordinates" Blinn/Newell, 1978
@ -65,8 +65,8 @@ void Clipper::clip_triangle_against_frustum(Vector<Vertex>& input_verts)
write_to->clear_with_capacity(); write_to->clear_with_capacity();
// Save me, C++23 // Save me, C++23
for (size_t i = 0; i < read_from->size(); i++) { for (size_t i = 0; i < read_from->size(); i++) {
const auto& curr_vec = read_from->at((i + 1) % read_from->size()); auto const& curr_vec = read_from->at((i + 1) % read_from->size());
const auto& prev_vec = read_from->at(i); auto const& prev_vec = read_from->at(i);
if (point_within_clip_plane(curr_vec.clip_coordinates, static_cast<ClipPlane>(plane))) { if (point_within_clip_plane(curr_vec.clip_coordinates, static_cast<ClipPlane>(plane))) {
if (!point_within_clip_plane(prev_vec.clip_coordinates, static_cast<ClipPlane>(plane))) { if (!point_within_clip_plane(prev_vec.clip_coordinates, static_cast<ClipPlane>(plane))) {

View file

@ -49,8 +49,8 @@ public:
void clip_triangle_against_frustum(Vector<Vertex>& input_vecs); void clip_triangle_against_frustum(Vector<Vertex>& input_vecs);
private: private:
bool point_within_clip_plane(const FloatVector4& vertex, ClipPlane plane); bool point_within_clip_plane(FloatVector4 const& vertex, ClipPlane plane);
Vertex clip_intersection_point(const Vertex& vec, const Vertex& prev_vec, ClipPlane plane_index); Vertex clip_intersection_point(Vertex const& vec, Vertex const& prev_vec, ClipPlane plane_index);
Vector<Vertex> list_a; Vector<Vertex> list_a;
Vector<Vertex> list_b; Vector<Vertex> list_b;
}; };