Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
ray_march.hpp
Go to the documentation of this file.
1
6
7
#pragma once
8
#include "
gpu_layout.hpp
"
9
10
#include <cstdint>
11
#include <glm/glm.hpp>
12
#include <
toast/export.hpp
>
13
14
namespace
voxel {
15
16
inline
constexpr
uint32_t k_max_march_steps = 1024;
17
19
inline
constexpr
float
k_march_tie_epsilon
= 1e-6f;
20
21
struct
RayHit
{
22
bool
hit =
false
;
23
25
float
t
= 0.0f;
26
27
glm::ivec3 voxel {0};
28
30
int32_t
axis
= -1;
31
32
uint8_t material = k_empty_palette_index;
33
34
uint32_t steps = 0;
35
37
uint32_t
coarse_steps
= 0;
38
uint32_t brick_steps = 0;
39
uint32_t sub_steps = 0;
40
};
41
44
[[nodiscard]]
45
TOAST_API
auto
marchRay(
46
const
gpu::PackedPool
& pool,
const
gpu::PackedScene
& scene, uint32_t volume, glm::vec3 origin, glm::vec3 direction,
47
float
t_min,
float
t_max, uint32_t max_steps = k_max_march_steps
48
) ->
RayHit
;
49
50
}
export.hpp
gpu_layout.hpp
voxel::k_march_tie_epsilon
constexpr float k_march_tie_epsilon
Relative to t.
Definition
ray_march.hpp:19
voxel::RayHit
Definition
ray_march.hpp:21
voxel::RayHit::t
float t
t_min when the ray started inside a voxel
Definition
ray_march.hpp:25
voxel::RayHit::axis
int32_t axis
-1 when the ray started inside a solid voxel
Definition
ray_march.hpp:30
voxel::RayHit::coarse_steps
uint32_t coarse_steps
Steps that skipped a whole coarse cell brick or 4x4x4 or 2x2x2 sub-brick so the rest are single voxel...
Definition
ray_march.hpp:37
voxel::gpu::PackedPool
Definition
gpu_layout.hpp:62
voxel::gpu::PackedScene
Definition
gpu_layout.hpp:76
engine
src
toast
voxel
ray_march.hpp
Generated by
1.17.0