raytest from inside of a collision shape

Post Reply
hiro
Posts: 2
Joined: Mon Jul 27, 2015 5:01 pm

raytest from inside of a collision shape

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

benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: raytest from inside of a collision shape

Post 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?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: raytest from inside of a collision shape

Post 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?
Last edited by benelot on Fri Nov 20, 2015 1:24 pm, edited 1 time in total.
hiro
Posts: 2
Joined: Mon Jul 27, 2015 5:01 pm

Re: raytest from inside of a collision shape

Post 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!
Post Reply