I tried to raytest inside-out of a shape, but never worked from inside. Only worked from outside.
Using these points, I place other shapes so that they have exact contact points with the first shape.
Here is my setup and the code:
- Using openframeworks bullet physics addson openframeworks bullet physics addson
- made a rigidbody called "shape"
- made a btDiscreteDynamicsWorld called "world"
Code: Select all
btVector3 ray_from = shape->getCenterOfMassPosition() ; // center of mass of the shape called stones[0]
btVector3 ray_to = ray_from + btVector3(0, -100., 0); // ray to the top
btCollisionWorld::AllHitsRayResultCallback allResults(ray_from, ray_to);
world->rayTest(ray_from, ray_to, allResults);
for (int i = 0; i < allResults.m_hitFractions.size(); i++)
{
btVector3 p = ray_from.lerp(ray_to, allResults.m_hitFractions[i]);
ray_all_results.push_back(new btVector3(p.getX(), p.getY(), p.getZ()));
}