DylanD Posted June 28, 2018 Share Posted June 28, 2018 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. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 28, 2018 Share Posted June 28, 2018 let's see how it goes with a PG Quote Link to comment Share on other sites More sharing options...
DylanD Posted June 29, 2018 Author Share Posted June 29, 2018 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 Quote Link to comment Share on other sites More sharing options...
DylanD Posted June 29, 2018 Author Share Posted June 29, 2018 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 29, 2018 Share Posted June 29, 2018 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 Quote Link to comment Share on other sites More sharing options...
DylanD Posted June 29, 2018 Author Share Posted June 29, 2018 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 Thanks anyway though! Quote Link to comment Share on other sites More sharing options...
Guest Posted June 29, 2018 Share Posted June 29, 2018 No waste of time! it is important to talk about all of that And I'm happy to be your echo chamber DylanD 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted June 30, 2018 Share Posted June 30, 2018 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 DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted July 3, 2018 Author Share Posted July 3, 2018 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 Quote Link to comment Share on other sites More sharing options...
DylanD Posted July 4, 2018 Author Share Posted July 4, 2018 Hey I was wondering does intersecting mesh use bounding box or the actual mesh for the check, because it seems that it hits just a bit before the meshes actually intersect, idk if it just me or my eyes playing tricks on me... @Deltakosh Quote Link to comment Share on other sites More sharing options...
Guest Posted July 5, 2018 Share Posted July 5, 2018 IntersectsMesh uses bounding box and bounding sphere for intersection evaluation Quote Link to comment Share on other sites More sharing options...
DylanD Posted July 24, 2018 Author Share Posted July 24, 2018 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! Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 24, 2018 Share Posted July 24, 2018 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? Quote Link to comment Share on other sites More sharing options...
DylanD Posted July 24, 2018 Author Share Posted July 24, 2018 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.