apecs-0.2.0.3: A fast ECS for game engine programming

Safe HaskellNone
LanguageHaskell2010

Apecs.Util

Contents

Synopsis

Utility

initStore :: (Initializable s, InitArgs s ~ ()) => IO s Source #

Initializes a store with (), useful since most stores have () as their initialization argument

newtype ConcatQueries q Source #

Sequentially performs a series of queries and concatenates their result. Especially useful when iterating over an IndexTable

Constructors

ConcatQueries [q] 

Instances

Query q s => Query (ConcatQueries q) s Source # 

Methods

explSlice :: s -> ConcatQueries q -> IO (Vector Int) Source #

runGC :: System w () Source #

Explicitly invoke the garbage collector

EntityCounter

initCounter :: IO (Storage EntityCounter) Source #

Initialize an EntityCounter

nextEntity :: Has w EntityCounter => System w (Entity ()) Source #

Bumps the EntityCounter and yields its value

newEntity :: (IsRuntime c, Has w c, Has w EntityCounter) => c -> System w (Entity c) Source #

Writes the given components to a new entity, and yields that entity

Spatial hashing

quantize Source #

Arguments

:: (Fractional (v a), Integral b, RealFrac a, Functor v) 
=> v a

Quantization cell size

-> v a

Vector to be quantized

-> v b 

The following functions are for spatial hashing. The idea is that your spatial hash is defined by two vectors; - The cell size vector contains real components and dictates how large each cell in your table is spatially. It is used to translate from world-space to table space - The field size vector contains integral components and dictates how many cells your field consists of in each direction. It is used to translate from table-space to a flat integer

Quantize turns a world-space coordinate into a table-space coordinate by dividing by the given cell size and round components towards negative infinity

flatten :: (Applicative v, Integral a, Foldable v) => v a -> v a -> a Source #

Turns a table-space vector into a linear index, given some table size vector.

region Source #

Arguments

:: (Enum a, Applicative v, Traversable v) 
=> v a

Lower bound for the region

-> v a

Higher bound for the region

-> [v a] 

For two table-space vectors indicating a region's bounds, gives a list of the vectors contained between them. This is useful for querying a spatial hash.

inbounds :: (Num (v a), Ord a, Applicative v, Foldable v) => v a -> v a -> Bool Source #

Tests whether a vector is in the region given by 0 and the size vector

Timing

timeSystem :: System w a -> System w (Double, a) Source #

Runs a system and gives its execution time in seconds

timeSystem_ :: System w a -> System w Double Source #

Runs a system, discards its output, and gives its execution time in seconds