Skip to content

Commit a5e6bd9

Browse files
committed
Synchronize the GEO reference implementations with upcoming H20.
Change to PRM_UI rather than PRM_FREE to match H20 version of parms in activate. Signed-off-by: Jeff Lait <jlait@andorra.sidefx.com>
1 parent 3f8b6f3 commit a5e6bd9

File tree

4 files changed

+69
-6
lines changed

4 files changed

+69
-6
lines changed

openvdb_houdini/openvdb_houdini/GEO_PrimVDB.cc

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,17 +1410,44 @@ GEO_PrimVDB::isActiveRegionMatched(const GEO_PrimVDB *vdb) const
14101410
CE_VDBGrid *
14111411
GEO_PrimVDB::getCEGrid(bool read, bool write) const
14121412
{
1413-
UT_ASSERT(!write);
1414-
UT_ASSERT(read);
1415-
1413+
// No read means there is no topo either, so likely
1414+
// for someone who only wants tilestarts.
14161415
if (myCEGrid)
1416+
{
1417+
if (read)
1418+
{
1419+
if (!myCEGrid->hasBuffer())
1420+
{
1421+
// Attempt to load...
1422+
try
1423+
{
1424+
myCEGrid->initFromVDB(getGrid());
1425+
}
1426+
catch (cl::Error &err)
1427+
{
1428+
CE_Context::reportError(err);
1429+
return nullptr;
1430+
}
1431+
}
1432+
}
1433+
if (write)
1434+
{
1435+
if (!myCEGridIsOwned)
1436+
{
1437+
UT_ASSERT(!"Not implemented");
1438+
}
1439+
// Re-flag to write back.
1440+
myCEGridAuthorative = true;
1441+
}
14171442
return myCEGrid;
1443+
}
14181444

14191445
CE_VDBGrid *cegrid = new CE_VDBGrid();
14201446

14211447
try
14221448
{
1423-
cegrid->initFromVDB(getGrid());
1449+
if (read)
1450+
cegrid->initFromVDB(getGrid());
14241451
myCEGridIsOwned = true;
14251452
}
14261453
catch (cl::Error &err)
@@ -1444,7 +1471,17 @@ GEO_PrimVDB::flushCEWriteCaches()
14441471
if (myCEGridAuthorative)
14451472
{
14461473
// Write back.
1447-
UT_ASSERT(!"Not implemented");
1474+
try
1475+
{
1476+
openvdb::GridBase::Ptr gpugrid = myCEGrid->createVDB();
1477+
if (gpugrid)
1478+
setGrid(*gpugrid);
1479+
getParent()->getPrimitiveList().bumpDataId();
1480+
}
1481+
catch (cl::Error &err)
1482+
{
1483+
CE_Context::reportError(err);
1484+
}
14481485
myCEGridAuthorative = false;
14491486
}
14501487
}
@@ -1956,6 +1993,16 @@ GEO_PrimVDB::setTransform4(const UT_DMatrix4 &xform4)
19561993
myGridAccessor.setTransform(*geoCreateLinearTransform(xform4), *this);
19571994
}
19581995

1996+
void
1997+
GEO_PrimVDB::getRes(int64 &rx, int64 &ry, int64 &rz) const
1998+
{
1999+
int x, y, z;
2000+
getRes(x, y, z);
2001+
rx = x;
2002+
ry = y;
2003+
rz = z;
2004+
}
2005+
19592006
void
19602007
GEO_PrimVDB::getRes(int &rx, int &ry, int &rz) const
19612008
{
@@ -3550,6 +3597,7 @@ namespace // anonymous
35503597
geo_INTRINSIC_ACTIVEVOXELDIM,
35513598
geo_INTRINSIC_ACTIVEVOXELCOUNT,
35523599
geo_INTRINSIC_TRANSFORM,
3600+
geo_INTRINSIC_TAPER,
35533601
geo_INTRINSIC_VOLUMEVISUALMODE,
35543602
geo_INTRINSIC_VOLUMEVISUALDENSITY,
35553603
geo_INTRINSIC_VOLUMEVISUALISO,
@@ -3671,6 +3719,12 @@ namespace // anonymous
36713719
q->setTransform4(m);
36723720
return 16;
36733721
}
3722+
static fpreal
3723+
intrinsicTaper(const GEO_PrimVDB *prim)
3724+
{
3725+
return prim->getTaper();
3726+
}
3727+
36743728
const char *
36753729
intrinsicVisualMode(const GEO_PrimVDB *p)
36763730
{
@@ -3814,6 +3868,8 @@ GA_START_INTRINSIC_DEF(GEO_PrimVDB, geo_NUM_INTRINSICS)
38143868
"transform", 16, intrinsicTransform);
38153869
GA_INTRINSIC_SET_TUPLE_F(GEO_PrimVDB, geo_INTRINSIC_TRANSFORM,
38163870
intrinsicSetTransform);
3871+
GA_INTRINSIC_F(GEO_PrimVDB, geo_INTRINSIC_TAPER,
3872+
"taper", intrinsicTaper)
38173873

38183874
GA_INTRINSIC_S(GEO_PrimVDB, geo_INTRINSIC_VOLUMEVISUALMODE,
38193875
"volumevisualmode", intrinsicVisualMode)

openvdb_houdini/openvdb_houdini/GEO_PrimVDB.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ class OPENVDB_HOUDINI_API GEO_PrimVDB : public GEO_Primitive
291291
/// Returns the resolution of the active voxel array.
292292
/// Does *not* mean the indices go from 0..rx, however!
293293
void getRes(int &rx, int &ry, int &rz) const;
294+
void getRes(int64 &rx, int64 &ry, int64 &rz) const;
294295

295296
/// Computes the voxel diameter by taking a step in x, y, and z
296297
/// converting to world space and taking the length of that vector.

openvdb_houdini/openvdb_houdini/GU_PrimVDB.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,12 @@ GU_PrimVDB::normal(NormalComp& /*output*/) const
18131813
// No need here.
18141814
}
18151815

1816+
void
1817+
GU_PrimVDB::normal(NormalCompD& /*output*/) const
1818+
{
1819+
// No need here.
1820+
}
1821+
18161822

18171823
////////////////////////////////////////
18181824

openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ an inclusive range, so includes the maximum voxel.)"));
219219
*/
220220
parms.add(hutil::ParmFactory(PRM_INT, "expand", "Expand Voxels")
221221
.setDefault(PRMoneDefaults)
222-
.setRange(PRM_RANGE_FREE, -5, PRM_RANGE_FREE, 5)
222+
.setRange(PRM_RANGE_UI, -5, PRM_RANGE_UI, 5)
223223
.setTooltip("Expand the active area by at least the specified number of voxels.")
224224
.setDocumentation(
225225
R"(Expand the active area by at least the specified number of voxels. Does not support

0 commit comments

Comments
 (0)