fix VCM cull-face behaviour for 'rect'

This commit is contained in:
MihailRis 2026-11-21 21:50:39 +03:00
parent 1d1174e344
commit 14c53c6149

View file

@ -193,45 +193,36 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) {
std::string texture = root.attr("texture", "$0").getText();
glm::vec3 normal;
glm::vec3 backNormal;
if (root.has("normal")) {
normal = root.attr("normal").asVec3();
backNormal = normal;
} else {
normal = glm::cross(glm::normalize(right), glm::normalize(up));
backNormal = -normal;
}
glm::vec3 center = from + right * 0.5f + up * 0.5f;
UVRegion backRegion = region;
std::swap(backRegion.u1, backRegion.u2);
auto cullFace = root.attr("cull-face", "back").getText();
if (cullFace == "front") {
normal *= -1.0f;
} else if (cullFace == "off") {
if (cullFace != "front") {
builder.addRect(
texture,
shading,
from + right * 0.5f + up * 0.5f,
right * 0.5f,
up * 0.5f,
normal,
region
texture, shading, center, right * 0.5f, up * 0.5f, normal, region
);
}
if (cullFace == "front" || cullFace == "off") {
builder.addRect(
texture,
shading,
center,
right * -0.5f,
up * 0.5f,
backNormal,
backRegion
);
builder.addRect(
texture,
shading,
from + right * 0.5f + up * 0.5f,
right * -0.5f,
up * -0.5f,
-normal,
region
);
return;
}
builder.addRect(
texture,
shading,
from + right * 0.5f + up * 0.5f,
right * 0.5f,
up * 0.5f,
normal,
region
);
}
static void perform_triangle(const xmlelement& root, ModelBuilder& builder) {