@@ -1410,17 +1410,44 @@ GEO_PrimVDB::isActiveRegionMatched(const GEO_PrimVDB *vdb) const
14101410CE_VDBGrid *
14111411GEO_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+
19592006void
19602007GEO_PrimVDB::getRes (int &rx, int &ry, int &rz) const
19612008{
@@ -3453,7 +3500,7 @@ GEO_PrimVDB::GridAccessor::setTransformAdapter(
34533500
34543501void
34553502GEO_PrimVDB::GridAccessor::setGridAdapter (
3456- const void * gridPtr,
3503+ const void * gridPtr,
34573504 GEO_PrimVDB &prim,
34583505 bool copyPosition)
34593506{
@@ -3534,7 +3581,7 @@ GEO_PrimVDB::getGridName() const
35343581{
35353582 GA_ROHandleS nameAttr (getParent (), GA_ATTRIB_PRIMITIVE, " name" );
35363583 return nameAttr.isValid ()
3537- ? static_cast <const char *>(nameAttr.get (getMapOffset ())) : " " ;
3584+ ? static_cast <const char *>(nameAttr.get (getMapOffset ())) : " " ;
35383585}
35393586
35403587
@@ -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 {
@@ -3770,7 +3824,7 @@ GEO_PrimVDB::backgroundV3() const
37703824 { \
37713825 UT_String str; \
37723826 intrinsicGetMetaString (o, ID, str); \
3773- v.append (str); \
3827+ v.append (str); \
37743828 return 1 ; \
37753829 } \
37763830 static geo_Size setSS (CLASS *o, const char **v, GA_Size) \
@@ -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)
0 commit comments