[Block] Useless code removed.
This commit is contained in:
parent
9fd25da16a
commit
ac88ba4b97
@ -20,12 +20,10 @@
|
|||||||
|
|
||||||
class Block {
|
class Block {
|
||||||
public:
|
public:
|
||||||
Block(const glm::vec3 &pos, u32 id);
|
Block(u32 id);
|
||||||
|
|
||||||
glm::vec4 getTexCoords(int face);
|
glm::vec4 getTexCoords(int face);
|
||||||
|
|
||||||
const glm::vec3 &pos() const { return m_pos; }
|
|
||||||
|
|
||||||
u32 id() const { return m_id; }
|
u32 id() const { return m_id; }
|
||||||
void setId(u32 id) { m_id = 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; }
|
void setSelected(bool isSelected, s8 face) { m_isSelected = isSelected; m_selectedFace = face; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
glm::vec3 m_pos;
|
|
||||||
|
|
||||||
u32 m_id;
|
u32 m_id;
|
||||||
|
|
||||||
bool m_isSelected = false;
|
bool m_isSelected = false;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "Block.hpp"
|
#include "Block.hpp"
|
||||||
|
|
||||||
Block::Block(const glm::vec3 &pos, u32 id) : m_pos(pos) {
|
Block::Block(u32 id) {
|
||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,23 +81,9 @@ void Chunk::update() {
|
|||||||
for(u8 y = 0 ; y < height ; y++) {
|
for(u8 y = 0 ; y < height ; y++) {
|
||||||
for(u8 x = 0 ; x < width ; x++) {
|
for(u8 x = 0 ; x < width ; x++) {
|
||||||
Block *block = getBlock(x, y, z);
|
Block *block = getBlock(x, y, z);
|
||||||
|
if(!block || !block->id()) continue;
|
||||||
|
|
||||||
if(!block || !block->id()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
float cubeTexCoords[2 * 4 * 6];
|
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++) {
|
for(int i = 0 ; i < 6 ; i++) {
|
||||||
const glm::vec4 &blockTexCoords = block->getTexCoords(i);
|
const glm::vec4 &blockTexCoords = block->getTexCoords(i);
|
||||||
float faceTexCoords[2 * 4] = {
|
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 < 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; }
|
if(z >= Chunk::depth) { if(m_surroundingChunks[3]) m_surroundingChunks[3]->setBlock(x, y, z - Chunk::depth, type); return; }
|
||||||
|
|
||||||
glm::vec3 pos;
|
m_data[x][y][z].reset(new Block(type));
|
||||||
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_isChanged = true;
|
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; }
|
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 {
|
void Chunk::draw(RenderTarget &target, RenderStates states) const {
|
||||||
if(m_verticesCount == 0) return;
|
if(m_verticesCount == 0) return;
|
||||||
|
|
||||||
@ -236,6 +216,7 @@ void Chunk::draw(RenderTarget &target, RenderStates states) const {
|
|||||||
|
|
||||||
VertexBuffer::bind(&m_vbo);
|
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("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)));
|
m_vbo.setAttribPointer(states.shader->attrib("texCoord"), 2, GL_FLOAT, GL_FALSE, 0, (GLvoid*)((m_verticesCount + m_normalsCount) * sizeof(float)));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user