Changing how physics is sent and received
by Ken Pajala · in Torque Game Builder · 02/06/2008 (7:35 pm) · 4 replies
I have a slight issue with the way collision responses are handled.
Here's what I'm trying to do. I have two types of objects, Bubbles and Photons. When two Bubbles collide they bounce off each other. When a Photon collides with a Bubble, it bounces off, leaving the Bubble unaffected.
For the Bubble-Bubble collisions, I need to set things up like this:
That shouldn't happen. I know the Bubble sends the collision, but once the collision has occurred, the physics is a completely separate issue. I would propose that a physical reaction can only happen when one participant is set to Send Physics and the other is set to Receive Physics. It doesn't matter which participant Sent the original collision.
So, a reaction can only happen if the sender and receiver agree:
Change:
Here's what I'm trying to do. I have two types of objects, Bubbles and Photons. When two Bubbles collide they bounce off each other. When a Photon collides with a Bubble, it bounces off, leaving the Bubble unaffected.
For the Bubble-Bubble collisions, I need to set things up like this:
%bubble.setCollisionActive (true, true); %bubble.setCollisionPhysics (true, true);For the Photon-Bubble collisions, the only way I see to set things up that makes sense is this:
%photon.setCollisionActive (false, true); %photon.setCollisionPhysics (false, true);To me, this means that the Photons do not send any physics, so that anything that hits them should not react in any way. But, when the collision Bubble(sender)-->Photon(receiver) happens, the Bubble still responds to the collision and bounces off the Photon.
That shouldn't happen. I know the Bubble sends the collision, but once the collision has occurred, the physics is a completely separate issue. I would propose that a physical reaction can only happen when one participant is set to Send Physics and the other is set to Receive Physics. It doesn't matter which participant Sent the original collision.
So, a reaction can only happen if the sender and receiver agree:
// if you want %two to react: %one.setCollisionPhysics (true, xxx); %two.setCollisionPhysics (xxx, true); // if you want %one to react: %one.setCollisionPhysics (xxx, true); %two.setCollisionPhysics (true, xxx); // if you want both to react: %one.setCollisionPhysics (true, true); %two.setCollisionPhysics (true, true);The change is a relatively minor one to processCollisionStatus() in t2dSceneObject.cc:
Change:
pCollisionStatus->mSrcSolve = pSrcObject->getCollisionPhysicsSend() && !pSrcObject->processIsMountedRigid(); pCollisionStatus->mDstSolve = pDstObject->getCollisionPhysicsReceive() && !pDstObject->processIsMountedRigid();to
pCollisionStatus->mSrcSolve = pSrcObject->getCollisionPhysicsReceive() && !pSrcObject->processIsMountedRigid() && pDstObject->getCollisionPhysicsSend(); pCollisionStatus->mDstSolve = pDstObject->getCollisionPhysicsReceive() && !pDstObject->processIsMountedRigid() && pSrcObject->getCollisionPhysicsSend();Does that make sense?
#2
02/15/2008 (7:13 am)
Not so much a question as an observation that it's possible to have more control over which collisions cause reactions. I suppose I am asking whether or not this would remove some functionality that I'm not aware of.
#3
I'd say that sounds like a great change.
If your bubbles need to react to each other, then they must both send and receive.
If photons need to reach to bubbles, but bubbles shouldn't react to photons, then photons must must receive but not send.
But an issue that still seems unsolvable...
What if your photons needed to react to each other, AND react to bubbles, just not have bubbles react to photons '-) For photons to react to each other they must send and receive, but that means they will also cause bubbles to react to them!
In some situations it seems like more control than is available is needed. Like maybe a physics send MASK and a physics receive MASK?
03/22/2008 (1:53 pm)
So if I understand you correctly, with this change, only the physics receiver in a collision has a physics response? I'd say that sounds like a great change.
If your bubbles need to react to each other, then they must both send and receive.
If photons need to reach to bubbles, but bubbles shouldn't react to photons, then photons must must receive but not send.
But an issue that still seems unsolvable...
What if your photons needed to react to each other, AND react to bubbles, just not have bubbles react to photons '-) For photons to react to each other they must send and receive, but that means they will also cause bubbles to react to them!
In some situations it seems like more control than is available is needed. Like maybe a physics send MASK and a physics receive MASK?
#4
03/22/2008 (5:33 pm)
Just handle the physics yourself in the collision callback then you have this freedom. don't see why the collision in this case would need the default physics as bounce off is a simple vector equation (reflection + a scaling with value bounciness or 1 - friction)
Torque Owner Kevin James
I have noticed that sometimes the collisions don't call the way one would expect. Is that what you are getting at?