Mesh¶
-
template<IsSpectral TSpectral>
class Mesh : public huira::SceneObject<Mesh<TSpectral>>¶ Represents a 3D triangle mesh with vertex and index data.
Mesh stores geometry data as indexed triangles, with each triangle defined by three indices into a vertex buffer. The vertex buffer contains positions, normals, and spectral properties. Meshes are movable but not copyable.
Each Mesh owns an Embree BLAS (bottom-level acceleration structure) built over its triangle data. The BLAS is constructed lazily on first access via blas(), using shared buffers (zero-copy). The RTCDevice must be assigned (via set_device()) before the BLAS can be built — this is handled automatically by Scene::add_mesh().
- Template Parameters:
TSpectral – The spectral representation type.
Public Functions
-
inline Mesh()¶
-
Mesh(IndexBuffer index_buffer, VertexBuffer<TSpectral> vertex_buffer)¶
Constructs a Mesh from index and vertex buffers.
Creates a new mesh by taking ownership of the provided buffers. The index buffer should contain triangle indices (groups of three) that reference vertices in the vertex buffer. The Embree BLAS is not built here — it is constructed lazily on first call to blas() after a device has been assigned.
- Parameters:
index_buffer – Buffer containing triangle vertex indices.
vertex_buffer – Buffer containing vertex data (positions, normals, etc.).
-
Mesh(IndexBuffer index_buffer, VertexBuffer<TSpectral> vertex_buffer, TangentBuffer tangent_buffer)¶
-
~Mesh() override¶
-
inline void set_device(RTCDevice device) noexcept¶
-
std::size_t index_count() const noexcept¶
-
std::size_t vertex_count() const noexcept¶
-
std::size_t triangle_count() const noexcept¶
-
const IndexBuffer &index_buffer() const noexcept¶
-
const VertexBuffer<TSpectral> &vertex_buffer() const noexcept¶
-
const TangentBuffer &tangent_buffer() const noexcept¶
-
inline bool has_tangents() const noexcept¶
-
RTCScene blas() const¶
Returns the Embree BLAS scene for this mesh, building it if necessary.
On first call, constructs the BLAS using shared buffers (zero-copy) over the mesh’s vertex and index data. Subsequent calls return the cached BLAS. Requires that set_device() has been called (typically by Scene::add_mesh()).
- Returns:
The committed RTCScene containing the triangle geometry.
-
inline virtual std::uint64_t id() const override¶
Get the object’s unique ID.
- Returns:
std::uint64_t ID
-
inline virtual std::string type() const override¶
Get the object’s type string.
- Returns:
std::string Type
-
inline bool is_scene_owned() const¶
Check if the object is owned by the scene.
- Returns:
bool True if owned
-
inline void set_scene_owned(bool owned)¶
Set scene ownership flag.
- Parameters:
owned – True if owned
-
inline std::string name() const¶
Get the object’s name.
- Returns:
std::string Name
-
inline virtual std::string get_info() const¶
Get a descriptive info string for the object.
- Returns:
std::string Info string