Skip to content

Commit 1912b09

Browse files
committed
Add an option to specify the expansion pattern.
Rename the label of the expand voxels to match the current Houdini name. Signed-off-by: jlait <[email protected]>
1 parent dd69b1a commit 1912b09

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ an inclusive range, so includes the maximum voxel.)"));
214214
Expand the active area by at least the specified number of voxels. Does not
215215
support operation or setting of values.
216216
*/
217-
parms.add(hutil::ParmFactory(PRM_INT, "expand", "Voxels to Expand")
217+
parms.add(hutil::ParmFactory(PRM_INT, "expand", "Expand Voxels")
218218
.setDefault(PRMoneDefaults)
219219
.setRange(PRM_RANGE_FREE, -5, PRM_RANGE_FREE, 5)
220220
.setTooltip("Expand the active area by at least the specified number of voxels.")
@@ -233,6 +233,20 @@ operation or setting of values.)"));
233233
.setDocumentation(
234234
R"(Expand the active area by at least the specified distance. Does not support operation or setting of values.)"));
235235

236+
/*
237+
Specifies which nearby voxels are considered neighbors for expansion.
238+
*/
239+
parms.add(hutil::ParmFactory(PRM_STRING, "expansionpattern", "Expansion Pattern")
240+
.setChoiceListItems(PRM_CHOICELIST_SINGLE, {
241+
"face", "Plus",
242+
"faceedge", "Diamond",
243+
"faceedgevertex", "Box"
244+
})
245+
.setDefault("face")
246+
.setTooltip("Set pattern used to identify neighbor voxels for expansion.")
247+
.setDocumentation(
248+
R"(Specifies which nearby voxels are considered neighbors for expansion.)"));
249+
236250
parms.addFolder("Reference");
237251
/*
238252
Uses the second input to determine the selected region.
@@ -490,9 +504,9 @@ sopFillSDF(GridType &grid, int dummy)
490504

491505
template <typename GridType>
492506
static void
493-
sopDilateVoxels(GridType& grid, exint count)
507+
sopDilateVoxels(GridType& grid, exint count, openvdb::tools::NearestNeighbors nn)
494508
{
495-
openvdb::tools::dilateActiveValues(grid.tree(), static_cast<int>(count));
509+
openvdb::tools::dilateActiveValues(grid.tree(), static_cast<int>(count), nn);
496510
}
497511

498512
template <typename GridType>
@@ -557,6 +571,7 @@ SOP_VDBActivate::Cache::cookVDBSop(OP_Context &context)
557571
{
558572
using namespace openvdb;
559573
using namespace openvdb::math;
574+
using namespace openvdb::tools;
560575

561576
try
562577
{
@@ -677,9 +692,15 @@ SOP_VDBActivate::Cache::cookVDBSop(OP_Context &context)
677692
{
678693
if (boss->opInterrupt())
679694
break;
695+
NearestNeighbors nn = NN_FACE;
696+
const auto str = evalStdString("expansionpattern", t);
697+
if (str == "faceedge")
698+
nn = NN_FACE_EDGE;
699+
else if (str == "faceedgevertex")
700+
nn = NN_FACE_EDGE_VERTEX;
680701
UTvdbCallAllTopology(vdb->getStorageType(),
681702
sopDilateVoxels,
682-
vdb->getGrid(), maxdilate);
703+
vdb->getGrid(), maxdilate, nn);
683704
}
684705

685706
exint mindilate = SYSmin(dilatevoxels, dilatedist);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Houdini:
2+
* VDB Activate SOP now has an option for the expansion pattern to use
3+
for dilation.
4+
* The label for Voxels to Expand is now Expand Voxels to match Houdini.

0 commit comments

Comments
 (0)