motor2 development progress

March 21, 2008 on 11:28 pm | In Actionscript | 26 Comments

I just wanted to give you some updates on the recent motor2 development. I spent far too much time on alternative collision detection algorithms besides SAT and writing a fluid/soft-body solver which I will eventually integrate into the engine. So I’m way behind my schedule. Nevertheless I made some good progress over the last 2 weeks. The latest SVN revision now includes:

  • highly optimized box-circle and poly-circle collision detection
  • a framework for modeling forces, including some simple force generators (e.g. springs)
  • testbed package with dozens of ready-to-compile test scenarios
  • shape renderer example classes
  • fast buoyancy solver

Many bugs were fixed, among other things it turned out that there was a nasty bug in the contact solver which zeroed out all friction impulses. Now the simulation behaves much better, especially for stacks :).

Some words about drawing the scene onto screen: you should look at the ShaperRenderer class to understand how to draw the shape of a rigid body in order to implement custom rendering classes. My implementation draws the modeling space into a display object and then translates and rotates it according to the world space. An alternative is to directly draw the world space after every time step.

Furthermore I started to document the API. For performance reasons almost all fields are defined as public (some of them shouldn’t be modified because they are only used internally by the engine) so I decided to only write javadocs for those methods that make sense for the user.

If you want to be kept up to date about the latest changes you can subscribe to the new motor2 development mailing list at http://groups.google.com/group/motor2.

AS3 Data Structures v1.0

March 17, 2008 on 3:13 pm | In Actionscript | 11 Comments

Version 1.0 is out :) You can grab it from http://as3ds.googlecode.com. The next big update is likely to have advanced tree structures, a revised graph class and further optimizations. This however has to wait until a major version of motor2 is complete, which I’m now working on. For now I’ll only fix bugs as they come along.

Path finding prototype in JavaScript

March 7, 2008 on 11:32 pm | In Actionscript | 3 Comments

Chris Lindsey from Green Mayo Studios has build a pathfinder in JavaScript which is based on my AS3 data structures library. It can be seen here. Pretty darn good, isn’t it ? I can’t think of real applications for it, but it’s nice to see that it’s actually possible :).

int and Number type madness

March 7, 2008 on 11:32 pm | In Actionscript | 8 Comments

Recently I came across a strange behaviour of the AS3 compiler with int and Number types. It took some time to extract the flawed portion of my code to reproduce the error, so here is an example starting with the case where everything’s fine:

var i:int = 3;
var j:int = 6;
while (true)
{
    var k:int = (i + j) / 2;
    trace(k, k is int, k is Number); //4, true, false
    break;
}

The term ‘(i + j) / 2′ evaluates to 4.5, and assigning it to the variable k removes everything after the decimal point. Now below is another example with just the while loop replaced with a do..while variant. But now the variable k “forgets” that it was typed to an int and becomes a Number storing a float:

var i:int = 3;
var j:int = 6;
do
{
    var k:int = (i+ j) / 2;
    trace(k, k is int, k is Number); //4.5, false, true
    break;
}
while (true);

This is really bad since using k to access arrays will throw a runtime error. A workaround is to explicitly cast the value to an int or declare the variable outside the do..while loop.

Proudly powered by WordPress Theme based upon Pool theme by Borja Fernandez.
Entries and comments feeds.