1
Vote

Box collision response issue.

description

When you spawn a box at the origin and pick some arbitrary up.. like 200, with all other values zeroed out... no rotation (angular velocity) and no orientation = identity.
When the box falls, it'll get a collision callback but will fail to have any response. This occurs in a large number of test cases. It seems to have something to do with the orientation for the most part. Applying a fare enough ammount of orientation will cause the box to collide correctly. As so some various random positions.
Try running a box with these settings. - This was modified from the example screen, it should be pasteable back in over the box creation for loop. spawn with 1 box, watch the tears :(
 
            // Create a rigid body for the current box.
            RigidBody rigidBody = new RigidBody();
 
            // Populate some of the rigid body's parameters.
            rigidBody.Flags |= RigidBodyFlags.AutoDisable;
            rigidBody.Position = new Vector3(0.0f, 200, 0.0f);//random.NextVector3(-90.0f, 90.0f, 50.0f, 55.0f, -90.0f, 90.0f);
            //rigidBody.Orientation = random.NextQuaternion(-90.0f, 90.0f, 50.0f, 55.0f, -90.0f, 90.0f);
            //rigidBody.Orientation.Normalize();
            //rigidBody.Rotation = random.NextVector3(-0.5f, 0.5f);
            //rigidBody.Rotation.Normalize();
            rigidBody.Acceleration = new Vector3(0.0f, -9.8f, 0.0f);
 
            rigidBody.Friction = 0.5f;
            rigidBody.Restitution = 0.6f;
            rigidBody.LinearDamping = 0.95f;
            rigidBody.AngularDamping = 0.8f;
 
            // Enable the rigid body.
            rigidBody.SetEnabled(true);

            // Create the box.
            CollisionBox box = new CollisionBox();
 
            // Populate some of the box's parameters.
            box.Extents = new Vector3(5);
            box.Mass = box.Extents.X * box.Extents.Y * box.Extents.Z * 8.0f;
 
            // Add the box to the rigid body and initialize.
            rigidBody.CollisionShapes.Add(box);
            rigidBody.CalculateDerivedData();
 
            // Assign the box to the quad-tree and shape list.
            this.space.Add(box);
            this.boxes.Add(box);
            this.rigidBodies.Add(rigidBody);

comments

Ens wrote Apr 30, 2008 at 5:06 AM

The problem is in your code. You are spawning the object out of the bounds of the world. The 'space' is defined as follows in ExampleScreen.cs
this.space = new QuadTree<CollisionShape>(new Vector3(200.0f, 200.0f, 200.0f), 4, this);

If you change your startup position to even this, it will work.
rigidBody.Position = new Vector3( 0.0f, 199.999f, 0.0f );

wrote Feb 13, 2013 at 10:00 PM