This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: ElastoLab - real time physics in VW
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
ElastoLab started out as a C++ project - real time physics simulator. When Dave got going, did the UI in VW, the physics in C++. Only later did he replace the physics in Smalltalk. It was too hard to improve the algorithms in C++
His initial proof of concept tests worked out - it was fast enough on a 400 particle test. Smalltalk ended up 3.8X times slower than C++ for the physicss calculations. Profiling indicates that this is as fast as VW can go - 80% of the time is in 4 methods. So the question is, is that fast enough?
ElastoLab requires 10 frames/second. 50% calculate time, 10% display time, 40% wait time. So while it's slower, it's fast enough. The algorithm - uses 4th order Adaptive Runge Kutta differential equation solver. Hard to code, but stable - i.e., it will look better on screen.
Finding collisions - more complex than you think. Uses the Bisection algorithm to determine the collision points. Resting Contacts are also complex - it all gets into the performance with barriers and collisions. David was able to more easily implement this in Smalltalk than in C++ due to the algorithm complexity - Baraff[94]. This was one of the drivers to doing it in Smalltalk.
Tradeoff - accuracy vs. speed - use 0.01, 0.001, or 0.001 (etc)? - the more accuracy, the lesss speed. What's "good enough"? There are better methods than Bisection; David went to Smalltalk in order to allow for better algorithms that would actually yield bigger performance gains.
So far, latest release is a tad slower - but he was focused on correctness. Next - better algorithms (as above). The better algorithms have not yet been done.
Question How much harder was the physics in C++ than Smalltalk? - the translation from C++ to Smalltalk was just transliteration, so there's no easy way to compare. The UI was much, much faster to do in ST.