Toast Engine
Toggle main menu visibility
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>
13
#include <
toast/assets/asset_manager.hpp
>
14
#include <
toast/assets/assets.hpp
>
15
#include <
toast/voxel/assets/voxel_model.hpp
>
16
#include <
toast/voxel/procedural_pool.hpp
>
17
#include <
toast/voxel/voxel_volume.hpp
>
18
19
namespace
toast::_detail
{
20
22
enum : uint8_t {
23
k_message_outside = 40,
24
k_message_misaligned = 41,
25
};
26
28
template
<
typename
T>
29
[[nodiscard]]
30
auto
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]]
40
inline
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
}
asset_manager.hpp
Maps URI schemes to filesystem roots and manages asset lifetime.
assets.hpp
Public API for the asset management system.
assets::Asset
Base class for all engine assets.
Definition
core_types.hpp:45
assets::HandleBase
Base class for type-erased asset handles.
Definition
core_types.hpp:72
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
assets::VoxelModel
Definition
voxel_model.hpp:43
toast::_detail
Member-robber pattern used by the generated reflection code.
Definition
defer.hpp:16
toast::_detail::assetOfType
auto assetOfType(const assets::Handle< T > &handle, std::string_view type) -> const T *
Definition
voxel_node_utils.hpp:30
toast::_detail::instantiateModel
auto instantiateModel(const assets::VoxelModel &model) -> std::unique_ptr< voxel::Volume >
Definition
voxel_node_utils.hpp:40
procedural_pool.hpp
Bricks for the grids ProceduralVoxel pieces draw into.
voxel_model.hpp
voxel_volume.hpp
engine
src
toast
voxel
nodes
voxel_node_utils.hpp
Generated by
1.17.0