Skip to content

Commit

Permalink
VOXEDIT: also preview the erasing area/shape
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Jul 31, 2023
1 parent 448443b commit 68b1462
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/tools/voxedit/modules/voxedit-util/modifier/Modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,14 @@ bool Modifier::aabbAction(voxel::RawVolume *volume, const Callback &callback) {
return planeModifier(volume, callback);
}

runModifier(volume, callback);
runModifier(volume, _modifierType, callback);

_secondPosValid = false;
return true;
}

bool Modifier::runModifier(voxel::RawVolume *volume, const Callback &callback) {
ModifierVolumeWrapper wrapper(volume, _modifierType, _selections);
bool Modifier::runModifier(voxel::RawVolume *volume, ModifierType modifierType, const Callback &callback) {
ModifierVolumeWrapper wrapper(volume, modifierType, _selections);
const math::AABB<int> a = aabb();
glm::ivec3 minsMirror = a.mins();
glm::ivec3 maxsMirror = a.maxs();
Expand Down
2 changes: 1 addition & 1 deletion src/tools/voxedit/modules/voxedit-util/modifier/Modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Modifier : public core::IComponent {
bool planeModifier(voxel::RawVolume *volume, const Callback &callback);
bool pathModifier(voxel::RawVolume *volume, const Callback &callback);

bool runModifier(voxel::RawVolume *volume, const Callback &callback = [] (const voxel::Region &, ModifierType, bool) {});
bool runModifier(voxel::RawVolume *volume, ModifierType modifierType, const Callback &callback = [] (const voxel::Region &, ModifierType, bool) {});

math::AABB<int> aabb() const;
public:
Expand Down
12 changes: 10 additions & 2 deletions src/tools/voxedit/modules/voxedit-util/modifier/ModifierFacade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ModifierFacade.h"
#include "core/ScopedPtr.h"
#include "voxedit-util/modifier/ModifierType.h"
#include "voxel/Face.h"
#include "voxel/RawVolume.h"
#define GLM_ENABLE_EXPERIMENTAL
Expand Down Expand Up @@ -60,13 +61,20 @@ void ModifierFacade::render(const video::Camera &camera, voxel::Palette &palette
glm::ivec3 minsMirror = mins;
glm::ivec3 maxsMirror = maxs;
_modifierRenderer->clearShapeMeshes();

// even in erase mode we want the preview to create the models, not wipe them
ModifierType modifierType = _modifierType;
if ((modifierType & ModifierType::Erase) == ModifierType::Erase) {
modifierType &= ~ModifierType::Erase;
}

if (getMirrorAABB(minsMirror, maxsMirror)) {
_mirrorVolume = new voxel::RawVolume(voxel::Region(minsMirror, maxsMirror + 1));
runModifier(_mirrorVolume);
runModifier(_mirrorVolume, modifierType);
_modifierRenderer->updateShapeMesh(1, _mirrorVolume, &palette);
}
_volume = new voxel::RawVolume(voxel::Region(mins, maxs + 1));
runModifier(_volume);
runModifier(_volume, modifierType);
_modifierRenderer->updateShapeMesh(0, _volume, &palette);
}
}
Expand Down

0 comments on commit 68b1462

Please sign in to comment.