42static_assert(
sizeof(
Cluster) == 48,
"Cluster is the record an .esmesh stores");
75 if (!(error < std::numeric_limits<f32>::infinity()))
return std::numeric_limits<f32>::infinity();
77 const glm::vec3 to = glm::vec3(centre[0], centre[1], centre[2]) - eye.
position;
92 for (
u32 i = 0; i < count; ++i) {
103 u64 hash = 0xcbf29ce484222325ull;
104 for (
const u32 id : picked) {
106 hash *= 0x100000001b3ull;
108 return hash ^ (
static_cast<u64>(picked.size()) << 40);
118 std::vector<u32>& out) {
120 for (
const u32 id : picked) total += hierarchy.
clusters[id].indexCount;
123 for (
const u32 id : picked) {
126 if (vertexBase == 0) {
127 std::memcpy(out.data() + at, from,
static_cast<usize>(cluster.
indexCount) *
sizeof(
u32));
129 for (
u32 i = 0; i < cluster.
indexCount; ++i) out[at + i] = from[i] + vertexBase;
143 if (cluster.
indexCount % 3 != 0)
return false;
147 for (
const u32 index : hierarchy.
indices)
if (index >= vertexCount)
return false;
Math utilities and GLM configuration for ESEngine.
Core type definitions and utilities for ESEngine.
constexpr f32 kClusterNearGap
The nearest a sphere's surface is taken to be: an eye inside one sees its error as large as it can be...
bool clusterHierarchyValid(const ClusterHierarchy &hierarchy, u32 vertexCount)
Whether hierarchy is one a cut can be assembled from: every run inside the indices,...
u32 selectClusters(const ClusterHierarchy &hierarchy, const ClusterEye &eye, std::vector< u32 > &out)
The clusters eye draws, in the hierarchy's order, into out. Returns the indices they hold together.
f32 clusterErrorOnScreen(const ClusterEye &eye, const f32 *centre, f32 radius, f32 error)
The size on screen of error, read at the nearest point of the sphere it belongs to.
u64 cutSignature(const std::vector< u32 > &picked)
A number that changes when the picked clusters do: two cuts with the same one are drawn from the same...
bool clusterDrawn(const ClusterEye &eye, const Cluster &cluster)
Whether cluster is the level of its surface that eye draws.
void assembleCut(const ClusterHierarchy &hierarchy, const std::vector< u32 > &picked, u32 vertexBase, std::vector< u32 > &out)
The picked clusters' indices, one run after another, into out.
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.
float f32
32-bit floating point
An eye as a hierarchy measures from it.
bool flat
An orthographic view: an error is the same size at every distance.
A mesh's clusters and the indices they name, every level together.
std::vector< u32 > indices
std::vector< Cluster > clusters
One cluster: its run of the hierarchy's indices, its own bounds and its group's.