SpriteFinderImpl

public class SpriteFinderImpl implements SpriteFinder

Indexes an atlas sprite to allow fast lookup of Sprites from baked vertex coordinates. Implementation is a straightforward quad tree. Other options that were considered were linear search (slow) and direct indexing of fixed-size cells. Direct indexing would be fastest but would be memory-intensive for large atlases and unsuitable for any atlas that isn't consistently aligned to a fixed cell size.

Constructors

SpriteFinderImpl
Link copied to clipboard
void SpriteFinderImpl(Map<Identifier, Sprite> sprites)

Types

SpriteFinderAccess
Link copied to clipboard
public interface SpriteFinderAccess

Functions

find
Link copied to clipboard
Sprite find(float u, float v)
Alternative to find when vertex centroid is alreadyknown or unsuitable.
Sprite find(QuadView quad, int textureIndex)
Finds the atlas sprite containing the vertex centroid of the quad.Vertex centroid is essentially the mean u,v coordinate - the intent beingto find a point that is unambiguously inside the sprite (vs on an edge.
get
Link copied to clipboard
static SpriteFinder get(SpriteAtlasTexture atlas)
Retrieves or creates the finder for the given atlas.Instances should not be retained as fields or they must berefreshed whenever there is a resource reload or other eventthat causes atlas textures to be re-stitched.
static SpriteFinderImpl get(SpriteAtlasTexture atlas)

Sources

jvm source
Link copied to clipboard