aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/tri_deriv.h
blob: 16a21f8e4f28038339e35ea1793f19de16220757 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef O3D_TRI_VERTEX_H
#define O3D_TRI_VERTEX_H

#include <vector>
#include "o3d/vertex.h"
#include "o3d/deriv_vertex.h"

namespace engine::o3d {

struct TriangleDerived {
    DerivedVertex derived_vertex1;
    DerivedVertex derived_vertex2;
    DerivedVertex derived_vertex3;

    std::vector<TriangleDerived> perspective_crop_xy_out(float x1, float x2, float y1, float y2) const;
    std::vector<TriangleDerived> crop_z_out(float z1, float z2) const;

    constexpr TriangleDerived div_by_w() const & {
        return {derived_vertex1.div_by_w(), derived_vertex2.div_by_w(), derived_vertex3.div_by_w()};
    }
};

}

#endif // O3D_TRI_VERTEX_H