Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::OcclusionView Class Reference

The depths this view is blocked at, and the test a bound asks it. More...

#include <OcclusionView.hpp>

Public Member Functions

void setSize (u32 size)
u32 size () const
void begin (const glm::mat4 &viewProjection)
 Opens a view looking through viewProjection. Nothing is blocked until a box is taken, which is what a scene declaring no occluder (every 2D one) pays: one comparison per renderable.
bool addBox (const glm::vec3 &centre, const glm::quat &rotation, const glm::vec3 &half)
 Takes one solid box — half world half-extents about centre, turned by rotation — as something sight does not pass through.
void finish ()
 Closes the view: reduces the grid by MAXIMUM into a pyramid, so a bound of any size on screen costs four reads rather than its area. A coarse texel answers for a whole region, and taking the farthest of them is what keeps a region that is only partly blocked drawn.
bool hidden (const glm::vec3 &centre, const glm::vec3 &half) const
 Whether nothing of a box bounded by centre / half can be seen, because every texel it covers is blocked nearer than its nearest point.
bool empty () const
 Whether this view blocks nothing, so every bound is visible to it.
u32 boxes () const
 How many declared boxes this view took.

Static Public Attributes

static constexpr u32 kSize = 64
 Grid resolution of the coarsest useful answer. A texel is ~1.5% of the screen, which is what an occluder must exceed to hide anything; finer costs the rasterisation, which is the only cost here.
static constexpr u32 kLevels = 7
 64, 32, 16, 8, 4, 2, 1 — down to one texel, so an object covering the whole screen still takes a bounded number of reads.
static constexpr u32 kTestSpan = 4
 Texels a side a bound is tested over: sixteen reads, whatever its size on screen.
static constexpr f32 kOpen = std::numeric_limits<f32>::infinity()
 Depth of a texel nothing covers: no bound is ever farther.
static constexpr f32 kMinW = 1e-4f
 Smallest clip w a corner may have. Anything at or behind the eye plane makes the projection meaningless, and the cases that reach it — the eye inside the box, the box across the near plane — are exactly the ones a conservative answer must refuse.

Detailed Description

The depths this view is blocked at, and the test a bound asks it.

begin, an addBox per declared occluder, finish, then hidden until the next begin. The stored view-projection serves both halves: a tester holding its own copy is how a raster and a test come to disagree about where something is.

Definition at line 48 of file OcclusionView.hpp.

Member Function Documentation

◆ addBox()

bool esengine::OcclusionView::addBox ( const glm::vec3 & centre,
const glm::quat & rotation,
const glm::vec3 & half )
inline

Takes one solid box — half world half-extents about centre, turned by rotation — as something sight does not pass through.

Returns
Whether it was taken. A refusal is not an error: a box reaching behind the eye plane is dropped whole rather than clipped, because everything this class may get wrong must be got wrong towards drawing.

Definition at line 100 of file OcclusionView.hpp.

References kOpen.

◆ begin()

void esengine::OcclusionView::begin ( const glm::mat4 & viewProjection)
inline

Opens a view looking through viewProjection. Nothing is blocked until a box is taken, which is what a scene declaring no occluder (every 2D one) pays: one comparison per renderable.

Definition at line 86 of file OcclusionView.hpp.

◆ boxes()

u32 esengine::OcclusionView::boxes ( ) const
inline

How many declared boxes this view took.

Definition at line 234 of file OcclusionView.hpp.

◆ empty()

bool esengine::OcclusionView::empty ( ) const
inline

Whether this view blocks nothing, so every bound is visible to it.

Definition at line 231 of file OcclusionView.hpp.

◆ finish()

void esengine::OcclusionView::finish ( )
inline

Closes the view: reduces the grid by MAXIMUM into a pyramid, so a bound of any size on screen costs four reads rather than its area. A coarse texel answers for a whole region, and taking the farthest of them is what keeps a region that is only partly blocked drawn.

Definition at line 163 of file OcclusionView.hpp.

References size().

◆ hidden()

bool esengine::OcclusionView::hidden ( const glm::vec3 & centre,
const glm::vec3 & half ) const
inline

Whether nothing of a box bounded by centre / half can be seen, because every texel it covers is blocked nearer than its nearest point.

Definition at line 184 of file OcclusionView.hpp.

References kOpen, kTestSpan, and size().

◆ setSize()

void esengine::OcclusionView::setSize ( u32 size)
inline

Definition at line 71 of file OcclusionView.hpp.

References kSize, and size().

◆ size()

u32 esengine::OcclusionView::size ( ) const
inline

Definition at line 81 of file OcclusionView.hpp.

Referenced by finish(), hidden(), and setSize().

Member Data Documentation

◆ kLevels

u32 esengine::OcclusionView::kLevels = 7
staticconstexpr

64, 32, 16, 8, 4, 2, 1 — down to one texel, so an object covering the whole screen still takes a bounded number of reads.

Definition at line 56 of file OcclusionView.hpp.

◆ kMinW

f32 esengine::OcclusionView::kMinW = 1e-4f
staticconstexpr

Smallest clip w a corner may have. Anything at or behind the eye plane makes the projection meaningless, and the cases that reach it — the eye inside the box, the box across the near plane — are exactly the ones a conservative answer must refuse.

Definition at line 69 of file OcclusionView.hpp.

◆ kOpen

f32 esengine::OcclusionView::kOpen = std::numeric_limits<f32>::infinity()
staticconstexpr

Depth of a texel nothing covers: no bound is ever farther.

Definition at line 63 of file OcclusionView.hpp.

Referenced by addBox(), and hidden().

◆ kSize

u32 esengine::OcclusionView::kSize = 64
staticconstexpr

Grid resolution of the coarsest useful answer. A texel is ~1.5% of the screen, which is what an occluder must exceed to hide anything; finer costs the rasterisation, which is the only cost here.

Definition at line 53 of file OcclusionView.hpp.

Referenced by setSize().

◆ kTestSpan

u32 esengine::OcclusionView::kTestSpan = 4
staticconstexpr

Texels a side a bound is tested over: sixteen reads, whatever its size on screen.

Definition at line 60 of file OcclusionView.hpp.

Referenced by hidden().


The documentation for this class was generated from the following file: