16#include <glm/gtc/quaternion.hpp>
57inline void boundingSphere(
const glm::vec3& position,
const glm::quat& rotation,
58 const glm::vec3& scale,
const glm::vec3& localMin,
59 const glm::vec3& localMax, glm::vec3& outCentre,
f32& outRadius) {
60 const glm::vec3 scaledHalf = glm::abs((localMax - localMin) * 0.5f * scale);
61 outCentre = position + glm::mat3_cast(rotation) * ((localMin + localMax) * 0.5f * scale);
62 outRadius = glm::length(scaledHalf);
75 const glm::vec4 clip = viewProjection * glm::vec4(centre, 1.0f);
77 const glm::vec3 row1(viewProjection[0][1], viewProjection[1][1], viewProjection[2][1]);
78 const glm::vec3 row3(viewProjection[0][3], viewProjection[1][3], viewProjection[2][3]);
81 const glm::vec3 gradient = (row1 - (clip.y / clip.w) * row3) / clip.w;
82 return radius * glm::length(gradient);
96 const u8 candidate =
static_cast<u8>(i + 1);
97 const bool coarseSide = current >= candidate;
101 if (set.
cull > 0.0f) {
102 const bool wasCulled = current ==
kCulled;
Math utilities and GLM configuration for ESEngine.
Core type definitions and utilities for ESEngine.
constexpr f32 kSizeAtEye
What a point at or behind the eye reports.
u8 selectLevel(const LevelSet &set, f32 size, u8 current)
The level size asks for, given the one shown last.
f32 screenRelativeSize(const glm::mat4 &viewProjection, const glm::vec3 ¢re, f32 radius)
How much of the viewport's HEIGHT a sphere covers: 1 = one screen high.
constexpr u8 kCulled
The level of an object small enough that nothing is drawn for it.
void boundingSphere(const glm::vec3 &position, const glm::quat &rotation, const glm::vec3 &scale, const glm::vec3 &localMin, const glm::vec3 &localMax, glm::vec3 &outCentre, f32 &outRadius)
The sphere a group is measured by: its centre in the world and its radius.
constexpr u8 kMaxStandIns
How many stand-ins a group may declare beyond the renderer's own mesh.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
float f32
32-bit floating point
The screen sizes a group hands over at, in the order it hands them over.
f32 takeOver[kMaxStandIns]
What a frame's selections came to, counted where each one is made.
u32 level[kMaxStandIns+1]