FlixelCommunity / flixel

Community fork of Adam “Atomic” Saltsman's popular game engine Flixel. Distilled from a variety of Flash games he worked on over the last couple years, including Gravity Hook, Fathom and Canabalt, its primary function is to provide some useful base classes that you can extend to make your own game objects.
http://flixelcommunity.org/
Other
84 stars 17 forks source link

Use bitwise operators for faster Math functions #196

Open IQAndreas opened 10 years ago

IQAndreas commented 10 years ago

As brought up by @Dovyski in https://github.com/FlixelCommunity/flixel/issues/142#issuecomment-29564170

mezkhalin commented 10 years ago

If it's not a problem I am happy to take on this issue

Dovyski commented 10 years ago

Awesome! :) You can start working on this right now, if you want, but I think it's better if you could hold on until Andreas has organized FlxG/FlxU (issue https://github.com/FlixelCommunity/flixel/issues/142).

mezkhalin commented 10 years ago

Wonderful! I'll wait until the reorganization then, could prove cumbersome otherwise ;)

greysondn commented 10 years ago

The comments give a page which may or may not be of use during this process: http://graphics.stanford.edu/~seander/bithacks.html

It is important to bench the results to be sure it's actually doing good instead of just taking it at face value (and will have to be retested from time to time); I have found such things as I've searched them out to be hit-and-miss chiefly dependent on age. One of the comments there notes:

This was tested with the standalone flash player 9 on windows. but I assume that nowadays the results are out of date and differ greatly.

The simplest test for execution time is to wrap in getTimer() calls such that timeElapsed = timeNow - timeBefore; accuracy is varied by platform but generally is down to the millisecond level somewhat reliably for that test.

Once I have cleared my current docket of assurances here in flixelCommunity, I would be happy to assist in this process if needbe; however, I am considering those hung until the directory structure (and, by extension in AS3, API address for any given component) stabilizes, for various reasons.

Edit: Typos, silliness... I'm too emotive for this line of work...

Dovyski commented 10 years ago

That's a good observation, @greysondn A few bench tests won't hurt.

Dovyski commented 10 years ago

Faster sin function: http://guihaire.com/code/?p=520