mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 18:39:46 +00:00
fix VCM cull-face behaviour for 'rect'
This commit is contained in:
parent
1d1174e344
commit
14c53c6149
1 changed files with 20 additions and 29 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue