I'm currently trying to setup "sticky" behavior in my engine and thus far I've opted for using generic6dof constraints to make the objects stick. So I check the contact points each frame and when all the conditions for an object to stick occur I get the local coordinates for each object in the said collision of where the collision occured. I always loop through all contact points in the manifold and pick the contact point with the deepest penetration and use the local space coordinates for that contact point to create the constraint.
Now...sometimes (about 50% of the time) the coordinates I pull out of the contact point is just plain wrong. When this happens it'll set the local point for one or both of the bodies to a location anywhere from 50 to 100 units off from where the actual object is when the object is only ~20 units in all dimensions.
For clarity...lets say one object is resting at origin, it's size is "20,20,30". I throw another object about the size of "15,20,15" at it and it's set to stick to the first object it collides with. When I throw the object from the negative X direction instead of the contact point being something logical like "-10,2.5,0", about half of the time it'll report the location to be "50,-20,0", which of course sends the thrown object to some random point on the screen where it floats in mid-air.
Why are these contact points seeming to mis-report the point of the collision?
Contact points inaccurate
-
- Posts: 171
- Joined: Sun Jan 17, 2010 4:47 am
Re: Contact points inaccurate
I've found a workaround for this issue for now. I have no idea why these contact points are being generated when information for them isn't ready, or why the data on the manifold point isn't zero'd out at the very least to make it obvious it's un-initialized. But for now I'm checking the applied impulse for each manifold point and discarding it as usable if the applied impulse is zero, as that seems to be the case for every invalid manifold point.