Page 1 of 1

raytest from inside of a collision shape

Posted: Mon Jul 27, 2015 5:21 pm
by hiro
Hi all,

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()));
	}


Re: raytest from inside of a collision shape

Posted: Mon Aug 03, 2015 9:19 pm
by benelot
So is that a statement or a question? I might experience something similar. I am trying to raytest from the center of mass inside of the shape in the direction of a certain direction, but I never get a hit. Is that what you are experiencing?

Re: raytest from inside of a collision shape

Posted: Fri Aug 07, 2015 12:18 pm
by benelot
I have the same experience as you and I found that there is a flag called btTriangleRaycastCallback::kF_FilterBackfaces;.

I thought probably this is enabled by default and therefore I tried to remove the flag, but this does not make a difference.

Code: Select all

	rayCallback.m_flags &= ~btTriangleRaycastCallback::kF_FilterBackfaces;
Does anybody know why?

Re: raytest from inside of a collision shape

Posted: Wed Sep 02, 2015 9:38 am
by hiro
Hi all,

I also tried to invert faces for raytest but didin't work well.
Only solution so far worked well is just ray test from the outside of the shape.

Thanks for your comments!