summaryrefslogtreecommitdiffstats
path: root/src/RendererSectionData.cpp
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-06-28 17:55:59 +0200
committerLaG1924 <lag1924@gmail.com>2021-06-28 17:55:59 +0200
commit7ff7b88cf66131a559ea0ee931bddce4785507a7 (patch)
tree11e2ff67d8e4ca2a7ba25c0ce70f2056e47eb723 /src/RendererSectionData.cpp
parentEmbed UV to vertex data (diff)
downloadAltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.tar
AltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.tar.gz
AltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.tar.bz2
AltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.tar.lz
AltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.tar.xz
AltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.tar.zst
AltCraft-7ff7b88cf66131a559ea0ee931bddce4785507a7.zip
Diffstat (limited to '')
-rw-r--r--src/RendererSectionData.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp
index 78e2239..e74590a 100644
--- a/src/RendererSectionData.cpp
+++ b/src/RendererSectionData.cpp
@@ -47,21 +47,24 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co
lightness = glm::vec2(light.face[faceDirection], skyLight.face[faceDirection]);
}
+ data.vertices.emplace_back();
+ VertexData& vertexData = data.vertices.back();
+
glm::mat4 transformed = transform * model.transform * face.transform;
- data.positions.push_back(transformed * glm::vec4(0, 0, 0, 1));
- data.positions.push_back(transformed * glm::vec4(0, 0, 1, 1));
- data.positions.push_back(transformed * glm::vec4(1, 0, 1, 1));
- data.positions.push_back(transformed * glm::vec4(1, 0, 0, 1));
-
- data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames));
- data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames));
- data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames));
- data.uvs.push_back(TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames));
-
- data.uvLayers.push_back(face.layer);
- data.animations.push_back(glm::vec2(face.texture.w / face.frames, face.frames));
- data.colors.push_back(face.color);
- data.lights.push_back(lightness);
+ vertexData.positions[0] = transformed * glm::vec4(0, 0, 0, 1);
+ vertexData.positions[1] = transformed * glm::vec4(0, 0, 1, 1);
+ vertexData.positions[2] = transformed * glm::vec4(1, 0, 1, 1);
+ vertexData.positions[3] = transformed * glm::vec4(1, 0, 0, 1);
+
+ vertexData.uvs[0] = TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames);
+ vertexData.uvs[1] = TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames);
+ vertexData.uvs[2] = TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames);
+ vertexData.uvs[3] = TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames);
+
+ vertexData.uvLayers = face.layer;
+ vertexData.animations = glm::vec2(face.texture.w / face.frames, face.frames);
+ vertexData.colors = face.color;
+ vertexData.lights = lightness;
}
}
@@ -154,12 +157,7 @@ RendererSectionData ParseSection(const SectionsData &sections) {
}
}
}
- data.positions.shrink_to_fit();
- data.uvs.shrink_to_fit();
- data.uvLayers.shrink_to_fit();
- data.animations.shrink_to_fit();
- data.colors.shrink_to_fit();
- data.lights.shrink_to_fit();
+ data.vertices.shrink_to_fit();
return data;
}