Raycasts improvement

Hi everybody,

It could be great to have another boolean called for instance IgnoreOrigin on the pickWithRay and multipickwithRay functions to prevent hit on the origin of the ray when the origin is on a mesh that is already pickable. And I wonder if it could not be great to assign this boolean to true by default.

Boris

A ray doesn’t know its node origin, only its origin position. Unless I am missing something, this is not just a flag. Want to explain the use case with some code? This would be really great :slight_smile:

You’re right but when you pick points, you should be able to exclude the known origin of the ray if this origin is already on the surface of a pickable mesh.

but the data is not present at the time of generating the ray. you know this information, babylon has no way of knowing it. You can write a predicate to prevent the ray from selecting the mesh you are generating the ray from.

If you think I misunderstand (which happen more often that i’d like to admit), code example would be great!

I think you understand quite well but I’m surprised that we are not able to exclude the origin of the ray of the picked points result array.

If I know that my origin of the ray is on the surface of a pickable mesh, i’d want to be able to exclude it from the picked points.

so - a ray is a mathematical concept. It has an origin, which is a vector3, and a direction, another vector3. Along the way it will hit objects defined by the scene. To control these you have a few options - you can define a predicate when running the function to choose which meshes the scene should select from, or you could set the origin mesh to be not pickable for the duration of the test. This is on you as a dev, as babylon doesnt know the origin of the generated ray.

1 Like

Ok, i assumed that Babylon knew the origin of the ray but it is not the case…

Thanks for your answer.

It is possible, if we generate the ray. this is why i asked for a code sample to know exactly which ray you are referring to…

here’s a simple example I made to explain better what i’m looking for:

I still would use a predicate like https://playground.babylonjs.com/#C77SMH#10

2 Likes

Yep, that would be the best solution here.
There are different ways of solving this, but the predicate is the simplest one. An even better predicate, if possible, would be to check against the list of meshes you DO want to hit, especially if your scene has a lot of unrelated meshes.

1 Like