Collision System – Update II

This update I won’t be talking about much except what decisions I’ve made as to how I’m setting everything up.

Right now I have a Physics class in the Physics project which handles keeping track of all the collidable objects. This object is just the sRigidBodyState struct which I’ve modified to also store collision data. There is an update loop which will handle detecting collisions.

Since for now there is only collision detection the pseudo code looks like this ->

Update() {  // Per frame

TryMoveObjects();

Loop through all objects in list and check for collision against every other object.

  • If an object did not have any collisions this frame go through the collision pair list and remove this object if it exists in the list.
    • If it was in the list, also call the OnColliderEndOverlap functions on these colliders.
  • If a collision pair is detected, check to see if it already exists in the collision pair list. If it does don’t do anything.
  • If a new collision pair is found store it in a list and call their individual OnColliderBeginOverlap functions. This happens only once.

Loop through all the collision pairs and call OnColliderOverlapStay function.

FinalizeMove();

}

As you can see the Begin and End overlap functions will only be called once while the OverlapStay will be called every loop.

This update function will replace the individual update function call for every sRigidBodyStruct in the main loop.

I’ve decided to use function pointers as opposed to inheritance to register and update my collider object. And I’m using smart pointers for reference tracking.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s