Jump to content

pickWithRay behaves wrong when using boundingBoxes


Steffen
 Share

Recommended Posts

Hi,

when using

var hitInfo = scene.pickWithRay(ray, null, true);

I would expect that the ray only checks the boundingboxes and not the mesh. So if I import an "open package" where the ray can go through the object without collision, I want to check only if the ray hits the boundingbox, but this doesn't seem to work.

Here is a playground: http://www.babylonjs-playground.com/#5PMLFP

Thanks,

Steffen

Link to comment
Share on other sites

Hello,
You'll need mesh.boundingBox.isPickable = false, but I do not think it's available.
You can cheat by folding a box set it in wireframe and  you can deactivate the property box.isPickable = false?

I do not know if that can help you?

Good luck in your search.

Link to comment
Share on other sites

I don't think I understand you correctly...

If you set the "isPickable" param to "false", the ray will ignore the mesh. 

See line 50: http://www.babylonjs-playground.com/#5PMLFP#1

 

EDIT:

Solved. The comment in the doc for pick/pickWithRay is very irritating. Or it is just me and @aWeirdo (do you have a workaround?).

Quote from @Deltakosh

Quote

The fast check using bounding boxes to invalidate candidate. Not to validate them.

Edited by Steffen
solved...
Link to comment
Share on other sites

Hi @Steffen 

The picking doesn't pick by boundingboxes.

I ended up doing a workaround thus far, a prototype for abstractMesh which adds a "picking Box" (just a BABYLON.Mesh.CreateBox) the size of the mesh's bounding box, parented to the mesh, only pickingBox has isPickable and then a visibility of 0.001 or so. 

And on picking it's just pickedMesh.parent to get the actual mesh.

I hope it makes sense.

Link to comment
Share on other sites

Hi guys.  In another thread, some folks are/were playing with picking... for drag/drop usage.  Here's the latest PG:

https://www.babylonjs-playground.com/#WWCK0#70

(For some reason, this PG requires ONE MORE click of the RUN button, before it is normal).

In lines 3-67, we "installed" (hijacked) the abstract mesh intersects() function (used for picking)... into the playground.

Then we added many console.logs to it... to learn and test things.  Most important... line 53... which tells (at console) the name of mesh for each pickedPoint that happens during a single pointerDown pick.

Open console, then do a single pick on a "barrel".  It looks like about 4-6 picks happen for one pointerDown. 

Even the add-on "elli" sphere (mesh.ellipsoidMesh) is sometimes picked (if you pick high enough on barrel)... even though it is set isPickable = false in line 86. 

Why so many pickedPoints for a single pick?  Perhaps... do this forum search for 'multi-picks'.  I believe multi-pick returns an array of all the pickedPoints (including which mesh was hit for each pick-point).  It might be worth investigating.  Perhaps a predicate/conditional could be used.   Maybe multipick code could be modified to ONLY return pick-hits from a certain "class" or "tag-group".   (variable-criteria filtering). 

You could also use mesh.metadata as an "Allow this mesh to be included in multi-pick returns?" -flag.  Then hijack (borrow from here) the multi-pick code into your home project, and modify it... to ONLY include mesh whose .metadata = true, or whose .metadata = { allowReturnInMultiPicks: true, whatever: whatever, etc: etc }

Just some goofy Wingnut ideas.  :)  Be well, guys.

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...