Fix NanoVDB volume loading and rendering
This commit is contained in:
@@ -15,7 +15,7 @@ constexpr Core::uint32 kMaterialArtifactSchemaVersion = 6;
|
||||
constexpr Core::uint32 kMeshArtifactSchemaVersion = 2;
|
||||
constexpr Core::uint32 kShaderArtifactSchemaVersion = 5;
|
||||
constexpr Core::uint32 kUIDocumentArtifactSchemaVersion = 2;
|
||||
constexpr Core::uint32 kVolumeFieldArtifactSchemaVersion = 1;
|
||||
constexpr Core::uint32 kVolumeFieldArtifactSchemaVersion = 2;
|
||||
|
||||
struct TextureArtifactHeader {
|
||||
char magic[8] = { 'X', 'C', 'T', 'E', 'X', '0', '1', '\0' };
|
||||
@@ -131,15 +131,17 @@ struct UIDocumentArtifactDiagnosticHeader {
|
||||
};
|
||||
|
||||
struct VolumeFieldArtifactHeader {
|
||||
char magic[8] = { 'X', 'C', 'V', 'O', 'L', '0', '1', '\0' };
|
||||
char magic[8] = { 'X', 'C', 'V', 'O', 'L', '0', '2', '\0' };
|
||||
Core::uint32 schemaVersion = kVolumeFieldArtifactSchemaVersion;
|
||||
Core::uint32 storageKind = 0;
|
||||
Math::Vector3 boundsMin = Math::Vector3::Zero();
|
||||
Math::Vector3 boundsMax = Math::Vector3::Zero();
|
||||
Math::Vector3 voxelSize = Math::Vector3::Zero();
|
||||
Core::int32 indexBoundsMin[3] = { 0, 0, 0 };
|
||||
Core::int32 indexBoundsMax[3] = { 0, 0, 0 };
|
||||
Core::uint32 gridType = 0;
|
||||
Core::uint32 gridClass = 0;
|
||||
Core::uint64 payloadSize = 0;
|
||||
Core::uint32 reserved0 = 0;
|
||||
Core::uint32 reserved1 = 0;
|
||||
};
|
||||
|
||||
} // namespace Resources
|
||||
|
||||
@@ -14,6 +14,28 @@ enum class VolumeStorageKind : Core::uint32 {
|
||||
NanoVDB = 1
|
||||
};
|
||||
|
||||
struct VolumeIndexBounds {
|
||||
Core::int32 minX = 0;
|
||||
Core::int32 minY = 0;
|
||||
Core::int32 minZ = 0;
|
||||
Core::int32 maxX = 0;
|
||||
Core::int32 maxY = 0;
|
||||
Core::int32 maxZ = 0;
|
||||
|
||||
bool operator==(const VolumeIndexBounds& other) const {
|
||||
return minX == other.minX &&
|
||||
minY == other.minY &&
|
||||
minZ == other.minZ &&
|
||||
maxX == other.maxX &&
|
||||
maxY == other.maxY &&
|
||||
maxZ == other.maxZ;
|
||||
}
|
||||
|
||||
bool operator!=(const VolumeIndexBounds& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
class VolumeField : public IResource {
|
||||
public:
|
||||
VolumeField();
|
||||
@@ -31,11 +53,18 @@ public:
|
||||
const void* payload,
|
||||
size_t payloadSize,
|
||||
const Math::Bounds& bounds = Math::Bounds(),
|
||||
const Math::Vector3& voxelSize = Math::Vector3::Zero());
|
||||
const Math::Vector3& voxelSize = Math::Vector3::Zero(),
|
||||
const VolumeIndexBounds& indexBounds = VolumeIndexBounds(),
|
||||
Core::uint32 gridType = 0u,
|
||||
Core::uint32 gridClass = 0u);
|
||||
|
||||
VolumeStorageKind GetStorageKind() const { return m_storageKind; }
|
||||
const Math::Bounds& GetBounds() const { return m_bounds; }
|
||||
const Math::Bounds& GetWorldBounds() const { return m_bounds; }
|
||||
const Math::Vector3& GetVoxelSize() const { return m_voxelSize; }
|
||||
const VolumeIndexBounds& GetIndexBounds() const { return m_indexBounds; }
|
||||
Core::uint32 GetGridType() const { return m_gridType; }
|
||||
Core::uint32 GetGridClass() const { return m_gridClass; }
|
||||
const void* GetPayloadData() const { return m_payload.Data(); }
|
||||
size_t GetPayloadSize() const { return m_payload.Size(); }
|
||||
|
||||
@@ -45,6 +74,9 @@ private:
|
||||
VolumeStorageKind m_storageKind = VolumeStorageKind::Unknown;
|
||||
Math::Bounds m_bounds;
|
||||
Math::Vector3 m_voxelSize = Math::Vector3::Zero();
|
||||
VolumeIndexBounds m_indexBounds = {};
|
||||
Core::uint32 m_gridType = 0u;
|
||||
Core::uint32 m_gridClass = 0u;
|
||||
Containers::Array<Core::uint8> m_payload;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user