Shrink GlyphInfo struct

This commit is contained in:
Georg Hagen
2025-01-10 18:09:38 +01:00
parent ce57ed2091
commit f58064d724
3 changed files with 27 additions and 20 deletions

View File

@@ -82,7 +82,11 @@ namespace OpenVulkano::Scene
for (const auto& [key, val] : m_atlasData->glyphs)
{
fs.write(reinterpret_cast<const char*>(&key), sizeof(uint32_t));
fs.write(reinterpret_cast<const char*>(&val), sizeof(GlyphInfo));
fs.write(reinterpret_cast<const char*>(&val.pos), sizeof(GlyphInfo::pos));
fs.write(reinterpret_cast<const char*>(&val.pos), sizeof(GlyphInfo::pos)); // TODO remove this after cleaning up the atlas writing code
fs.write(reinterpret_cast<const char*>(&val.uv), sizeof(GlyphInfo::uv));
fs.write(reinterpret_cast<const char*>(&val.advance), sizeof(GlyphInfo::advance));
fs.write(reinterpret_cast<const char*>(&val.advance), sizeof(GlyphInfo::advance)); // TODO remove this afer cleaning up the atlas writing code
metadataBytes += sizeof(uint32_t);
metadataBytes += sizeof(GlyphInfo);
}
@@ -125,32 +129,28 @@ namespace OpenVulkano::Scene
void FontAtlasGeneratorBase::SetGlyphData(GlyphInfo& info, Math::Vector2d bearing, Math::Vector2d size,
const Math::AABB& aabb, double advance)
{
const double bearingX = bearing.x;
const double bearingY = bearing.y;
const double w = size.x;
const double h = size.y;
const double l = aabb.min.x;
const double r = aabb.max.x;
const double t = aabb.max.y;
const double b = aabb.min.y;
info.xyz[0].x = bearingX;
info.xyz[0].y = h - bearingY;
info.pos[0].x = bearing.x;
info.pos[0].y = size.y - bearing.y;
info.uv[0].x = l / m_atlasData->texture.resolution.x;
info.uv[0].y = b / m_atlasData->texture.resolution.y;
info.xyz[1].x = bearingX + w;
info.xyz[1].y = h - bearingY;
info.pos[1].x = bearing.x + size.x;
info.pos[1].y = size.y - bearing.y;
info.uv[1].x = r / m_atlasData->texture.resolution.x;
info.uv[1].y = b / m_atlasData->texture.resolution.y;
info.xyz[2].x = bearingX + w;
info.xyz[2].y = bearingY; //h - bearingY + h;
info.pos[2].x = bearing.x + size.x;
info.pos[2].y = bearing.y;
info.uv[2].x = r / m_atlasData->texture.resolution.x;
info.uv[2].y = t / m_atlasData->texture.resolution.y;
info.xyz[3].x = bearingX;
info.xyz[3].y = bearingY;
info.pos[3].x = bearing.x;
info.pos[3].y = bearing.y;
info.uv[3].x = l / m_atlasData->texture.resolution.x;
info.uv[3].y = t / m_atlasData->texture.resolution.y;