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

Topics: Developer Forum
Jun 5, 2008 at 7:59 AM
Hi,

I'm using this engine for silverlight 2.0 (engine version 1.0.0.5).  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?

Thanks,
Hailiang
Coordinator
Jun 9, 2008 at 12:15 PM
This could be an oversight on my part. I'll make a note to look at it.
Jul 10, 2008 at 9:29 AM
I got the same error a lot of times.
Thanks for the work on the bugfix!
Developer
Aug 15, 2008 at 6: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.)