SpriteBatch: setVisible() method

Issue #551 wontfix
created an issue

the setVisible() method would allow specifying a subset of a SpriteBatch's sprites to be drawn by providing their ids. this would be useful in conjunction with eg. visibility queries you could get from libraries like hardoncollider.

it would have 3 variants:

SpriteBatch:setVisible(...) -- raw list of ids
SpriteBatch:setVisible(ids) -- table of ids
SpriteBatch:setVisible() -- return to drawing everything

if an invalid id is present, it would simply be ignored.

there could also be a corresponding getVisible() method too.

not sure whether this would provide any significant performance improvement, but maybe it would help with very large spritebatches

Comments (2)

  1. Alex Szpakowski

    I believe you can do a pseudo SpriteBatch:hide(id) with SpriteBatch:set(id, 0, 0, 0, 0, 0).

    This makes all the sprite's vertices equal (because the x and y scales are 0), which prevents OpenGL from processing the sprite when drawing the SpriteBatch.

  2. Log in to comment