This project has moved. For the latest updates, please go here.

Bug in Grid.Intersect(ref Vector2 vector, out Feature feature)??

Topics: Developer Forum
Jun 5, 2008 at 6:59 AM

I'm using this engine for silverlight 2.0 (engine version  This is a great engine. I like it :)

I created a simple draw app but sometimes all the objects are frozen when I'm drawing quickly.

Under debug environment, I found many values in the object body were NaN.

After debugging for a long time, I found at the end of Grid.Intersect() method, before creating the new Feature object, both normal.X and normal.Y are zero which cause Vector2.Normalize fail.

With the following modification, the error doesn't appear so far:

    if (normal.X != 0 || normal.Y != 0))
        Vector2.Normalize(ref normal, out normal);
         feature = new Feature(vector, normal, distance);
         return true;

Is this a bug or there is other cause?

Jun 9, 2008 at 11:15 AM
This could be an oversight on my part. I'll make a note to look at it.
Jul 10, 2008 at 8:29 AM
I got the same error a lot of times.
Thanks for the work on the bugfix!
Aug 15, 2008 at 5:03 PM
Nice! Thanks.

... but there is one "bug" left. Sometimes the objects merge together. I guess I'll check on collision if the objects have the same position (with some tolerance); and if then I'll add some random impulse to seperate them again.

(Of course I could let them simply explode because what object (some kind of a machine) survives a collision like that? Hehe.)