|
@@ -96,6 +96,7 @@ void Chunk::load(Framework::StreamReader* zReader)
|
|
|
Framework::Vec3<int> pos = {0, 0, 0};
|
|
|
unsigned short id;
|
|
|
zReader->lese((char*)&id, 2);
|
|
|
+ int count = 0;
|
|
|
while (id)
|
|
|
{
|
|
|
int index;
|
|
@@ -122,10 +123,12 @@ void Chunk::load(Framework::StreamReader* zReader)
|
|
|
visibleBlocks.add(b);
|
|
|
}
|
|
|
}
|
|
|
+ count++;
|
|
|
vcs.unlock();
|
|
|
}
|
|
|
zReader->lese((char*)&id, 2);
|
|
|
}
|
|
|
+ std::cout << "Loaded " << count << " blocks\n";
|
|
|
int index = 0;
|
|
|
// light
|
|
|
zReader->lese((char*)&index, 4);
|
|
@@ -609,7 +612,7 @@ void Chunk::setBlock(Block* block)
|
|
|
vcs.lock();
|
|
|
if (affectsGround || newAffectsGround)
|
|
|
{
|
|
|
- buildGroundModel();
|
|
|
+ modelChanged = 1;
|
|
|
}
|
|
|
if (block && block->isVisible() && !newAffectsGround)
|
|
|
{
|
|
@@ -624,7 +627,7 @@ void Chunk::setBlock(Block* block)
|
|
|
vcs.lock();
|
|
|
if (affectsGround || newAffectsGround)
|
|
|
{
|
|
|
- buildGroundModel();
|
|
|
+ modelChanged = 1;
|
|
|
}
|
|
|
if (block && block->isVisible() && !newAffectsGround)
|
|
|
{
|
|
@@ -663,7 +666,7 @@ void Chunk::removeBlock(Block* zBlock)
|
|
|
.istGleich("cube");
|
|
|
blocks[index]->release();
|
|
|
blocks[index] = 0;
|
|
|
- if (affectsGround) buildGroundModel();
|
|
|
+ if (affectsGround) modelChanged = 1;
|
|
|
}
|
|
|
cs.unlock();
|
|
|
}
|
|
@@ -721,6 +724,11 @@ bool Chunk::tick(std::function<void(Model3D*)> f, double time)
|
|
|
{
|
|
|
acs.lock();
|
|
|
vcs.lock(); // TODO: enshure no dead lock occures
|
|
|
+ if (modelChanged)
|
|
|
+ {
|
|
|
+ modelChanged = 0;
|
|
|
+ buildGroundModel();
|
|
|
+ }
|
|
|
if (lightChanged)
|
|
|
{
|
|
|
lightChanged = 0;
|