mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
fix: air blocks placement; ghost segments can not be removed
This commit is contained in:
parent
1abb2cf327
commit
1bfd5ccad3
1 changed files with 9 additions and 3 deletions
|
|
@ -352,11 +352,17 @@ voxel* PlayerController::updateSelection(float maxDistance) {
|
||||||
selection.vox = *vox;
|
selection.vox = *vox;
|
||||||
selection.actualPosition = iend;
|
selection.actualPosition = iend;
|
||||||
if (selectedState.segment) {
|
if (selectedState.segment) {
|
||||||
iend = chunks->seekOrigin(
|
selection.position = chunks->seekOrigin(
|
||||||
iend, indices->getBlockDef(selection.vox.id), selectedState
|
iend, indices->getBlockDef(selection.vox.id), selectedState
|
||||||
);
|
);
|
||||||
|
auto origin = chunks->get(iend);
|
||||||
|
if (origin && origin->id != vox->id) {
|
||||||
|
chunks->set(iend.x, iend.y, iend.z, 0, {});
|
||||||
|
return updateSelection(maxDistance);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selection.position = iend;
|
||||||
}
|
}
|
||||||
selection.position = iend;
|
|
||||||
selection.hitPosition = end;
|
selection.hitPosition = end;
|
||||||
selection.normal = norm;
|
selection.normal = norm;
|
||||||
return vox;
|
return vox;
|
||||||
|
|
@ -398,7 +404,7 @@ void PlayerController::processRightClick(Block* def, Block* target) {
|
||||||
if (def->grounded && !chunks->isSolidBlock(coord.x, coord.y-1, coord.z)) {
|
if (def->grounded && !chunks->isSolidBlock(coord.x, coord.y-1, coord.z)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (chosenBlock != vox->id) {
|
if (chosenBlock != vox->id && chosenBlock) {
|
||||||
onBlockInteraction(coord, def, BlockInteraction::placing);
|
onBlockInteraction(coord, def, BlockInteraction::placing);
|
||||||
chunks->set(coord.x, coord.y, coord.z, chosenBlock, state);
|
chunks->set(coord.x, coord.y, coord.z, chosenBlock, state);
|
||||||
lighting->onBlockSet(coord.x, coord.y, coord.z, chosenBlock);
|
lighting->onBlockSet(coord.x, coord.y, coord.z, chosenBlock);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue