From 5b90ed6c06bf79f41d56666158f660513d8e1f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Barschkis?= Date: Sun, 10 Jan 2021 19:08:56 +0100 Subject: Fluid: Fix cache saving issue with OpenVDB IO Fixes issue where files would not be written when 'resumable' option was checked. --- extern/mantaflow/preprocessed/fileio/iovdb.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'extern') diff --git a/extern/mantaflow/preprocessed/fileio/iovdb.cpp b/extern/mantaflow/preprocessed/fileio/iovdb.cpp index 8aca19ade04..3641577beca 100644 --- a/extern/mantaflow/preprocessed/fileio/iovdb.cpp +++ b/extern/mantaflow/preprocessed/fileio/iovdb.cpp @@ -423,13 +423,14 @@ int writeObjectsVDB(const string &filename, if (GridBase *mantaGrid = dynamic_cast(*iter)) { - if (clipGrid) { - assertMsg(clipGrid->getSize() == mantaGrid->getSize(), - "writeObjectsVDB: Clip grid and exported grid must have the same size"); - } if (mantaGrid->getType() & GridBase::TypeInt) { debMsg("Writing int grid '" << mantaGrid->getName() << "' to vdb file " << filename, 1); Grid *mantaIntGrid = (Grid *)mantaGrid; + if (clipGrid && mantaIntGrid->saveSparse()) { + assertMsg(clipGrid->getSize() == mantaGrid->getSize(), + "writeObjectsVDB: Clip grid and exported grid must have the same size " + << clipGrid->getSize() << " vs " << mantaGrid->getSize()); + } vdbGrid = exportVDB(mantaIntGrid, clip, vdbClipGrid); gridsVDB.push_back(vdbGrid); } @@ -440,6 +441,11 @@ int writeObjectsVDB(const string &filename, Grid *mantaRealGrid = (Grid *)mantaGrid; // Only supply clip grid if real grid is not equal to the clip grid openvdb::FloatGrid::Ptr tmpClipGrid = (mantaRealGrid == clipGrid) ? nullptr : vdbClipGrid; + if (clipGrid && mantaRealGrid->saveSparse()) { + assertMsg(clipGrid->getSize() == mantaGrid->getSize(), + "writeObjectsVDB: Clip grid and exported grid must have the same size " + << clipGrid->getSize() << " vs " << mantaGrid->getSize()); + } vdbGrid = exportVDB(mantaRealGrid, clip, tmpClipGrid); gridsVDB.push_back(vdbGrid); } @@ -448,6 +454,11 @@ int writeObjectsVDB(const string &filename, gClass = (mantaGrid->getType() & GridBase::TypeMAC) ? openvdb::GRID_STAGGERED : openvdb::GRID_UNKNOWN; Grid *mantaVec3Grid = (Grid *)mantaGrid; + if (clipGrid && mantaVec3Grid->saveSparse()) { + assertMsg(clipGrid->getSize() == mantaGrid->getSize(), + "writeObjectsVDB: Clip grid and exported grid must have the same size " + << clipGrid->getSize() << " vs " << mantaGrid->getSize()); + } vdbGrid = exportVDB(mantaVec3Grid, clip, vdbClipGrid); gridsVDB.push_back(vdbGrid); } -- cgit v1.2.3