CollisionEnabled vs CollisionResponseEnabled

Nov 23, 2009 at 3:10 PM
Edited Nov 23, 2009 at 3:12 PM

Can you explain the difference between these two values?  It seems that if just one of these values are set to false, the collision doesn't seem to happen.  I assume then that means that CollisionEnabled simply detects the collision and fires the OnCollision event if necessary?  Then that means that setting CollisionResponseEnabled to false is the same as returning false to the OnCollide Event?

If I'm right about that...

It might be more useful to be able to enable collision, enable separation, and then enable the response to the collision as an option after separation instead of having the separation and reaction code all contingent on one bool.  Unless I'm missing something here it seems like that's not possible right now?

This may also alleviate some of the problems users have been having with the walking over multiple flat surfaces since they can call the separation code to move the character back above the surface, but then decide whether or not to react to the forces calculated if the player is on a ground surface or even a sticky surface (because right now setting restitution to 0 on both objects seems to be broken.  It's close, but there are small reactions that still happen when they collide, whereas if the surface was sticky, you'd want the object to stop completely).

It would also be nice to know the values that are about to be added or applied to the object in question.

Coordinator
Nov 23, 2009 at 9:17 PM

Setting CollisionEnabled to false causes all collisions on that object to be ignored in the broad phase of the physics system. The OnCollision and OnBroadPhaseCollision will never fire since the geometry is simply ignored.

Setting CollisionResponseEnabled to false causes the geometry to ignore the response of a collision. Collisions on the geometry are still detected and reported using the two collision delegates.

Returning false inside the OnCollision delegate causes the physics system to drop all detected contacts and thus it will have no data to create a collision response. You might say that returning false inside the OnCollision delegate and CollisionResponseEnabled to false is the same, but they happen at different points in the physics system.

Restitution works the best it can. It is a value ranging from 0 to 1 that determines the amount of "reactionforce" to apply to the collision response. Setting it to 0 makes the reactionforce 0. Your reactions might be because it is an iterative (and very simple) solver. Can you provide me with a sample that demonstrates the bouncing you get?

Nov 24, 2009 at 3:35 PM
Edited Nov 24, 2009 at 3:41 PM

So then are you saying it's impossible to separate the the objects first, and then decide if I want to apply the reaction force?  I don't know enough about the engine yet to really break it apart myself (maybe as I spend a little more time with it), but I was wondering if there are any functions I could call to get the functionality I'm needing or if you can point me to the direction of where those individual things happen in the source.

I'm not too worried about the bouncing.  It's a small problem and is manageable.  I'm not sure it's so much that the bodies are "bouncing", but it's more than likely the other forces that are at resolving.  In some cases I'm trying to emulate a sticky type surface in which the object would just cling and stop, but I suppose that would take a bit of manipulation to accomplish.  I've already written Stop() functions in the wrapper for the engine, so this shouldn't be much of a problem if I utilize that.

One thing I've noticed working with this engine is that it's kind of hard to get a balance between all of the values.  It would be nice to have some sort of cheat sheet or template settings for different types of effects.  Although I suppose we can see those in the demos, but it's kind of a hassle flipping through the various classes to find what we're looking for.  Maybe I'll put one together and post it since I'll be doing so for my engine anyway.

Coordinator
Nov 24, 2009 at 3:41 PM

If you want separation but no reaction you can use the Separation property on the Contacts given to you in the OnCollision delegate. (in the ContactsList)

It is the amount of penetration the two objects has. In other words, the amount you need to separate them along the normal of the contact point.