fix generator area centering
This commit is contained in:
parent
c110fafbcf
commit
98813472a8
@ -77,8 +77,8 @@ void LevelController::update(float delta, bool pause) {
|
|||||||
player->updateEntity();
|
player->updateEntity();
|
||||||
glm::vec3 position = player->getPosition();
|
glm::vec3 position = player->getPosition();
|
||||||
player->chunks->configure(
|
player->chunks->configure(
|
||||||
position.x,
|
glm::floor(position.x),
|
||||||
position.z,
|
glm::floor(position.z),
|
||||||
settings.chunks.loadDistance.get() + settings.chunks.padding.get()
|
settings.chunks.loadDistance.get() + settings.chunks.padding.get()
|
||||||
);
|
);
|
||||||
chunks->update(
|
chunks->update(
|
||||||
|
|||||||
@ -32,18 +32,18 @@ Chunks::Chunks(
|
|||||||
: events(events),
|
: events(events),
|
||||||
indices(indices),
|
indices(indices),
|
||||||
areaMap(w, d) {
|
areaMap(w, d) {
|
||||||
areaMap.setCenter(ox-w/2, oz-d/2);
|
areaMap.setCenter(ox - w / 2, oz - d / 2);
|
||||||
areaMap.setOutCallback([this](int, int, const auto& chunk) {
|
areaMap.setOutCallback([this](int, int, const auto& chunk) {
|
||||||
this->events->trigger(LevelEventType::CHUNK_HIDDEN, chunk.get());
|
this->events->trigger(LevelEventType::CHUNK_HIDDEN, chunk.get());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chunks::configure(int32_t x, int32_t z, uint32_t radius) {
|
void Chunks::configure(int32_t x, int32_t z, uint32_t radius) {
|
||||||
setCenter(x, z);
|
|
||||||
uint32_t diameter = radius * 2LL;
|
uint32_t diameter = radius * 2LL;
|
||||||
if (getWidth() != diameter) {
|
if (getWidth() != diameter) {
|
||||||
resize(diameter, diameter);
|
resize(diameter, diameter);
|
||||||
}
|
}
|
||||||
|
setCenter(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
voxel* Chunks::get(int32_t x, int32_t y, int32_t z) const {
|
voxel* Chunks::get(int32_t x, int32_t y, int32_t z) const {
|
||||||
@ -313,7 +313,7 @@ glm::vec3 Chunks::rayCastToObstacle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Chunks::setCenter(int32_t x, int32_t z) {
|
void Chunks::setCenter(int32_t x, int32_t z) {
|
||||||
areaMap.setCenter(floordiv(x, CHUNK_W), floordiv(z, CHUNK_D));
|
areaMap.setCenter(floordiv<CHUNK_W>(x), floordiv<CHUNK_D>(z));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chunks::resize(uint32_t newW, uint32_t newD) {
|
void Chunks::resize(uint32_t newW, uint32_t newD) {
|
||||||
|
|||||||
@ -355,9 +355,7 @@ void WorldGenerator::generateHeightmap(
|
|||||||
|
|
||||||
void WorldGenerator::update(int centerX, int centerY, int loadDistance) {
|
void WorldGenerator::update(int centerX, int centerY, int loadDistance) {
|
||||||
surroundMap.setCenter(centerX, centerY);
|
surroundMap.setCenter(centerX, centerY);
|
||||||
// 3 is safety padding preventing ChunksController rounding problem
|
surroundMap.resize(loadDistance);
|
||||||
// FIXME
|
|
||||||
surroundMap.resize(loadDistance + 3);
|
|
||||||
surroundMap.setCenter(centerX, centerY);
|
surroundMap.setCenter(centerX, centerY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user