mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 07:11:37 +02:00
More undo work
This commit is contained in:
parent
448e3a0947
commit
378afdf117
2 changed files with 5 additions and 23 deletions
|
@ -42,7 +42,7 @@ void VoxelTree::deleteVoxelAt(float x, float y, float z, float s) {
|
|||
}
|
||||
|
||||
VoxelTreeElement* VoxelTree::getVoxelAt(float x, float y, float z, float s) const {
|
||||
return (VoxelTreeElement*)getOctreeElementAt(x, y, z, s);
|
||||
return static_cast<VoxelTreeElement*>(getOctreeElementAt(x, y, z, s));
|
||||
}
|
||||
|
||||
void VoxelTree::createVoxel(float x, float y, float z, float s,
|
||||
|
|
|
@ -22,27 +22,8 @@ AddVoxelCommand::AddVoxelCommand(VoxelTree* tree, VoxelDetail& voxel, VoxelEditP
|
|||
{
|
||||
VoxelTreeElement* element = _tree->getVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s);
|
||||
if (element) {
|
||||
if (element->hasContent() && element->isLeaf()) {
|
||||
// Do nothing, everything is in order
|
||||
} else {
|
||||
_oldTree = new VoxelTree();
|
||||
_tree->copySubTreeIntoNewTree(element, _oldTree, true);
|
||||
}
|
||||
} else {
|
||||
glm::vec3 point(_voxel.x + _voxel.s / 2.0f,
|
||||
_voxel.y + _voxel.s / 2.0f,
|
||||
_voxel.z + _voxel.s / 2.0f);
|
||||
OctreeElement* element = _tree->getElementEnclosingPoint(point, Octree::Lock);
|
||||
if (element) {
|
||||
VoxelTreeElement* node = static_cast<VoxelTreeElement*>(element);
|
||||
_voxel.x = node->getCorner().x;
|
||||
_voxel.y = node->getCorner().y;
|
||||
_voxel.z = node->getCorner().z;
|
||||
_voxel.s = node->getScale();
|
||||
_voxel.red = node->getColor()[0];
|
||||
_voxel.green = node->getColor()[1];
|
||||
_voxel.blue = node->getColor()[2];
|
||||
}
|
||||
_oldTree = new VoxelTree();
|
||||
_tree->copySubTreeIntoNewTree(element, _oldTree, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +43,9 @@ void AddVoxelCommand::redo() {
|
|||
void AddVoxelCommand::undo() {
|
||||
if (_oldTree) {
|
||||
OctreeElement* element = _tree->getOrCreateChildElementAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s);
|
||||
qDebug() << _voxel.x << " " << _voxel.y << " " << _voxel.z << " " << _voxel.s;
|
||||
qDebug() << "undo(): " << _voxel.x << " " << _voxel.y << " " << _voxel.z << " " << _voxel.s;
|
||||
_tree->copyFromTreeIntoSubTree(_oldTree, element);
|
||||
qDebug() << "done";
|
||||
} else {
|
||||
if (_tree) {
|
||||
_tree->deleteVoxelAt(_voxel.x, _voxel.y, _voxel.z, _voxel.s);
|
||||
|
|
Loading…
Reference in a new issue