提交 e33843b4 编写于 作者: M Matt Pharr

NanoVDBMediumProvider: don't assume density grid bounds == temperature grid bounds

上级 b77e0760
......@@ -364,24 +364,18 @@ NanoVDBMediumProvider *NanoVDBMediumProvider::Create(
ErrorExit(loc, "Must supply \"filename\" to \"nanovdb\" medium.");
nanovdb::GridHandle<NanoVDBBuffer> densityGrid;
nanovdb::BBox<nanovdb::Vec3R> bbox;
densityGrid = readGrid<NanoVDBBuffer>(filename, "density", loc, alloc);
if (!densityGrid)
ErrorExit(loc, "%s: didn't find \"density\" grid.", filename);
bbox = densityGrid.grid<float>()->worldBBox();
nanovdb::GridHandle<NanoVDBBuffer> temperatureGrid;
temperatureGrid = readGrid<NanoVDBBuffer>(filename, "temperature", loc, alloc);
Bounds3f bounds(Point3f(bbox.min()[0], bbox.min()[1], bbox.min()[2]),
Point3f(bbox.max()[0], bbox.max()[1], bbox.max()[2]));
Float LeScale = parameters.GetOneFloat("LeScale", 1.f);
Float temperatureCutoff = parameters.GetOneFloat("temperaturecutoff", 0.f);
Float temperatureScale = parameters.GetOneFloat("temperaturescale", 1.f);
return alloc.new_object<NanoVDBMediumProvider>(bounds, std::move(densityGrid),
return alloc.new_object<NanoVDBMediumProvider>(std::move(densityGrid),
std::move(temperatureGrid), LeScale,
temperatureCutoff, temperatureScale);
}
......
......@@ -596,21 +596,30 @@ class NanoVDBMediumProvider {
bounds, LeScale, temperatureCutoff, temperatureScale);
}
NanoVDBMediumProvider(const Bounds3f &bounds, nanovdb::GridHandle<NanoVDBBuffer> dg,
NanoVDBMediumProvider(nanovdb::GridHandle<NanoVDBBuffer> dg,
nanovdb::GridHandle<NanoVDBBuffer> tg, Float LeScale,
Float temperatureCutoff, Float temperatureScale)
: bounds(bounds),
densityGrid(std::move(dg)),
: densityGrid(std::move(dg)),
temperatureGrid(std::move(tg)),
LeScale(LeScale),
temperatureCutoff(temperatureCutoff),
temperatureScale(temperatureScale) {
densityFloatGrid = densityGrid.grid<float>();
nanovdb::BBox<nanovdb::Vec3R> bbox = densityFloatGrid->worldBBox();
bounds = Bounds3f(Point3f(bbox.min()[0], bbox.min()[1], bbox.min()[2]),
Point3f(bbox.max()[0], bbox.max()[1], bbox.max()[2]));
if (temperatureGrid) {
temperatureFloatGrid = temperatureGrid.grid<float>();
float minTemperature, maxTemperature;
temperatureFloatGrid->tree().extrema(minTemperature, maxTemperature);
LOG_VERBOSE("Max temperature: %f", maxTemperature);
nanovdb::BBox<nanovdb::Vec3R> bbox = temperatureFloatGrid->worldBBox();
bounds = Union(bounds,
Bounds3f(Point3f(bbox.min()[0], bbox.min()[1], bbox.min()[2]),
Point3f(bbox.max()[0], bbox.max()[1], bbox.max()[2])));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册