[Block] Useless code removed.

This commit is contained in:
Quentin Bazin 2018-06-18 21:42:35 +02:00
parent 9fd25da16a
commit ac88ba4b97
3 changed files with 5 additions and 28 deletions

View File

@ -20,12 +20,10 @@
class Block {
public:
Block(const glm::vec3 &pos, u32 id);
Block(u32 id);
glm::vec4 getTexCoords(int face);
const glm::vec3 &pos() const { return m_pos; }
u32 id() const { return m_id; }
void setId(u32 id) { m_id = id; }
@ -33,8 +31,6 @@ class Block {
void setSelected(bool isSelected, s8 face) { m_isSelected = isSelected; m_selectedFace = face; }
private:
glm::vec3 m_pos;
u32 m_id;
bool m_isSelected = false;

View File

@ -13,7 +13,7 @@
*/
#include "Block.hpp"
Block::Block(const glm::vec3 &pos, u32 id) : m_pos(pos) {
Block::Block(u32 id) {
m_id = id;
}

View File

@ -81,23 +81,9 @@ void Chunk::update() {
for(u8 y = 0 ; y < height ; y++) {
for(u8 x = 0 ; x < width ; x++) {
Block *block = getBlock(x, y, z);
if(!block || !block->id()) continue;
if(!block || !block->id()) {
continue;
}
//
float cubeTexCoords[2 * 4 * 6];
// blockTexCoords.x, blockTexCoords.w,
// blockTexCoords.z, blockTexCoords.w,
// blockTexCoords.z, blockTexCoords.y,
// blockTexCoords.x, blockTexCoords.y
// // 0.0f, 1.0f,
// // 1.0f, 1.0f,
// // 1.0f, 0.0f,
// // 0.0f, 0.0f
// };
for(int i = 0 ; i < 6 ; i++) {
const glm::vec4 &blockTexCoords = block->getTexCoords(i);
float faceTexCoords[2 * 4] = {
@ -213,12 +199,7 @@ void Chunk::setBlock(int x, int y, int z, u32 type) {
if(z < 0) { if(m_surroundingChunks[2]) m_surroundingChunks[2]->setBlock(x, y, z + Chunk::depth, type); return; }
if(z >= Chunk::depth) { if(m_surroundingChunks[3]) m_surroundingChunks[3]->setBlock(x, y, z - Chunk::depth, type); return; }
glm::vec3 pos;
pos.x = x + m_x * width;
pos.y = y + m_y * height;
pos.z = z + m_z * depth;
m_data[x][y][z].reset(new Block(pos, type));
m_data[x][y][z].reset(new Block(type));
m_isChanged = true;
@ -228,7 +209,6 @@ void Chunk::setBlock(int x, int y, int z, u32 type) {
if(z == depth - 1 && back()) { back()->m_isChanged = true; }
}
// FIXME: Implement vertex attributes in VertexBuffer and remove most of the code here
void Chunk::draw(RenderTarget &target, RenderStates states) const {
if(m_verticesCount == 0) return;
@ -236,6 +216,7 @@ void Chunk::draw(RenderTarget &target, RenderStates states) const {
VertexBuffer::bind(&m_vbo);
// FIXME: Find a way to give this job to RenderTarget
m_vbo.setAttribPointer(states.shader->attrib("normal"), 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(m_verticesCount * sizeof(float)));
m_vbo.setAttribPointer(states.shader->attrib("texCoord"), 2, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((m_verticesCount + m_normalsCount) * sizeof(float)));