Merge: gamnit: cache each camera matrix and avoid boxing floats in matrix operations
authorJean Privat <jean@pryen.org>
Wed, 10 May 2017 13:20:47 +0000 (09:20 -0400)
committerJean Privat <jean@pryen.org>
Wed, 10 May 2017 13:20:47 +0000 (09:20 -0400)
commitf9be86a8c8820f52eaf5466aa3ee6ebc3940fcbb
tree4d1e65cacc5b74c7f45c199ed7fe69e31a1439a8
parenta22fb19a1ab2ebc7b9954d545010decf46df6dd9
parenta3e387dab57f0cc5db19c12ed4511de16537f962
Merge: gamnit: cache each camera matrix and avoid boxing floats in matrix operations

Optimize the gamnit framework to avoid excessive garbage collection and a general speedup.

Replace the use of a generic `Array[E]` to implement matrices of floats, as it caused the boxing of each floats at each access. The new custom extern class does not suffer from the boxing and allow for some optimization in C code. This structure is allocated in the Nit GC (hackishly), and doesn't need an explicit liberation. A limitation of the current solution is about the size of the floating points in C, `matrix` uses doubles and `glesv2` floats, the data is copied and cast in C code, this could be optimized further as needed.

Caching each camera matrix avoids recreating them at each frame, which was quite costly, especially for the UI camera that rarely moves. The caching logic is implemented as a distinct class allowing easy debugging.

Pull-Request: #2428
Reviewed-by: Jean Privat <jean@pryen.org>
lib/gamnit/flat.nit