Skip to content

Commit

Permalink
Merge pull request #1655 from sideeffects/sendupstream_sync_h20
Browse files Browse the repository at this point in the history
Synchronize the GEO reference implementations with upcoming H20.
  • Loading branch information
jmlait committed Sep 11, 2023
2 parents a46f498 + 2155e86 commit 2d7ba1c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 9 deletions.
72 changes: 64 additions & 8 deletions openvdb_houdini/openvdb_houdini/GEO_PrimVDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1410,17 +1410,44 @@ GEO_PrimVDB::isActiveRegionMatched(const GEO_PrimVDB *vdb) const
CE_VDBGrid *
GEO_PrimVDB::getCEGrid(bool read, bool write) const
{
UT_ASSERT(!write);
UT_ASSERT(read);

// No read means there is no topo either, so likely
// for someone who only wants tilestarts.
if (myCEGrid)
{
if (read)
{
if (!myCEGrid->hasBuffer())
{
// Attempt to load...
try
{
myCEGrid->initFromVDB(getGrid());
}
catch (cl::Error &err)
{
CE_Context::reportError(err);
return nullptr;
}
}
}
if (write)
{
if (!myCEGridIsOwned)
{
UT_ASSERT(!"Not implemented");
}
// Re-flag to write back.
myCEGridAuthorative = true;
}
return myCEGrid;
}

CE_VDBGrid *cegrid = new CE_VDBGrid();

try
{
cegrid->initFromVDB(getGrid());
if (read)
cegrid->initFromVDB(getGrid());
myCEGridIsOwned = true;
}
catch (cl::Error &err)
Expand All @@ -1444,7 +1471,17 @@ GEO_PrimVDB::flushCEWriteCaches()
if (myCEGridAuthorative)
{
// Write back.
UT_ASSERT(!"Not implemented");
try
{
openvdb::GridBase::Ptr gpugrid = myCEGrid->createVDB();
if (gpugrid)
setGrid(*gpugrid);
getParent()->getPrimitiveList().bumpDataId();
}
catch (cl::Error &err)
{
CE_Context::reportError(err);
}
myCEGridAuthorative = false;
}
}
Expand Down Expand Up @@ -1956,6 +1993,16 @@ GEO_PrimVDB::setTransform4(const UT_DMatrix4 &xform4)
myGridAccessor.setTransform(*geoCreateLinearTransform(xform4), *this);
}

void
GEO_PrimVDB::getRes(int64 &rx, int64 &ry, int64 &rz) const
{
int x, y, z;
getRes(x, y, z);
rx = x;
ry = y;
rz = z;
}

void
GEO_PrimVDB::getRes(int &rx, int &ry, int &rz) const
{
Expand Down Expand Up @@ -3453,7 +3500,7 @@ GEO_PrimVDB::GridAccessor::setTransformAdapter(

void
GEO_PrimVDB::GridAccessor::setGridAdapter(
const void* gridPtr,
const void* gridPtr,
GEO_PrimVDB &prim,
bool copyPosition)
{
Expand Down Expand Up @@ -3534,7 +3581,7 @@ GEO_PrimVDB::getGridName() const
{
GA_ROHandleS nameAttr(getParent(), GA_ATTRIB_PRIMITIVE, "name");
return nameAttr.isValid()
? static_cast<const char *>(nameAttr.get(getMapOffset())) : "";
? static_cast<const char *>(nameAttr.get(getMapOffset())) : "";
}


Expand All @@ -3550,6 +3597,7 @@ namespace // anonymous
geo_INTRINSIC_ACTIVEVOXELDIM,
geo_INTRINSIC_ACTIVEVOXELCOUNT,
geo_INTRINSIC_TRANSFORM,
geo_INTRINSIC_TAPER,
geo_INTRINSIC_VOLUMEVISUALMODE,
geo_INTRINSIC_VOLUMEVISUALDENSITY,
geo_INTRINSIC_VOLUMEVISUALISO,
Expand Down Expand Up @@ -3671,6 +3719,12 @@ namespace // anonymous
q->setTransform4(m);
return 16;
}
static fpreal
intrinsicTaper(const GEO_PrimVDB *prim)
{
return prim->getTaper();
}

const char *
intrinsicVisualMode(const GEO_PrimVDB *p)
{
Expand Down Expand Up @@ -3770,7 +3824,7 @@ GEO_PrimVDB::backgroundV3() const
{ \
UT_String str; \
intrinsicGetMetaString(o, ID, str); \
v.append(str); \
v.append(str); \
return 1; \
} \
static geo_Size setSS(CLASS *o, const char **v, GA_Size) \
Expand Down Expand Up @@ -3814,6 +3868,8 @@ GA_START_INTRINSIC_DEF(GEO_PrimVDB, geo_NUM_INTRINSICS)
"transform", 16, intrinsicTransform);
GA_INTRINSIC_SET_TUPLE_F(GEO_PrimVDB, geo_INTRINSIC_TRANSFORM,
intrinsicSetTransform);
GA_INTRINSIC_F(GEO_PrimVDB, geo_INTRINSIC_TAPER,
"taper", intrinsicTaper)

GA_INTRINSIC_S(GEO_PrimVDB, geo_INTRINSIC_VOLUMEVISUALMODE,
"volumevisualmode", intrinsicVisualMode)
Expand Down
1 change: 1 addition & 0 deletions openvdb_houdini/openvdb_houdini/GEO_PrimVDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class OPENVDB_HOUDINI_API GEO_PrimVDB : public GEO_Primitive
/// Returns the resolution of the active voxel array.
/// Does *not* mean the indices go from 0..rx, however!
void getRes(int &rx, int &ry, int &rz) const;
void getRes(int64 &rx, int64 &ry, int64 &rz) const;

/// Computes the voxel diameter by taking a step in x, y, and z
/// converting to world space and taking the length of that vector.
Expand Down
6 changes: 6 additions & 0 deletions openvdb_houdini/openvdb_houdini/GU_PrimVDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,12 @@ GU_PrimVDB::normal(NormalComp& /*output*/) const
// No need here.
}

void
GU_PrimVDB::normal(NormalCompD& /*output*/) const
{
// No need here.
}


////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ an inclusive range, so includes the maximum voxel.)"));
*/
parms.add(hutil::ParmFactory(PRM_INT, "expand", "Expand Voxels")
.setDefault(PRMoneDefaults)
.setRange(PRM_RANGE_FREE, -5, PRM_RANGE_FREE, 5)
.setRange(PRM_RANGE_UI, -5, PRM_RANGE_UI, 5)
.setTooltip("Expand the active area by at least the specified number of voxels.")
.setDocumentation(
R"(Expand the active area by at least the specified number of voxels. Does not support
Expand Down

0 comments on commit 2d7ba1c

Please sign in to comment.