Monday, October 17, 2011

New system almost complete - much more stable

I have mostly finished the framework underlying the second release of SWIFT. I have made a wrapper around most of the windowing functions I need, plus drawing functions which are now handled by the GUI library (which should allow me to make a Clutter backend as well!).  Instead of using the buggy pixel-based hitTest I was using before, I am now using the even-odd algorithm. I was initially calculating exact intersections of lines, but I stumbled across this post, which appears to be much more efficient. Early tests indicate that it is. I ran a benchmark; here are the results (from an Asus EeePC netbook!):
10,000 hitTests
total time: 1.735355 seconds
average time: 0.000174 seconds/hitTest
In other words, that's about 0.1 milliseconds per hitTest! This is better than I expected by a factor of 10 or more! And it all "just works", unlike the pixel version which was very finicky. So (judging by hitTests alone) you could be working with 1,000 objects on the Stage and not even notice a slowdown on a low-spec'd computer!
I will re-write the HTML5 hitTest library to use this algorithm, it should speed it up quite a lot.

No comments:

Post a Comment