Skip to main content
Tweeted twitter.com/StackGameDev/status/866568745979969536
deleted 119 characters in body; edited tags; edited title
Source Link
Gnemlock
  • 5.3k
  • 5
  • 28
  • 59

Collision Detection Delegate Scheme How do I handle my collision resolution using a delegate scheme?

Hey guys! My physics engine is coming along quite nicely (thanks for asking!), and I'm ready to start working on some even more advanced junkfeatures. Case in point, I'm trying to set up my collision engine so that an arbitrary delegate can be notified when a collision occurs. Let me set up a scenario for you:

Say we have object A, object B, and object C in the physics simulation. I want to be able to inform a delegate about a collision between A and B, ANDand also inform a potentially DIFFERENTdifferent delegate about a collision between A and C.

A little background information: I have a known interface for the delegate, I have the potential of storing a state for my collision detector (but don't atm), although I currently do not, and have the ability to store statestates in the objects, themselves. Similarly, I use this delegate model to handle collision resolution, simply setting the physics engine as the delegate for all objects by default, and allowing the user to change the delegate if desired.

Now, I have already tried having each object store it's own collision delegate, that would be informed when a collision occurred. This didn't work, because when the objects had the same collision delegate, the same collision was handled twice. When I switched to only using the delegate of the first object (however that was decided), the order of simulation became an issue. I want to use a dictionary, but that introduces a significant amount of overhead. However, that seems like the direction I need to be heading.

So here's the question: fight to the death over a suitable solution. How would YOU solve this problemdo I handle my collision resolution using a delegate scheme?

Collision Detection Delegate Scheme

Hey guys! My physics engine is coming along quite nicely (thanks for asking!) and I'm ready to start working on some even more advanced junk. Case in point, I'm trying to set up my collision engine so that an arbitrary delegate can be notified when a collision occurs. Let me set up a scenario for you:

Say we have object A, object B, and object C in the physics simulation. I want to be able to inform a delegate about a collision between A and B, AND inform a potentially DIFFERENT delegate about a collision between A and C.

A little background information: I have a known interface for the delegate, I have the potential of storing state for my collision detector (but don't atm), and have the ability to store state in the objects themselves. Similarly, I use this delegate model to handle collision resolution, simply setting the physics engine as the delegate for all objects by default, allowing the user to change the delegate if desired.

Now, I already tried having each object store it's own collision delegate that would be informed when a collision occurred. This didn't work because when the objects had the same collision delegate, the same collision was handled twice. When I switched to only using the delegate of the first object (however that was decided), the order of simulation became an issue. I want to use a dictionary, but that introduces a significant amount of overhead. However, that seems like the direction I need to be heading.

So here's the question: fight to the death over a suitable solution. How would YOU solve this problem?

How do I handle my collision resolution using a delegate scheme?

My physics engine is coming along quite nicely, and I'm ready to start working on some more advanced features. I'm trying to set up my collision engine so that an arbitrary delegate can be notified when a collision occurs.

Say we have object A, object B, and object C in the physics simulation. I want to be able to inform a delegate about a collision between A and B, and also inform a potentially different delegate about a collision between A and C.

I have a known interface for the delegate, I have the potential of storing a state for my collision detector, although I currently do not, and have the ability to store states in the objects, themselves. Similarly, I use this delegate model to handle collision resolution, simply setting the physics engine as the delegate for all objects by default, and allowing the user to change the delegate if desired.

I have already tried having each object store it's own collision delegate, that would be informed when a collision occurred. This didn't work, because when the objects had the same collision delegate, the same collision was handled twice. When I switched to only using the delegate of the first object (however that was decided), the order of simulation became an issue. I want to use a dictionary, but that introduces a significant amount of overhead. However, that seems like the direction I need to be heading.

How do I handle my collision resolution using a delegate scheme?

Source Link
Grimless
  • 324
  • 4
  • 10

Collision Detection Delegate Scheme

Hey guys! My physics engine is coming along quite nicely (thanks for asking!) and I'm ready to start working on some even more advanced junk. Case in point, I'm trying to set up my collision engine so that an arbitrary delegate can be notified when a collision occurs. Let me set up a scenario for you:

Say we have object A, object B, and object C in the physics simulation. I want to be able to inform a delegate about a collision between A and B, AND inform a potentially DIFFERENT delegate about a collision between A and C.

A little background information: I have a known interface for the delegate, I have the potential of storing state for my collision detector (but don't atm), and have the ability to store state in the objects themselves. Similarly, I use this delegate model to handle collision resolution, simply setting the physics engine as the delegate for all objects by default, allowing the user to change the delegate if desired.

Now, I already tried having each object store it's own collision delegate that would be informed when a collision occurred. This didn't work because when the objects had the same collision delegate, the same collision was handled twice. When I switched to only using the delegate of the first object (however that was decided), the order of simulation became an issue. I want to use a dictionary, but that introduces a significant amount of overhead. However, that seems like the direction I need to be heading.

So here's the question: fight to the death over a suitable solution. How would YOU solve this problem?