-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// nanovdb | ||
#include <nanovdb/util/IO.h> | ||
// ours | ||
#include "NanoVDBField.h" | ||
|
||
namespace visionaray { | ||
|
||
NanoVDBField::NanoVDBField(VisionarayGlobalState *d) | ||
: SpatialField(d) | ||
{ | ||
vfield.type = dco::SpatialField::NanoVDB; | ||
} | ||
|
||
void NanoVDBField::commit() | ||
{ | ||
m_gridData = getParamObject<helium::Array1D>("gridData"); | ||
|
||
if (!m_gridData) { | ||
reportMessage(ANARI_SEVERITY_WARNING, | ||
"missing required parameter 'gridHandle' on nanovdb spatial field"); | ||
|
||
return; | ||
} | ||
|
||
auto buffer = nanovdb::HostBuffer::createFull(m_gridData->totalSize(), | ||
(void *)m_gridData->data()); | ||
m_gridHandle = std::move(buffer); | ||
|
||
vfield.asNanoVDB.grid = m_gridHandle.grid<float>(); | ||
|
||
vfield.voxelSpaceTransform = mat4x3(mat3::identity(),float3{0.f,0.f,0.f}); | ||
|
||
dispatch(); | ||
} | ||
|
||
bool NanoVDBField::isValid() const | ||
{ | ||
return (bool)m_gridHandle; | ||
} | ||
|
||
aabb NanoVDBField::bounds() const | ||
{ | ||
if (!isValid()) | ||
return {}; | ||
|
||
auto bbox = m_gridHandle.gridMetaData()->indexBBox(); | ||
auto lower = bbox.min(); | ||
auto upper = bbox.max(); | ||
return aabb{{lower[0], lower[1], lower[2]}, | ||
{upper[0], upper[1], upper[2]}}; | ||
} | ||
|
||
} // namespace visionaray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
#pragma once | ||
|
||
// nanovdb | ||
#include <nanovdb/NanoVDB.h> | ||
#include <nanovdb/GridHandle.h> | ||
#include <nanovdb/HostBuffer.h> | ||
#ifdef WITH_CUDA | ||
#include <nanovdb/util/cuda/CudaDeviceBuffer.h> | ||
#endif | ||
// ours | ||
#include "SpatialField.h" | ||
#include "array/Array1D.h" | ||
|
||
namespace visionaray { | ||
|
||
struct NanoVDBField : public SpatialField | ||
{ | ||
NanoVDBField(VisionarayGlobalState *d); | ||
|
||
void commit() override; | ||
|
||
bool isValid() const override; | ||
|
||
aabb bounds() const override; | ||
private: | ||
|
||
helium::IntrusivePtr<Array1D> m_gridData; | ||
|
||
nanovdb::GridHandle<nanovdb::HostBuffer> m_gridHandle; | ||
}; | ||
|
||
} // namespace visionaray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters