float32 type

Hi Erin,

Is the Box2D float32 type set as a float in order to conserve memory? On every platform that I have been using (iOS, OSX, Windows), I get a marginal to significant increase in performance by switching to double. It appears that many current FPUs must upcast floats to double internally, and downcast outputted values.

-Tim Kerchmar
Smaller data leads to less cache misses. Also a modern compiler can convert some singe precision operations to SSE automatically. I strive to make my math robust in single precision so that it would be feasible to convert to SIMD in the future. Some platforms have horrible performance in double precision, such as the PS2. On the PS2 there is no hardware support for doubles.
*Shudder*, the PS2. :-\ SSE, didn't think of that. I don't foresee any difficult merge complications with future revisions. Would a #ifdef toggle for both types be useful, or would you prefer someone, such as myself, maintain a separate branch specifically with double support?

It was the float32 typedef and then some places such as all instances of cosf, and constants declared as floats, those were the spots that I changed to convert Box2D to double.
Yeah, I can't say I'm really interesting in maintaining a version for doubles. I would have to switch the macro to test it every time I make a change ... not fun.

Are you using doubles for a large world? I recommend world re-centering around the character to reduce the rounding errors. This is a feature that would have to be added to Box2D, but it is not terribly hard to do.

Original thread: https://box2d.org/forum/viewtopic.php?t=6633