WIP: Volume grid attribute support in geometry nodes #110044

Closed
Lukas Tönne wants to merge 130 commits from LukasTonne/blender:geometry-nodes-flip into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 22 additions and 2 deletions
Showing only changes of commit 39fd31c7ee - Show all commits

View File

@ -10,6 +10,10 @@
#include "BLI_math_base.hh"
#include "BLI_volume_openvdb.hh"
#ifdef WITH_OPENVDB
# include <openvdb/tools/ValueTransformer.h>
#endif
namespace blender::volume {
#ifdef WITH_OPENVDB
@ -19,11 +23,27 @@ GridMask::GridPtr GridMask::empty_grid()
return grid;
}
struct BoolGridToMask {
volume::Grid<bool>::GridType::ConstAccessor accessor;
inline void operator()(const openvdb::MaskGrid::ValueOnIter &iter) const
{
const openvdb::Coord coord = iter.getCoord();
if (!accessor.isValueOn(coord)) {
iter.setActiveState(false);
}
}
};
GridMask GridMask::from_bools(const volume::GridMask &full_mask,
const volume::Grid<bool> &selection)
{
BLI_assert_unreachable();
return {};
volume::GridMask result = {full_mask.grid()->copy()};
if (selection) {
BoolGridToMask op{selection.grid_->getConstAccessor()};
openvdb::tools::foreach (result.grid_->beginValueOn(), op);
}
return result;
}
bool GridMask::is_empty() const