|
@@ -191,6 +191,10 @@ void DimensionGenerator::setSeed(JFloatExpression* seed)
|
|
|
seedExpression = seed;
|
|
|
}
|
|
|
|
|
|
+const Framework::Text DimensionGenerator::X = "x";
|
|
|
+const Framework::Text DimensionGenerator::Y = "y";
|
|
|
+const Framework::Text DimensionGenerator::Z = "z";
|
|
|
+
|
|
|
JFloatExpression* DimensionGenerator::zSeed() const
|
|
|
{
|
|
|
return seedExpression;
|
|
@@ -248,13 +252,13 @@ BiomedCavedDimensionGenerator::getGeneratedStructoresForArea(
|
|
|
{
|
|
|
for (int y = minSearchY; y <= maxSearchY; y++)
|
|
|
{
|
|
|
- zMemory()->setFloatVariable("x", (float)x);
|
|
|
- zMemory()->setFloatVariable("y", (float)y);
|
|
|
+ zMemory()->setFloatVariable(X, (float)x);
|
|
|
+ zMemory()->setFloatVariable(Y, (float)y);
|
|
|
calculateHeightLayers();
|
|
|
BiomGenerator* gen = zBiomGenerator();
|
|
|
for (int z = minSearchZ; z <= maxSearchZ; z++)
|
|
|
{
|
|
|
- zMemory()->setFloatVariable("z", (float)z);
|
|
|
+ zMemory()->setFloatVariable(Z, (float)z);
|
|
|
gen->generateStructures(x,
|
|
|
y,
|
|
|
z,
|
|
@@ -275,13 +279,8 @@ Chunk* BiomedCavedDimensionGenerator::generateChunk(int centerX, int centerY)
|
|
|
Framework::Logging::debug()
|
|
|
<< "generating chunk " << centerX << ", " << centerY;
|
|
|
double structureTime = 0;
|
|
|
- double structureTime2 = 0;
|
|
|
- double structureTime3 = 0;
|
|
|
double caveTime = 0;
|
|
|
- double caveTime2 = 0;
|
|
|
double blockGenTime = 0;
|
|
|
- double biomTime = 0;
|
|
|
- double layerTime = 0;
|
|
|
Framework::ZeitMesser zm;
|
|
|
Framework::ZeitMesser zmGlobal;
|
|
|
zm.messungStart();
|
|
@@ -307,54 +306,36 @@ Chunk* BiomedCavedDimensionGenerator::generateChunk(int centerX, int centerY)
|
|
|
{
|
|
|
for (int y = -CHUNK_SIZE / 2; y < CHUNK_SIZE / 2; y++)
|
|
|
{
|
|
|
- zMemory()->setFloatVariable("x", (float)x + (float)centerX);
|
|
|
- zMemory()->setFloatVariable("y", (float)y + (float)centerY);
|
|
|
+ zMemory()->setFloatVariable(X, (float)x + (float)centerX);
|
|
|
+ zMemory()->setFloatVariable(Y, (float)y + (float)centerY);
|
|
|
// calculate height layers
|
|
|
- zm.messungStart();
|
|
|
calculateHeightLayers();
|
|
|
- zm.messungEnde();
|
|
|
- layerTime += zm.getSekunden();
|
|
|
// calculate biom
|
|
|
- zm.messungStart();
|
|
|
BiomGenerator* biom = zBiomGenerator();
|
|
|
- zm.messungEnde();
|
|
|
- biomTime += zm.getSekunden();
|
|
|
// generate blocks
|
|
|
for (int z = 0; z < WORLD_HEIGHT; z++)
|
|
|
{
|
|
|
- zMemory()->setFloatVariable("z", (float)z);
|
|
|
+ zMemory()->setFloatVariable(Z, (float)z);
|
|
|
Framework::Either<Block*, int> generated = BlockTypeEnum::AIR;
|
|
|
bool structureAffected = 0;
|
|
|
// check if the block is inside of a structure
|
|
|
- zm.messungStart();
|
|
|
for (auto structure : *structures)
|
|
|
{
|
|
|
if (structure->isBlockAffected(
|
|
|
Framework::Vec3<int>(x + centerX, y + centerY, z)))
|
|
|
{
|
|
|
- zm.messungEnde();
|
|
|
- structureTime2 += zm.getSekunden();
|
|
|
- zm.messungStart();
|
|
|
generated = structure->generateBlockAt(
|
|
|
Framework::Vec3<int>(x + centerX, y + centerY, z),
|
|
|
getDimensionId());
|
|
|
structureAffected = 1;
|
|
|
- zm.messungEnde();
|
|
|
- structureTime3 += zm.getSekunden();
|
|
|
- zm.messungStart();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- zm.messungEnde();
|
|
|
- structureTime2 += zm.getSekunden();
|
|
|
if (!structureAffected)
|
|
|
{
|
|
|
// check if block is a cave block
|
|
|
- zm.messungStart();
|
|
|
bool inCave
|
|
|
= caveGen->isInCave(x + centerX, y + centerY, z);
|
|
|
- zm.messungEnde();
|
|
|
- caveTime2 += zm.getSekunden();
|
|
|
if (!inCave)
|
|
|
{
|
|
|
// generate biom block
|
|
@@ -386,15 +367,8 @@ Chunk* BiomedCavedDimensionGenerator::generateChunk(int centerX, int centerY)
|
|
|
structures->release();
|
|
|
zmGlobal.messungEnde();
|
|
|
Framework::Logging::trace() << "structureGenerationTime: " << structureTime;
|
|
|
- Framework::Logging::trace()
|
|
|
- << "structure.isBlockAffected: " << structureTime2;
|
|
|
- Framework::Logging::trace()
|
|
|
- << "structure.generateBlockAt: " << structureTime3;
|
|
|
Framework::Logging::trace() << "caveGenerationTime: " << caveTime;
|
|
|
- Framework::Logging::trace() << "caveEvaluationTime: " << caveTime2;
|
|
|
Framework::Logging::trace() << "blockGenTime: " << blockGenTime;
|
|
|
- Framework::Logging::trace() << "biomTime: " << biomTime;
|
|
|
- Framework::Logging::trace() << "layerTime: " << layerTime;
|
|
|
Framework::Logging::debug() << "totalTime: " << zmGlobal.getSekunden();
|
|
|
zMemory()->unlock();
|
|
|
return chunk;
|
|
@@ -405,8 +379,8 @@ void BiomedCavedDimensionGenerator::generateEntities(Chunk* zChunk)
|
|
|
zMemory()->lock();
|
|
|
zMemory()->setCurrentChunk(dynamic_cast<Chunk*>(zChunk->getThis()));
|
|
|
|
|
|
- zMemory()->setFloatVariable("x", (float)zChunk->getCenter().x);
|
|
|
- zMemory()->setFloatVariable("y", (float)zChunk->getCenter().y);
|
|
|
+ zMemory()->setFloatVariable(X, (float)zChunk->getCenter().x);
|
|
|
+ zMemory()->setFloatVariable(Y, (float)zChunk->getCenter().y);
|
|
|
|
|
|
calculateHeightLayers();
|
|
|
BiomGenerator* biom = zBiomGenerator();
|
|
@@ -416,14 +390,20 @@ void BiomedCavedDimensionGenerator::generateEntities(Chunk* zChunk)
|
|
|
{
|
|
|
for (int z = 0; z < WORLD_HEIGHT; z++)
|
|
|
{
|
|
|
- if (zChunk->getBlockTypeAt(Framework::Vec3<int>(x, y, z))
|
|
|
+ if (zChunk->getBlockTypeAt(Framework::Vec3<int>(
|
|
|
+ x + CHUNK_SIZE / 2, y + CHUNK_SIZE / 2, z))
|
|
|
== BlockTypeEnum::AIR)
|
|
|
{
|
|
|
- zMemory()->setFloatVariable("x", (float)z);
|
|
|
- zMemory()->setFloatVariable("y", (float)z);
|
|
|
- zMemory()->setFloatVariable("z", (float)z);
|
|
|
- biom->generateEntities(
|
|
|
- x, y, z, getDimensionId(), zMemory());
|
|
|
+ zMemory()->setFloatVariable(
|
|
|
+ X, (float)x + (float)zChunk->getCenter().x);
|
|
|
+ zMemory()->setFloatVariable(
|
|
|
+ Y, (float)y + (float)zChunk->getCenter().y);
|
|
|
+ zMemory()->setFloatVariable(Z, (float)z);
|
|
|
+ biom->generateEntities(x + zChunk->getCenter().x,
|
|
|
+ y + zChunk->getCenter().y,
|
|
|
+ z,
|
|
|
+ getDimensionId(),
|
|
|
+ zMemory());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -448,13 +428,13 @@ Framework::Either<Block*, int> BiomedCavedDimensionGenerator::generateBlock(
|
|
|
Framework::RCArray<GeneratedStructure>* structures
|
|
|
= getGeneratedStructoresForArea(location, location);
|
|
|
|
|
|
- zMemory()->setFloatVariable("x", (float)location.x);
|
|
|
- zMemory()->setFloatVariable("y", (float)location.y);
|
|
|
+ zMemory()->setFloatVariable(X, (float)location.x);
|
|
|
+ zMemory()->setFloatVariable(Y, (float)location.y);
|
|
|
|
|
|
calculateHeightLayers();
|
|
|
BiomGenerator* biom = zBiomGenerator();
|
|
|
|
|
|
- zMemory()->setFloatVariable("z", (float)location.z);
|
|
|
+ zMemory()->setFloatVariable(Z, (float)location.z);
|
|
|
|
|
|
for (auto structure : *structures)
|
|
|
{
|
|
@@ -495,8 +475,8 @@ bool BiomedCavedDimensionGenerator::spawnStructure(
|
|
|
std::function<bool(GeneratorTemplate* tmpl)> filter)
|
|
|
{
|
|
|
zMemory()->lock();
|
|
|
- zMemory()->setFloatVariable("x", (float)location.x);
|
|
|
- zMemory()->setFloatVariable("y", (float)location.y);
|
|
|
+ zMemory()->setFloatVariable(X, (float)location.x);
|
|
|
+ zMemory()->setFloatVariable(Y, (float)location.y);
|
|
|
|
|
|
BiomGenerator* biom = zBiomGenerator();
|
|
|
zMemory()->unlock();
|