Collision problem: Piercing through solid body

atsakir

17-03-2006 09:10:35

Here's the problem:

I have a boat moving inside a river and I have a pair of "walls" along the banks of the river to limit the area of motion inside the "water" area. The "walls" have a TreeCollision body and the boat has a convex hull. I apply forces to the boat to make it move and rotate it manually (no torque). 99% of collisions work ok but if I have the boat facing the wall and fiddle a bit with the rotation while applying force forward (pushing the boat against the wall) I can get it to pierce the wall.

Is there a way I can make my wall "Super rigid" so it doesn't get pierced no matter how much the force? I have tried with different collision shapes for the boat and it happens with any shape. I have thought about assigning materials and friction but that would also affect "sliding" against the wall won't it?

here's a screenshot to better display the issue



Also, another thing: I have billboarded grass inside the water on which I will assign bounding cylinders for collision. Is setting material callbacks and friction enough to make the billboards slow down the boat when it passes through them?

walaber

17-03-2006 16:04:02

e boat to make it move and rotate it manually (no torque).

that's the problem. Newton cannot counter this because you are not using Torque to align the boat to it's desired direction. you need to apply a torque to turn the body to face the direction you want it to, and everything will be solved.

as for the grass, you cannot make Newton automatically "slow down" something that is passing through another body. you need to setup a collision callback so you can determine when collision happens (reject the collision after being notified of it), and then use that information to slow down the boat yourself (by damping the velocity, or applying a new drag force, etc).

atsakir

17-03-2006 16:57:05

Thanks, I figured it out by myself in the meantime, now I have another problem with the torque. I use this code i saw in a thread here to set the torque based on the orientation of the boat

Vector3 V2 = me->getOmega();
Vector3 V3 = orient*orient.normalise()* Vector3::UNIT_SCALE;
V3=V3*fl->mChar->rotation;
Vector3 rot ((V3 - V2) / me->getWorld()->getTimeStep());
rot = rot * 0.3f;

Vector3 torque = Vector3(0,rot.x,0) * mass;
me->addTorque(torque);


the problem is that this code is doesn't work properly. In particular, when the boat faces a certain direction (I guess when V3-V2=0) then no torque is applied and for a certain range of orientation (again, I guess V3-V2<0) torque is flipped.

How can I fix this so that the torque is always applied correctly regardless of the orientation of the boat?