Problems with CollisionCallbacks

Mar 12, 2008 at 5:32 PM

I recently started using Oops3D to create a game for a class project and I really like what I see. I am just having trouble getting it working.

I implemented the IPhysicsIntegrator, ICollisionGenerator, IQuadTreeComparer<CollisionShape>, ICollisionCallback interfaces in my original Game object. I also added a RigidBody with a simple CollisionBox to my entity objects. I add these RigidBodies to the quadtree.

Currently, I just added 10 entity objects to my scene. These entities just start falling, so I know the PhysicsComponent is working.

I put in some checks to make sure the ICollisionGenerator and ICollisionCallback functions are being called. They are only being called when the program is first run. When I start moving any of the entities into each other, the collision callbacks are not being called.

I have only started using your code for a few days now, so I must be missing something. Let me know if you need anymore info, maybe some code.

Thanks in advance,
Mar 17, 2008 at 12:47 AM
Hey Blake,

First, make sure that the class(es) the implements the ICollisionGenerator and ICollisionCallback interfaces are being passed into the constructor of the PhysicsComponent instance. There a few of them.

I f you still have a problem contact me here and I'll respond so you can send me your code if you want.

Good luck!
Apr 30, 2008 at 4:57 AM
Edited Apr 30, 2008 at 4:59 AM
This sounds like the problem that Kylawl reported in the issue tracker. Are you creating a QuadTree of adequate size? All objects must exist within the bounds of your QuadTree (or one of its descendant nodes). In the problem that Kylawl reported i observed that the CompareWorld method was never called when a box was spawned on the extent of the QuadTree and therefore collisions were never detected.

I took a quick look at the QuadTree.Add method and traced back to the compare method used. It will not add an item that is outside the extents of the tree. The QuadTree.Add method will return a bool indicating if the item was added or not, give this return value a check (and perhapses set an assertion on it to be alerted to a miss).

In the demo project the QuadTree is defined in ExampleScreen.cs as: = new QuadTree<CollisionShape>(new Vector3(200.0f, 200.0f, 200.0f), 4, this);

Compare method from ExampleScreen.cs line 467:
return node.Bounds.Contains(obj.AABB) == ContainmentType.Contains;

Also note that if an object leaves the extents of the QuadTree it will be automatically removed from the tree to allow objects to 'escape'. The QuadTree supports the idea of partitioning with this mechanism to allow for groups of objects in space to only be concerned with interacting with objects in that same space. Take for example the idea of a world with both an inside and outside region, or rooms in a level, there is no need for objects to check for collision with objects in another room or logical world devision - it cant happen. The mechanism employed by Oops allows for a more complex test than is the object inside a square extents space. The compare line referred to above could carry out a more complex test to segregate objects.

-Hope this helps!