52 inline void ShadowAtlas::set_tile(
size_t x,
size_t y,
bool flag) {
53 _flags[x + y * _num_tiles] = flag;
70 inline bool ShadowAtlas::get_tile(
size_t x,
size_t y)
const {
71 return _flags[x + y * _num_tiles];
90 inline bool ShadowAtlas::region_is_free(
size_t x,
size_t y,
size_t w,
size_t h)
const {
93 nassertr(x >= 0 && y >= 0 && x + w <= _num_tiles && y + h <= _num_tiles,
false);
96 for (
size_t cx = 0; cx < w; ++cx) {
97 for (
size_t cy = 0; cy < h; ++cy) {
98 if (get_tile(cx + x, cy + y))
return false;
117 nassertr(resolution > 0, -1);
119 if (resolution % _tile_size != 0) {
120 shadowatlas_cat.error() <<
"Resolution " << resolution <<
" is not a multiple " 121 <<
"of the shadow atlas tile size (" << _tile_size <<
")!" << std::endl;
124 return resolution / _tile_size;
137 LVecBase4 flt = LVecBase4(region.get_x(), region.get_y(), region.get_z(), region.get_w());
138 return flt * ((float)_tile_size / (
float)_size);
146 inline int ShadowAtlas::get_num_used_tiles()
const {
147 return _num_used_tiles;
158 return float(_num_used_tiles) / float(_num_tiles * _num_tiles);
int get_tile_size() const
RenderPipeline.
int get_required_tiles(size_t resolution) const
Returns the amount of tiles required to store a resolution.
LVecBase4 region_to_uv(const LVecBase4i ®ion)
Converts a tile-space region to uv space.
get_coverage
Returns the amount of used tiles in percentage.