fix extended blocks solidity & fix extended blocks neighbours update
This commit is contained in:
parent
64cf9bb273
commit
b217c902c4
@ -31,6 +31,11 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
||||
def.rt.solid = def.model == BlockModel::block;
|
||||
def.rt.extended = def.size.x > 1 || def.size.y > 1 || def.size.z > 1;
|
||||
|
||||
const float EPSILON = 0.01f;
|
||||
if (def.rt.extended && glm::i8vec3(def.hitboxes[0].size() + EPSILON) == def.size) {
|
||||
def.rt.solid = true;
|
||||
}
|
||||
|
||||
if (def.rotatable) {
|
||||
for (uint i = 0; i < BlockRotProfile::MAX_COUNT; i++) {
|
||||
def.rt.hitboxes[i].reserve(def.hitboxes.size());
|
||||
|
||||
@ -33,6 +33,29 @@ void BlocksController::updateSides(int x, int y, int z) {
|
||||
updateBlock(x, y, z + 1);
|
||||
}
|
||||
|
||||
void BlocksController::updateSides(int x, int y, int z, int w, int h, int d) {
|
||||
voxel* vox = chunks->get(x, y, z);
|
||||
const auto& def = level->content->getIndices()->blocks.require(vox->id);
|
||||
const auto& rot = def.rotations.variants[vox->state.rotation];
|
||||
const auto& xaxis = rot.axisX;
|
||||
const auto& yaxis = rot.axisY;
|
||||
const auto& zaxis = rot.axisZ;
|
||||
for (int ly = -1; ly <= h; ly++) {
|
||||
for (int lz = -1; lz <= d; lz++) {
|
||||
for (int lx = -1; lx <= w; lx++) {
|
||||
if (lx >= 0 && lx < w && ly >= 0 && ly < h && lz >= 0 && lz < d) {
|
||||
continue;
|
||||
}
|
||||
updateBlock(
|
||||
x + lx * xaxis.x + ly * yaxis.x + lz * zaxis.x,
|
||||
y + lx * xaxis.y + ly * yaxis.y + lz * zaxis.y,
|
||||
z + lx * xaxis.z + ly * yaxis.z + lz * zaxis.z
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlocksController::breakBlock(
|
||||
Player* player, const Block& def, int x, int y, int z
|
||||
) {
|
||||
@ -42,8 +65,12 @@ void BlocksController::breakBlock(
|
||||
chunks->set(x, y, z, 0, {});
|
||||
lighting->onBlockSet(x, y, z, 0);
|
||||
scripting::on_block_broken(player, def, x, y, z);
|
||||
if (def.rt.extended) {
|
||||
updateSides(x, y, z , def.size.x, def.size.y, def.size.z);
|
||||
} else {
|
||||
updateSides(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void BlocksController::placeBlock(
|
||||
Player* player, const Block& def, blockstate state, int x, int y, int z
|
||||
@ -56,8 +83,12 @@ void BlocksController::placeBlock(
|
||||
if (def.rt.funcsset.onplaced) {
|
||||
scripting::on_block_placed(player, def, x, y, z);
|
||||
}
|
||||
if (def.rt.extended) {
|
||||
updateSides(x, y, z , def.size.x, def.size.y, def.size.z);
|
||||
} else {
|
||||
updateSides(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void BlocksController::updateBlock(int x, int y, int z) {
|
||||
voxel* vox = chunks->get(x, y, z);
|
||||
|
||||
@ -37,6 +37,7 @@ public:
|
||||
BlocksController(Level* level, uint padding);
|
||||
|
||||
void updateSides(int x, int y, int z);
|
||||
void updateSides(int x, int y, int z, int w, int h, int d);
|
||||
void updateBlock(int x, int y, int z);
|
||||
|
||||
void breakBlock(Player* player, const Block& def, int x, int y, int z);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user