Skip to content

Commit

Permalink
Revert "优化更新区块列表"
Browse files Browse the repository at this point in the history
This reverts commit f731106.
  • Loading branch information
Null committed Oct 24, 2015
1 parent 5b80779 commit 07badfb
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 267 deletions.
22 changes: 10 additions & 12 deletions source/Chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace world{
delete[] pbrightness;
pblocks = nullptr;
pbrightness = nullptr;
//updated = false;
unloadedChunksCounter++;
updated = false;
unloadedChunks++;
}

void chunk::build(){
Expand Down Expand Up @@ -104,8 +104,7 @@ namespace world{
build();
#endif
if (Empty)destroy();
//else updated = true;
else world::setChunkUpdated(cx, cy, cz);
else updated = true;
}

void chunk::Unload(){
Expand Down Expand Up @@ -133,8 +132,8 @@ namespace world{
file.close();
}

bool chunk::buildRender(){
if (Empty) return false;
void chunk::buildRender(){
if (Empty) return;
#ifdef NEWORLD_DEBUG_CONSOLE_OUTPUT
if (pblocks == nullptr || pbrightness == nullptr){
DebugWarning("Empty pointer when building vertex buffers!");
Expand All @@ -147,14 +146,14 @@ namespace world{
for (y = -1; y <= 1; y++) {
for (z = -1; z <= 1; z++) {
if (x == 0 && y == 0 && z == 0) continue;
if (chunkOutOfBound(cx + x, cy + y, cz + z)) continue;
if (!chunkLoaded(cx + x, cy + y, cz + z)) return false;
if (chunkOutOfBound(cx + x, cy + y, cz + z)) continue;
if (!chunkLoaded(cx + x, cy + y, cz + z)) return;
}
}
}

//rebuiltChunksCounter++;
updatedChunksCounter++;
rebuiltChunks++;
updatedChunks++;

if (renderBuilt == false){
renderBuilt = true;
Expand Down Expand Up @@ -196,9 +195,8 @@ namespace world{
}
}
renderer::Flush(vbuffer[2], vertexes[2]);
//updated = false;
updated = false;

return true;
}

void chunk::destroyRender(){
Expand Down
4 changes: 2 additions & 2 deletions source/Chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace world{
extern string worldname;
extern brightness BRIGHTNESSMIN;
extern brightness skylight;

class chunk{

private:
Expand Down Expand Up @@ -46,7 +46,7 @@ namespace world{
}
void LoadFromFile();
void SaveToFile();
bool buildRender();
void buildRender();
void destroyRender();

inline block getblock(int x, int y, int z) {
Expand Down
5 changes: 2 additions & 3 deletions source/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

/*
#define NEWORLD_COMPILE_DISABLE_SECURE
#ifndef nullptr
#define nullptr NULL
#ifndef M_PI
#define M_PI 3.14159265898
#endif
*/

//#define NEWORLD_DEBUG
#define NEWORLD_DEBUG
#ifdef NEWORLD_DEBUG
#define NEWORLD_DEBUG_CONSOLE_OUTPUT
#define NEWORLD_DEBUG_NO_FILEIO
Expand Down
Loading

0 comments on commit 07badfb

Please sign in to comment.