Fluid: Updated manta pp files
Includes the OpenVDB read/write functions for int grids. This essential for the resume bake functionality in modular fluid caches.
This commit is contained in:
parent
68221b7eba
commit
4a08eb0707
|
@ -954,6 +954,79 @@ template<class T> void readGridVDB(const string &name, Grid<T> *grid)
|
|||
1);
|
||||
}
|
||||
|
||||
template<> void writeGridVDB(const string &name, Grid<int> *grid)
|
||||
{
|
||||
debMsg("Writing int grid " << grid->getName() << " to vdb file " << name, 1);
|
||||
|
||||
// Create an empty int32-point grid with background value 0.
|
||||
openvdb::initialize();
|
||||
openvdb::Int32Grid::Ptr gridVDB = openvdb::Int32Grid::create();
|
||||
gridVDB->setTransform(
|
||||
openvdb::math::Transform::createLinearTransform(1. / grid->getSizeX())); // voxel size
|
||||
|
||||
// Get an accessor for coordinate-based access to voxels.
|
||||
openvdb::Int32Grid::Accessor accessor = gridVDB->getAccessor();
|
||||
|
||||
gridVDB->setGridClass(openvdb::GRID_UNKNOWN);
|
||||
|
||||
// Name the grid "density".
|
||||
gridVDB->setName(grid->getName());
|
||||
|
||||
openvdb::io::File file(name);
|
||||
|
||||
FOR_IJK(*grid)
|
||||
{
|
||||
openvdb::Coord xyz(i, j, k);
|
||||
accessor.setValue(xyz, (*grid)(i, j, k));
|
||||
}
|
||||
|
||||
// Add the grid pointer to a container.
|
||||
openvdb::GridPtrVec gridsVDB;
|
||||
gridsVDB.push_back(gridVDB);
|
||||
|
||||
// Write out the contents of the container.
|
||||
file.write(gridsVDB);
|
||||
file.close();
|
||||
}
|
||||
|
||||
template<> void readGridVDB(const string &name, Grid<int> *grid)
|
||||
{
|
||||
debMsg("Reading int grid " << grid->getName() << " from vdb file " << name, 1);
|
||||
|
||||
openvdb::initialize();
|
||||
openvdb::io::File file(name);
|
||||
file.open();
|
||||
|
||||
openvdb::GridBase::Ptr baseGrid;
|
||||
for (openvdb::io::File::NameIterator nameIter = file.beginName(); nameIter != file.endName();
|
||||
++nameIter) {
|
||||
# ifndef BLENDER
|
||||
// Read in only the grid we are interested in.
|
||||
if (nameIter.gridName() == grid->getName()) {
|
||||
baseGrid = file.readGrid(nameIter.gridName());
|
||||
}
|
||||
else {
|
||||
debMsg("skipping grid " << nameIter.gridName(), 1);
|
||||
}
|
||||
# else
|
||||
// For Blender, skip name check and pick first grid from loop
|
||||
baseGrid = file.readGrid(nameIter.gridName());
|
||||
break;
|
||||
# endif
|
||||
}
|
||||
file.close();
|
||||
openvdb::Int32Grid::Ptr gridVDB = openvdb::gridPtrCast<openvdb::Int32Grid>(baseGrid);
|
||||
|
||||
openvdb::Int32Grid::Accessor accessor = gridVDB->getAccessor();
|
||||
|
||||
FOR_IJK(*grid)
|
||||
{
|
||||
openvdb::Coord xyz(i, j, k);
|
||||
int v = accessor.getValue(xyz);
|
||||
(*grid)(i, j, k) = v;
|
||||
}
|
||||
}
|
||||
|
||||
template<> void writeGridVDB(const string &name, Grid<Real> *grid)
|
||||
{
|
||||
debMsg("Writing real grid " << grid->getName() << " to vdb file " << name, 1);
|
||||
|
|
|
@ -310,6 +310,8 @@ template<class T> void readPdataUni(const std::string &name, ParticleDataImpl<T>
|
|||
UniPartHeader head;
|
||||
assertMsg(gzread(gzf, &head, sizeof(UniPartHeader)) == sizeof(UniPartHeader),
|
||||
"can't read file, no header present");
|
||||
pdata->resize(head.dim);
|
||||
|
||||
assertMsg(head.dim == pdata->size(), "pdata size doesn't match");
|
||||
# if FLOATINGPOINT_PRECISION != 1
|
||||
ParticleDataImpl<T> temp(pdata->getParent());
|
||||
|
|
|
@ -136,9 +136,9 @@ FluidSolver::FluidSolver(Vec3i gridsize, int dim, int fourthDim)
|
|||
mDtMin(1.),
|
||||
mDtMax(1.),
|
||||
mFrameLength(1.),
|
||||
mTimePerFrame(0.),
|
||||
mGridSize(gridsize),
|
||||
mDim(dim),
|
||||
mTimePerFrame(0.),
|
||||
mLockDt(false),
|
||||
mFourthDim(fourthDim)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
|
||||
|
||||
#define MANTA_GIT_VERSION "commit 3f5c7989fd82920f0c509844a06e97dd1069191c"
|
||||
#define MANTA_GIT_VERSION "commit abfff159b5ea8cee93d858f4b8be2a308b58b51d"
|
||||
|
|
|
@ -1407,7 +1407,6 @@ struct correctLevelset : public KernelBase {
|
|||
{
|
||||
if (rAcc(i, j, k) <= VECTOR_EPSILON)
|
||||
return; // outside nothing happens
|
||||
Real x = pAcc(i, j, k).x;
|
||||
|
||||
// create jacobian of pAcc via central differences
|
||||
Matrix3x3f jacobian = Matrix3x3f(0.5 * (pAcc(i + 1, j, k).x - pAcc(i - 1, j, k).x),
|
||||
|
|
|
@ -381,7 +381,6 @@ void getSpiralVelocity(const FlagGrid &flags,
|
|||
nz = flags.getSizeZ();
|
||||
Real midX = 0.5 * (Real)(nx - 1);
|
||||
Real midY = 0.5 * (Real)(ny - 1);
|
||||
Real midZ = 0.5 * (Real)(nz - 1);
|
||||
for (int i = 0; i < nx; i++) {
|
||||
for (int j = 0; j < ny; j++) {
|
||||
for (int k = 0; k < nz; k++) {
|
||||
|
|
|
@ -1099,7 +1099,7 @@ void PbRegister_flipSampleSecondaryParticles()
|
|||
// evaluates cubic spline with radius h and distance l in dim dimensions
|
||||
Real cubicSpline(const Real h, const Real l, const int dim)
|
||||
{
|
||||
const Real h2 = square(h), h3 = h2 * h, h4 = h3 * h, h5 = h4 * h;
|
||||
const Real h2 = square(h), h3 = h2 * h;
|
||||
const Real c[] = {
|
||||
Real(2e0 / (3e0 * h)), Real(10e0 / (7e0 * M_PI * h2)), Real(1e0 / (M_PI * h3))};
|
||||
const Real q = l / h;
|
||||
|
@ -1175,9 +1175,6 @@ struct knFlipUpdateSecondaryParticlesLinear : public KernelBase {
|
|||
}
|
||||
|
||||
Vec3i gridpos = toVec3i(pts_sec[idx].pos);
|
||||
int i = gridpos.x;
|
||||
int j = gridpos.y;
|
||||
int k = gridpos.z;
|
||||
|
||||
// spray particle
|
||||
if (neighborRatio(gridpos) < c_s) {
|
||||
|
|
Loading…
Reference in New Issue