Jump to content

IntersectMesh Trouble Part 2


DylanD
 Share

Recommended Posts

Hey everyone, I'm at the end of my day here so I won't have playground for a bit.

But I was having problems with intersectMesh again,

So I know there are two type inaccurate and accurate, false and true in the function parameter.  But its seems with inaccurate I could have a whole extra of my object slip between the gap when it is intersecting which makes it look as though you never touched the other mesh, which you don't.  With accurate mode it seems to not catch enough, as in one of my meshes will glide across another with out having intersectsMesh catch it.  This is mostly problematic on my meshes with collision physics (cannonjs I mean), well to be more accurate when one of my meshes without physics collides with one that has physics, its seems to either catch it right away or not at all and let it slide over it.

My goal is to have a more accurate inaccurate one or a accurate one that won't let the meshes slide.  Im thinking I might just make a phantom mesh for the intersecting, not sure yet.

 

 

Again I will try to get a playground up asap.

Thanks, have a goodnight.

Link to comment
Share on other sites

13 hours ago, Deltakosh said:

let's see how it goes with a PG :)

Ok so here is playground one, this one demonstrates the two meshes don't actually need to be intersecting to make the intersects mesh true, and I understand that they're pretty close without touching but it should at least be able to recognize not intersect at all.  Anyway wait of the green cube to go below -1, the first run just shows what happens when the cube actually intersects the other cube.  You can play around with the x value of good cube after it move in the render loop, I can push it to about x= 1.25 but it only moves a little bit.  I believe this is AABB so I can understand it not being perfect, but wait till next time when I show the precision one...

 

Playground example of the non precision:  https://www.babylonjs-playground.com/#LJPRIN#9

Thanks for now :) 

Link to comment
Share on other sites

All right here is the playground that demonstrates my problem with precise intersectMesh.  So I have the green cube moving down and to the right with move with collision, since I don't want it going straight through the red cube, but when I do this I believe it keeps it from actually intersecting, I'm not really sure.

My way around this will be two make a different mesh and use one mesh for collision that is slightly smaller than the actual mesh I want to use for intersecting.

however that adds another fake box to my scene that I would rather not have.  Is there any way to get around this without have to create an extra box?  Am I doing something wrong?

This actually kind of solves it well but I'm still hoping for a better solution...

Playground example of precision: https://www.babylonjs-playground.com/#LJPRIN#10

Thanks

 

Link to comment
Share on other sites

1 hour ago, Deltakosh said:

For this one: https://www.babylonjs-playground.com/#LJPRIN#9 =>> This is like you said, AABB so not perfect but fast

 

I'm not sure to get the problem for the second PG, it seems to work for me. The gray cube starts moving when the green cube intersects with the red one

 

yea I was thinking about it and I think my problem is not so much with intersects mesh, but with move with collison and intersects mesh, because the collision is keeping the meshes from intersecting, so I guess my problem can only be fixed by making two meshes one smaller and invisible for collision and another that is bigger and for intersecting.

 

I guess I just needed an echo chamber to figure this one out.  Sorry for wasting time :D 

Thanks anyway though!

Link to comment
Share on other sites

16 hours ago, DylanD said:

but with move with collison and intersects mesh, because the collision is keeping the meshes from intersecting

You can also detect collisions.  You may end up not being generic enough to swap out Physics Engines, but here is a way with cannonJS:
https://www.babylonjs-playground.com/#NVS2YA

Link to comment
Share on other sites

On 6/30/2018 at 5:25 AM, brianzinn said:

You can also detect collisions.  You may end up not being generic enough to swap out Physics Engines, but here is a way with cannonJS:
https://www.babylonjs-playground.com/#NVS2YA

I actually might have been generic enough to use this, as I am already using the cannonJS library for some physics, however I figured out the way above and I'm not going to fix it unless its broken.  But thanks again @brianzinn :)

 

Link to comment
Share on other sites

  • 3 weeks later...

Hi there again @Deltakosh

I was wondering do you know if I used AABB to check if a large amount of meshes are close enough to another mesh then use the other more precise one to see if the ones that were close enough actually interect, would it help with performance? my game is steady around 50-60 fps(with some heavy spikes, down to 40 frames sometimes) and I want to reduce the amount of spikes and make it overall higher frame rate(59-60).

 

I don't fully understand how each one work exactly and from what I understand I think this would be a performance boost.

thanks!

Link to comment
Share on other sites

26 minutes ago, DylanD said:

then use the other more precise one to see if the ones that were close enough actually interect

The precise intersects AABB vs OBB.
https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1172

You can use short-circuit evaluation to force precise check, only if AABB finds an intersection...

goodCube.intersectsMesh(badCube, false) && goodCube.intersectsMesh(badCube, true)

What does that do to your FPS? What's going on in your game when FPS drops?

Link to comment
Share on other sites

27 minutes ago, brianzinn said:

The precise intersects AABB vs OBB.
https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1172

You can use short-circuit evaluation to force precise check, only if AABB finds an intersection...


goodCube.intersectsMesh(badCube, false) && goodCube.intersectsMesh(badCube, true)

What does that do to your FPS? What's going on in your game when FPS drops?

I have been testing it on a low-mid range mobile phone, so pretty much just performance of the phone itself.

I want to make the webapp usable on all device(or at least as many as possible).

Creating the scene is a huge spike, not that big of a deal though, something I think I can fix, or maybe just load all my scenes at the start...

Particle systems turning on causes a spike.

That is a really clean line! Nice! 

Im going to try it now!

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