mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
bf59e520a7
109 changed files with 1908 additions and 474 deletions
|
|
@ -198,6 +198,31 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) {
|
|||
} else {
|
||||
normal = glm::cross(glm::normalize(right), glm::normalize(up));
|
||||
}
|
||||
|
||||
auto cullFace = root.attr("cull-face", "back").getText();
|
||||
if (cullFace == "front") {
|
||||
normal *= -1.0f;
|
||||
} else if (cullFace == "off") {
|
||||
builder.addRect(
|
||||
texture,
|
||||
shading,
|
||||
from + right * 0.5f + up * 0.5f,
|
||||
right * 0.5f,
|
||||
up * 0.5f,
|
||||
normal,
|
||||
region
|
||||
);
|
||||
builder.addRect(
|
||||
texture,
|
||||
shading,
|
||||
from + right * 0.5f + up * 0.5f,
|
||||
right * -0.5f,
|
||||
up * -0.5f,
|
||||
-normal,
|
||||
region
|
||||
);
|
||||
return;
|
||||
}
|
||||
builder.addRect(
|
||||
texture,
|
||||
shading,
|
||||
|
|
@ -246,6 +271,17 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) {
|
|||
}
|
||||
|
||||
std::string texture = root.attr("texture", "$0").getText();
|
||||
|
||||
auto cullFace = root.attr("cull-face", "back").getText();
|
||||
if (cullFace == "front") {
|
||||
std::swap(pointB, pointC);
|
||||
std::swap(uvs[1], uvs[2]);
|
||||
normal *= -1.0f;
|
||||
} else if (cullFace == "off") {
|
||||
builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]);
|
||||
builder.addTriangle(texture, shading, pointA, pointC, pointB, -normal, uvs[0], uvs[2], uvs[1]);
|
||||
return;
|
||||
}
|
||||
builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,9 @@ static model::Mesh load_mesh(
|
|||
if (flags == FLAG_ZLIB) {
|
||||
throw std::runtime_error("compression is not supported yet");
|
||||
}
|
||||
if (attributeCount <= 0) {
|
||||
throw std::runtime_error("mesh must have at least one attribute");
|
||||
}
|
||||
std::vector<VertexAttribute> attributes;
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
attributes.push_back(load_attribute(reader));
|
||||
|
|
|
|||
|
|
@ -122,10 +122,16 @@ namespace {
|
|||
std::vector<Glyph>& glyphs
|
||||
) {
|
||||
int size = canvas.getWidth() / 16;
|
||||
|
||||
const size_t end = (pageid + 1) * 256;
|
||||
if (glyphs.size() < end) {
|
||||
glyphs.resize(end);
|
||||
}
|
||||
|
||||
for (int c = 0; c < 256; c++) {
|
||||
int codepoint = pageid << 8 | c;
|
||||
if (!renderGlyph(codepoint, bitmapDst)) {
|
||||
glyphs.push_back(Glyph {0, size / 2});
|
||||
glyphs[codepoint] = Glyph {0, size / 2};
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -133,13 +139,10 @@ namespace {
|
|||
|
||||
Glyph glyph {
|
||||
face->glyph->bitmap_top - size,
|
||||
static_cast<int>(face->glyph->advance.x >> 6)
|
||||
static_cast<int>(face->glyph->advance.x >> 6),
|
||||
face->glyph->bitmap_left
|
||||
};
|
||||
if (codepoint < glyphs.size()) {
|
||||
glyphs[codepoint] = std::move(glyph);
|
||||
} else {
|
||||
glyphs.push_back(std::move(glyph));
|
||||
}
|
||||
glyphs[codepoint] = glyph;
|
||||
}
|
||||
canvas.flipY();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue