53 if (max.x <= min.x || max.y <= min.y || max.z <= min.z)
return false;
58 probes_.push_back({min, max, slot});
62 bool empty()
const {
return probes_.empty(); }
63 u32 count()
const {
return static_cast<u32>(probes_.size()); }
72 mix(&environment_,
sizeof(environment_));
73 for (
const Probe& p : probes_) {
74 mix(&p.min,
sizeof(p.min));
75 mix(&p.max,
sizeof(p.max));
76 mix(&p.slot,
sizeof(p.slot));
78 if (revision_ == 0 || h != revision_hash_) {
97 const Probe* best =
nullptr;
99 for (
const Probe& v : probes_) {
100 if (p.x < v.min.x || p.x > v.max.x || p.y < v.min.y || p.y > v.max.y
101 || p.z < v.min.z || p.z > v.max.z)
continue;
102 const glm::vec3 e = v.max - v.min;
103 const f32 size = e.x * e.y * e.z;
104 if (!best || size < bestSize) { best = &v; bestSize = size; }
106 return best ? best->
slot : 0u;
115 if (
const u32 at =
slotAt(centre); at != 0)
return at;
116 const Probe* best =
nullptr;
118 for (
const Probe& v : probes_) {
119 const glm::vec3 vc = (v.min + v.max) * 0.5f;
120 const glm::vec3 vh = (v.max - v.min) * 0.5f;
121 const glm::vec3 gap = glm::abs(centre - vc) - (half + vh);
122 if (gap.x > 0.0f || gap.y > 0.0f || gap.z > 0.0f)
continue;
123 const f32 size = vh.x * vh.y * vh.z;
124 if (!best || size < bestSize) { best = &v; bestSize = size; }
126 return best ? best->
slot : 0u;
130 const std::vector<Probe>&
probes()
const {
return probes_; }
133 std::vector<Probe> probes_;
134 u32 environment_ = 0;
135 mutable u64 revision_ = 0;
136 mutable u64 revision_hash_ = 0;
Per-frame 2D lighting constants — the third tier of the engine's constant-buffer layering (after per-...
What a resource's content is, as a number that changes whenever it does.
Core type definitions and utilities for ESEngine.
The frame's reflection probes, and the lookup that picks one.
const std::vector< Probe > & probes() const
The probes themselves, for the frame block that carries their boxes.
u64 revision() const
What the frame's reflection probes say, as a number that changes whenever it does (see core/Revision....
u32 slotForBox(const glm::vec3 ¢re, const glm::vec3 &half) const
The column a whole object reflects, by its world box rather than its origin (ProbeStore::sampleBox's ...
u32 environment() const
The baked environment every probe of this frame reads, or 0.
bool add(const glm::vec3 &min, const glm::vec3 &max, u32 slot, u32 environment)
Takes a probe, or refuses one nothing can read.
u32 slotAt(const glm::vec3 &p) const
The column a point at p reflects, or 0 for the environment.
u64 fnv1aBytes(u64 h, const void *data, usize bytes)
constexpr u64 kFnv64Offset
std::uint64_t u64
Unsigned 64-bit integer.
std::size_t usize
Size type for indexing and sizes.
std::uint32_t u32
Unsigned 32-bit integer.
constexpr u32 MAX_REFLECTION_PROBES
Columns of the reflection atlas one frame can address — column 0 the environment's,...
u64 nextRevision()
A revision no content has had before. Never 0, which reads as "none".
float f32
32-bit floating point
One probe: the world box it answers inside, and its atlas column.