aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/vertex_data.h
blob: 71f42cd0de3f8962d97c0d73ac6da3cb79c36ab2 (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
26
#ifndef O3D_VERTEX_DATA_H
#define O3D_VERTEX_DATA_H

namespace engine::o3d {

struct VertexData {
    static constexpr VertexData lerp(const VertexData& vd1, const VertexData& vd2, float b0) {
        return {
            b0 * vd1.tx + (1.f - b0) * vd2.tx,
            b0 * vd1.ty + (1.f - b0) * vd2.ty
        };
    }

    static constexpr VertexData bilerp(const VertexData& vd1, const VertexData& vd2, const VertexData& vd3, float b0, float b1) {
        return {
            b0 * vd1.tx + b1 * vd2.tx + (1.f - b0 - b1) * vd3.tx,
            b0 * vd1.ty + b1 * vd2.ty + (1.f - b0 - b1) * vd3.ty
        };
    }

    float tx, ty;
};

}

#endif // O3D_VERTEX_DATA_H