Box stays on edge/rotates up to be on corner.
Posted: Mon Mar 19, 2007 6:21 pm
I have a simple, handmade physics code.
Basically I have a concave heightfield for the ground, and box that I'm trying to drop on it.
For simplicities sake, I decided only the corners of the box were substainatal. I binary search through time in order to find the collision point(s).
Once I do, I go through each corner, and, if it is within a certain distance of the ground it is directly over, I compute the following
I sum these over any corners that are touching an take the average. This works a good potion of the time, but often the box rotates up to rest on one corner, or less frequently on an edge.
Any ideas?[/i][/code]
Basically I have a concave heightfield for the ground, and box that I'm trying to drop on it.
For simplicities sake, I decided only the corners of the box were substainatal. I binary search through time in order to find the collision point(s).
Once I do, I go through each corner, and, if it is within a certain distance of the ground it is directly over, I compute the following
Code: Select all
ComponentOfLinearVelocityFromAngular = AngularVelocity cross ArmInWorldSpace
LinearVelocity = PureLinearVelocity + ComponentOfLinearVelocityFromAngular
NormalVelocity = LinearSpeed projected onto Normal.
TangentalVelocity = LinearVelocity - NormalVelocity
CorrectionVelocity = -1.5 * NormalVelocity;
CorrectionTorque = ArmInWorldSpace cross CorrectionVelocity
Any ideas?[/i][/code]