Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
ClusterSelection.hpp File Reference

Which clusters of a mesh's hierarchy one eye draws. More...

#include "../../core/Types.hpp"
#include "../../math/Math.hpp"
#include <algorithm>
#include <cmath>
#include <cstring>
#include <limits>
#include <vector>
Include dependency graph for ClusterSelection.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esengine::lod::Cluster
 One cluster: its run of the hierarchy's indices, its own bounds and its group's. More...
struct  esengine::lod::ClusterHierarchy
 A mesh's clusters and the indices they name, every level together. More...
struct  esengine::lod::ClusterEye
 An eye as a hierarchy measures from it. More...

Namespaces

namespace  esengine
namespace  esengine::lod

Functions

f32 esengine::lod::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.
bool esengine::lod::clusterDrawn (const ClusterEye &eye, const Cluster &cluster)
 Whether cluster is the level of its surface that eye draws.
u32 esengine::lod::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.
u64 esengine::lod::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 buffer.
void esengine::lod::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.
bool esengine::lod::clusterHierarchyValid (const ClusterHierarchy &hierarchy, u32 vertexCount)
 Whether hierarchy is one a cut can be assembled from: every run inside the indices, every index a vertex.

Variables

constexpr f32 esengine::lod::kClusterNearGap = 1e-6f
 The nearest a sphere's surface is taken to be: an eye inside one sees its error as large as it can be.

Detailed Description

Which clusters of a mesh's hierarchy one eye draws.

A clustered mesh carries its triangles at every level of detail, cut into clusters (pipeline/src/assets/clusterLod.ts builds them). Each cluster has two bounds, its own and its group's: a sphere and an error in mesh units. A view draws a cluster when its own error is small enough on screen and its group's is not. A group's sphere holds its clusters' and its error is no smaller, so from any eye the group measures at least what its clusters do, and of a surface's levels exactly one is drawn everywhere. Header-only and free of the renderer, like LodSelection.hpp.

Definition in file ClusterSelection.hpp.