# Mesh.intersectsPoint and bounding box of plane in debug layer

## Recommended Posts

Hey guys,

I've just noticed that the bounding box of a plane in the debug layer and the bounding box which is taken into account when computing mesh intersection with a point are inconsistent.

Here is the playground example (just check the bounding boxes checkbox). So one of them should be fixed...

Upd:

Another problem is when the plane's bounding box does fit the bounding box of debug layer, there is no intersection at all (that's an obvious problem because of plane thickness I think).

Here is the playground sample.

Maybe the solution is to give a minimal bounding box thickness of BABYLON.Epsilon.

##### Share on other sites

Well, I'm a new but not that new   I've seen this tutorial dozens of times.

See, the cases are a bit different. The tutorial covers an intersection of a sphere with a plane (both precise and not) and an intersection of a sphere with a point.

In both cases there is no any problem - the bounding box of a sphere is always the same.

In my case there is an intersection of a plane with a point. And here is the thing: the intersection of a mesh with a point is always non precise (with a non-scaled bounding box). However in debug layer still appears the precise (scaled) bounding box. Which, in turn, may be very confusing. It took me a couple of hours to understand why do I get an intersection when in the debug layer there is a huge distance between my point and the bounding box of the plane.

Also, there is still the second problem I've described in the first post.

##### Share on other sites

I find both of your examples very interesting :-)

The first one - I believe you are right, the debug layer actually shows the precise bounding box but the boundries are different during the intersectsPoint inspection.

As the 2nd - I am not sure this is wrong. A plane is just this - very thin, and the y of the point intersected is never 0, due to the cosine calculation. so it never really intersects...

##### Share on other sites

Actually intersectsPoint use AABB (Axis aligned bounding box) for performance reason and that's why I linked the demo with various version of bounding boxes.

##### Share on other sites

So maybe it worth to add a precise computation as an option? Just like in the case of the mesh intersection? Also, it maybe useful to let the user define the minimal boundaries (thickness) of the bounding box. I'm not sure this is a problem (maybe it should be this way) but currently there is no way you can get a plane & point intersection.

##### Share on other sites

Well, there is a delta

BABYLON.Engine.Epsilon

I think that the inspection in the intersectsPoint (in the bounding box inspection) is simply other way around. Have a look here - http://www.babylonjs-playground.com/#1JLKCH#2 , changing the epsilon to negative works. (line 31).

@DK, what do you think? var delta in https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Culling/babylon.BoundingBox.ts#L99 should be -Epsilon ?

Right!

##### Share on other sites

fix coming up for 2.1

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.