pub struct TileRect {
pub x: u32,
pub y: u32,
pub side: u32,
}Expand description
A rectangle of the shadow atlas, in texels.
Square, because it is a node of a quadtree over a square cell — the two axes are one number and a reader that took them apart would be describing something this allocator cannot produce.
Fields§
§x: u32Texels from the atlas’s left edge to this rectangle’s.
y: u32Texels from its top edge to this rectangle’s.
side: u32The rectangle’s side, in texels. Zero for TileRect::EMPTY.
Implementations§
Source§impl TileRect
impl TileRect
Sourcepub const EMPTY: Self
pub const EMPTY: Self
The rectangle of an atlas slot no map was rendered into.
Zero rather than a corner of the image, on
crate::forward’s reason for writing the identity into a free tile’s
matrix: nothing samples a free slot — the rows that could name one carry
NO_SHADOW_TILE — so what the
value is for is a block dumped for debugging, where a side of zero says
“empty” and a plausible rectangle would not.
Sourcepub fn to_uv(self) -> [f32; 4]
pub fn to_uv(self) -> [f32; 4]
The rectangle as the shader reads it: a scale into the atlas in xy and
an offset in zw, so a point t of the tile’s own 0..1 space is at
zw + t * xy.
Two scales rather than one even though the rectangle is square: the
atlas need not be, and dividing a square by a rectangle’s two extents
is what puts a tile’s 0..1 on both of the image’s axes.