Toast Engine
Loading...
Searching...
No Matches
voxel_node_utils.hpp
Go to the documentation of this file.
1
7
8#pragma once
9#include <cstdint>
10#include <memory>
11#include <optional>
12#include <string_view>
18
19namespace toast::_detail {
20
22enum : uint8_t {
23 k_message_outside = 40,
24 k_message_misaligned = 41,
25};
26
28template<typename T>
29[[nodiscard]]
30auto assetOfType(const assets::Handle<T>& handle, std::string_view type) -> const T* {
31 if (!handle.hasValue()) {
32 return nullptr;
33 }
34 const assets::Asset& asset = static_cast<const assets::HandleBase&>(handle).get();
35 return asset.type() == type ? static_cast<const T*>(&asset) : nullptr;
36}
37
39[[nodiscard]]
40inline auto instantiateModel(const assets::VoxelModel& model) -> std::unique_ptr<voxel::Volume> {
41 std::optional<voxel::Volume> instance = model.instantiate(voxel::proceduralBrickPool());
42 if (!instance.has_value()) {
43 return nullptr;
44 }
45 return std::make_unique<voxel::Volume>(std::move(*instance));
46}
47
48}
Maps URI schemes to filesystem roots and manages asset lifetime.
Public API for the asset management system.
Base class for all engine assets.
Definition core_types.hpp:45
Base class for type-erased asset handles.
Definition core_types.hpp:72
Type-safe smart pointer for assets.
Definition core_types.hpp:149
Definition voxel_model.hpp:43
Member-robber pattern used by the generated reflection code.
Definition defer.hpp:16
auto assetOfType(const assets::Handle< T > &handle, std::string_view type) -> const T *
Definition voxel_node_utils.hpp:30
auto instantiateModel(const assets::VoxelModel &model) -> std::unique_ptr< voxel::Volume >
Definition voxel_node_utils.hpp:40
Bricks for the grids ProceduralVoxel pieces draw into.