Skip to content

Engine → Renderer → mesh_asset.h

mesh_asset

Syntax

class CONJURE_API mesh_asset

Constructors

AccessSignatureDescription
publicmesh_asset();
publicmesh_asset( const mesh_asset &) = default;
publicmesh_asset( mesh_asset &&) noexcept = default;

Destructors

AccessSignatureDescription
public~mesh_asset();

Variables

AccessNameTypeDefaultDescription
privatemBoundsmath::aabb{}
privatemNamestd::string{}
privatemStreamsmesh_streams{}
privatemSubmeshesstd::vector<submesh>{}

Functions

Public

bounds

[[nodiscard]] const math::aabb &bounds() const noexcept;

cpu_geometry

[[nodiscard]] cpu_geometry_view cpu_geometry() const noexcept;

Positions and indices for the editor's CPU picking.

from_geometry

[[nodiscard]] static core::result<mesh_asset> from_geometry(
    const mesh_geometry &geometry,
    std::string name = {},
    tangent_generation missingTangents = tangent_generation::FROM_UVS);

Packs geometry into streams. Fails with INVALID_ARGUMENT for no positions, an attribute array whose size differs from the position count, an index count that is not a multiple of three, an index out of range, a non-finite position, or submesh counts that do not partition the index list. Missing attributes are generated as described above; missingTangents chooses how and is not read when the geometry has tangents.

gpu_byte_size

[[nodiscard]] u64 gpu_byte_size() const noexcept;

Bytes of stream 0, stream 1 and the index buffer together.

index_count

[[nodiscard]] u32 index_count() const noexcept;

name

[[nodiscard]] std::string_view name() const noexcept;

parse_blob

[[nodiscard]] static core::result<mesh_asset> parse_blob(
    std::span<const std::byte> bytes);

Parses a .cmesh blob. Fails with renderer_error::INVALID_ASSET naming the problem.

quad

[[nodiscard]] static mesh_asset quad(
    f32 halfSize = 0.5f);

A quad in the XY plane facing +Z with the given half size.

streams

[[nodiscard]] const mesh_streams &streams() const noexcept;

submeshes

[[nodiscard]] std::span<const submesh> submeshes() const noexcept;

triangle_count

[[nodiscard]] u32 triangle_count() const noexcept;

unit_cube

[[nodiscard]] static mesh_asset unit_cube();

A unit cube centred on the origin with flat normals: the fallback mesh.

uv_sphere

[[nodiscard]] static mesh_asset uv_sphere(
    f32 radius,
    u32 rings = 16,
    u32 segments = 32);

A UV sphere of the given radius.

vertex_count

[[nodiscard]] u32 vertex_count() const noexcept;

write_blob

[[nodiscard]] std::vector<std::byte> write_blob() const;

Serialises the mesh as a .cmesh blob (little-endian, deterministic).

Operator Overloads

Public

operator=

mesh_asset &operator=(
    const mesh_asset &) = default;
mesh_asset &operator=(
    mesh_asset &&) noexcept = default;

operator==

[[nodiscard]] bool operator==(
    const mesh_asset &other) const noexcept;