diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-01 13:17:50 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-01 13:17:50 +0100 |
commit | d478c37fc03c7590823f003a3b326e79ae8012f9 (patch) | |
tree | d64f164bc4b5922324bd88bfe809d7dea2dde2ba /draw | |
parent | 7ebee3863c061b1d0b64839b56bbc70ff4e5d924 (diff) |
draw: skip clickables fully off the screen
Diffstat (limited to 'draw')
-rw-r--r-- | draw/anim.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/draw/anim.cpp b/draw/anim.cpp index 591d3801..03718fcb 100644 --- a/draw/anim.cpp +++ b/draw/anim.cpp @@ -34,16 +34,19 @@ void anim_mesh::add_clickable(tile_shader& shader, const Vector2i& win_size, const auto& g = a.group(s.r); const auto& f = a.frame(s.r, s.frame); const auto world_pos = TILE_SIZE20 * Vector3(xy) + Vector3(g.offset) + Vector3(Vector2(s.offset), 0); - const Vector2ui offset((Vector2(shader.camera_offset()) + Vector2(win_size)*.5f) - + shader.project(world_pos) - Vector2(f.ground)); - clickable item = { - { f.offset, f.offset + f.size }, { offset, offset + f.size }, - a.bitmask(), tile_shader::depth_value(xy, tile_shader::scenery_depth_offset), - a.info().pixel_size[0], - c, xy, - !g.mirror_from.isEmpty(), - }; - list.push_back(item); + const Vector2i offset((Vector2(shader.camera_offset()) + Vector2(win_size)*.5f) + + shader.project(world_pos) - Vector2(f.ground)); + if (offset < win_size && offset + Vector2i(f.size) >= Vector2i()) + { + clickable item = { + { f.offset, f.offset + f.size }, { offset, offset + Vector2i(f.size) }, + a.bitmask(), tile_shader::depth_value(xy, tile_shader::scenery_depth_offset), + a.info().pixel_size[0], + c, xy, + !g.mirror_from.isEmpty(), + }; + list.push_back(item); + } } void anim_mesh::draw(tile_shader& shader, chunk& c) |