Support POLY_FT4

This commit is contained in:
2023-05-19 22:26:53 +02:00
parent 1e0ba605b7
commit cc2c01138c
3 changed files with 109 additions and 26 deletions

View File

@@ -84,7 +84,7 @@ namespace JabyEngine {
uint16_t value = 0;
constexpr PageClut() = default;
constexpr PageClut(uint16_t x, uint16_t y) : value((y <<6 ) | ((x >> 4) & 0x3f)) {
constexpr PageClut(uint16_t x, uint16_t y) : value((y << 6) | ((x >> 4) & 0x3f)) {
}
};
@@ -142,7 +142,7 @@ namespace JabyEngine {
TPage tpage; // e
Vertex vertex2; // f
PagePosition page2; // g
uint16_t padded; // g
uint16_t padded2; // g
constexpr POLY_FT3() = default;
constexpr POLY_FT3(const Vertex (&verticies)[3], const PagePosition (&page_pos)[3], TPage tpage, PageClut clut, Color24 color) :
@@ -220,6 +220,13 @@ namespace JabyEngine {
color2(verticies_ex[2].color), vertex2(verticies_ex[2].position), page2(verticies_ex[2].page) {}
};
/*
1 - 2
| |
3 - 4
*/
struct POLY_F4 : public internal::IsPrimitive, public internal::CodeInterface<POLY_F4> {
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics);
@@ -245,19 +252,62 @@ namespace JabyEngine {
color) {}
};
struct POLY_FT4 : public internal::IsPrimitive, public internal::CodeInterface<POLY_FT4> {
typedef POLY_FT3::VertexEx VertexEx;
static constexpr auto IdentityCode = Code(POLY_FT3::IdentityCode).set(Code::QuadVertics);
Color24 color; // a
Code code = IdentityCode; // a
Vertex vertex0; // b
PagePosition page0; // c
PageClut page_clut; // c
Vertex vertex1; // d
PagePosition page1; // e
TPage tpage; // e
Vertex vertex2; // f
PagePosition page2; // g
uint16_t padded2; // g
Vertex vertex3; // h
PagePosition page3; // i
uint16_t padded3; // i
constexpr POLY_FT4() = default;
constexpr POLY_FT4(const Vertex (&verticies)[4], const PagePosition (&page_pos)[4], TPage tpage, PageClut clut, Color24 color) :
color(color), code(IdentityCode),
vertex0(verticies[0]), page0(page_pos[0]), page_clut(clut),
vertex1(verticies[1]), page1(page_pos[1]), tpage(tpage),
vertex2(verticies[2]), page2(page_pos[2]),
vertex3(verticies[3]), page3(page_pos[3]) {}
constexpr POLY_FT4(const VertexEx (&vertices_ex)[4], TPage tpage, PageClut clut, Color24 color) :
color(color), code(IdentityCode),
vertex0(vertices_ex[0].position), page0(vertices_ex[0].page), page_clut(clut),
vertex1(vertices_ex[1].position), page1(vertices_ex[1].page), tpage(tpage),
vertex2(vertices_ex[2].position), page2(vertices_ex[2].page),
vertex3(vertices_ex[3].position), page3(vertices_ex[3].page) {}
constexpr POLY_FT4(const AreaI16& area, const PagePosition& texture_pos, TPage tpage, PageClut clut, Color24 color) : POLY_FT4({
{area.position, texture_pos},
{area.position.move(area.size.width, 0), texture_pos.move(area.size.width, 0)},
{area.position.move(0, area.size.height), texture_pos.move(0, area.size.height)},
{area.position.move(area.size.width, area.size.height), texture_pos.move(area.size.width, area.size.height)}},
tpage, clut, color
) {}
};
typedef POLY_F3 FlatTriangle;
typedef POLY_FT3 FlatTexturedTriangle;
typedef POLY_G3 GouraudTriangle;
typedef POLY_GT3 GouraudTexturedTriangle;
typedef POLY_F4 FlatRectangle;
typedef POLY_F4 FlatRectangle;
typedef POLY_FT4 FlatTexturedRectangle;
static_assert(sizeof(POLY_F3) == 16);
static_assert(sizeof(POLY_FT3) == 28);
static_assert(sizeof(POLY_G3) == 24);
static_assert(sizeof(POLY_GT3) == 36);
static_assert(sizeof(POLY_F4) == 20);
static_assert(sizeof(POLY_F4) == 20);
static_assert(sizeof(POLY_FT4) == 36);
}
}