2026-04-08 19:45:53 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <XCEngine/Core/Asset/IResource.h>
|
|
|
|
|
#include <XCEngine/Core/Containers/Array.h>
|
|
|
|
|
#include <XCEngine/Core/Math/Bounds.h>
|
|
|
|
|
#include <XCEngine/Core/Math/Vector3.h>
|
|
|
|
|
#include <XCEngine/Core/Types.h>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Resources {
|
|
|
|
|
|
|
|
|
|
enum class VolumeStorageKind : Core::uint32 {
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
NanoVDB = 1
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-09 01:11:59 +08:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-08 19:45:53 +08:00
|
|
|
class VolumeField : public IResource {
|
|
|
|
|
public:
|
|
|
|
|
VolumeField();
|
|
|
|
|
virtual ~VolumeField() override;
|
|
|
|
|
|
|
|
|
|
ResourceType GetType() const override { return ResourceType::VolumeField; }
|
|
|
|
|
const Containers::String& GetName() const override { return m_name; }
|
|
|
|
|
const Containers::String& GetPath() const override { return m_path; }
|
|
|
|
|
ResourceGUID GetGUID() const override { return m_guid; }
|
|
|
|
|
bool IsValid() const override { return m_isValid; }
|
|
|
|
|
size_t GetMemorySize() const override { return m_memorySize; }
|
|
|
|
|
void Release() override;
|
|
|
|
|
|
|
|
|
|
bool Create(VolumeStorageKind storageKind,
|
|
|
|
|
const void* payload,
|
|
|
|
|
size_t payloadSize,
|
|
|
|
|
const Math::Bounds& bounds = Math::Bounds(),
|
2026-04-09 01:11:59 +08:00
|
|
|
const Math::Vector3& voxelSize = Math::Vector3::Zero(),
|
|
|
|
|
const VolumeIndexBounds& indexBounds = VolumeIndexBounds(),
|
|
|
|
|
Core::uint32 gridType = 0u,
|
|
|
|
|
Core::uint32 gridClass = 0u);
|
2026-04-08 19:45:53 +08:00
|
|
|
|
|
|
|
|
VolumeStorageKind GetStorageKind() const { return m_storageKind; }
|
|
|
|
|
const Math::Bounds& GetBounds() const { return m_bounds; }
|
2026-04-09 01:11:59 +08:00
|
|
|
const Math::Bounds& GetWorldBounds() const { return m_bounds; }
|
2026-04-08 19:45:53 +08:00
|
|
|
const Math::Vector3& GetVoxelSize() const { return m_voxelSize; }
|
2026-04-09 01:11:59 +08:00
|
|
|
const VolumeIndexBounds& GetIndexBounds() const { return m_indexBounds; }
|
|
|
|
|
Core::uint32 GetGridType() const { return m_gridType; }
|
|
|
|
|
Core::uint32 GetGridClass() const { return m_gridClass; }
|
2026-04-08 19:45:53 +08:00
|
|
|
const void* GetPayloadData() const { return m_payload.Data(); }
|
|
|
|
|
size_t GetPayloadSize() const { return m_payload.Size(); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void UpdateMemorySize();
|
|
|
|
|
|
|
|
|
|
VolumeStorageKind m_storageKind = VolumeStorageKind::Unknown;
|
|
|
|
|
Math::Bounds m_bounds;
|
|
|
|
|
Math::Vector3 m_voxelSize = Math::Vector3::Zero();
|
2026-04-09 01:11:59 +08:00
|
|
|
VolumeIndexBounds m_indexBounds = {};
|
|
|
|
|
Core::uint32 m_gridType = 0u;
|
|
|
|
|
Core::uint32 m_gridClass = 0u;
|
2026-04-08 19:45:53 +08:00
|
|
|
Containers::Array<Core::uint8> m_payload;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Resources
|
|
|
|
|
} // namespace XCEngine
|