Jump to content

Mesh.intersectsPoint and bounding box of plane in debug layer


binyan
 Share

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.

Link to comment
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.

So, please re-read my first post. I hope now it's clearer  ;)

Link to comment
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... 

Link to comment
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.

Link to comment
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 ?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...