Another “dreaded problem” accrued this week which I’m still struggling with. In contrast to Java’s simplified math types, in C a lot more possibilities exist to represent floats. This is problematic in particular when you have to map between the different formats.
For Java I have following rule of thumb:
- Int(eger) for numbers in
. - Double for Floating Point Arithmetic (On Dalvic VM I prefer float).
- Avoid mixing int with double.
- Map to Number for DB access.
(Honestly, I can’t remember reading something like for(char i = 0; i < 5; i++) in a Java source-code and since there is no pointer-arithmetic necessary, Long – numbers rarely appear for hashes and DB operations. )
A Java double is represented by 64Bit, in YAOgl I’m using the following resolutions:
- For OpenGL 32 Bit (24 Bit Mobile)
- For 3D-Models 32 Bit
- For Positioning, Timing and Animation 32/64 Bit
And notably my
- CPU realtime optimized version of Bullet-Physic-Engine uses 16Bit floating point arithmetic.
This version uses a SIMD (multimedia) instruction-set for the corresponding target platform (the machine code handles multiple calculations at once). Without the optimization a simulation would take to much computation time.
The 16Bit limitation also narrows the range in which a usable simulations can take place. Even worse, bijective-mapping between floating point arithmetic with different resolutions results in nonsense! (Objects start to jitter or slowly drifting away. )
If you ever heard of a successful implementation – I would doubt the source. If you combine the different resolutions to a Set R, than…
The Set of Numbers (R) doesn’t form a Ring. R isn’t commutative. Therefore it hasn’t an associative or distributive property.
As a result it is necessary to align important/active parts of a scene-graph to the usable simulation scale and range.
Since I have to handle very small and very large dimensions in B.I.S (Living-room, the play-board, and the tiny shop on Irata), I’m currently working on a fast rescale function. This includes texture mapping and sound.
Update 12/12/13
It is now possible to rescale the scene-graph during runtime with: [YAWorld* setScale:(float) scale]. Models, textures, lights and the viewport are than updated for the next frame. The 3D-Audio is mapped according to the actual camera position (or better your ears). Therefore no changes are necessary.
What else was done this week
Here is a short video (sorry for the silly references but the opt-out function seems to be disabled):





