JohnK Posted July 10, 2015 Share Posted July 10, 2015 It all started when two meshes in the project I am doing would only show an intersection when they were overlapping by several units. Rather than try to explain the steps needed to reproduce what was happening in the project I thought I would see what happened in the playground. Now I must have done something stupid becausebox1.intersectsMesh(box0, false)always read true whatever the positions of box0 and box1. My trial is at http://www.babylonjs-playground.com/#MABFZ I have tried it with and without setting checkCollisions for the meshes and the scene. Waiting to kick myself when someone points out what I have done wrong. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 10, 2015 Share Posted July 10, 2015 This is because your test is done before the first render so world matrices are not computed yet. Here is the fix (just call computeWorldMatrix manually):http://www.babylonjs-playground.com/#MABFZ#1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 10, 2015 Author Share Posted July 10, 2015 Thank you DK. Need to keep remembering that code can be done before rendering and that calling computeWorldMatrix solves a lot of problems. Partially solves the project problem provided I do not scale the meshes, which I want to do. Will keep working on the code to see if I can work out where to adjust. Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted December 14, 2015 Share Posted December 14, 2015 Hey, I've just played a bit with intersectsMesh and I see something strange happening. http://www.babylonjs-playground.com/#11JY4O#1 Here we can move the objects with the mouse. The green cube is the "collider one". For the mesh currently moved (red sphere for instance), I record the current position if no intersection occur. When intersectMesh with the green box returns true, I don't record the current position, and instead I reposition the object to the latest safe position recorded (where no intersection previously occured). Since this position has been calculated as "safe" by intersectMesh, no intersection should be detected there. But while it works well the first two or three times, then intersection strangely occurs also in safe recorded positions.You can check the console to see locations logged. Am I doing something wrong, or intersectMesh doesn't give always same answer for two identical situations (maybe it is processed at the quantum level ) ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 14, 2015 Share Posted December 14, 2015 Hum..this works for me Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted December 15, 2015 Share Posted December 15, 2015 Oww, you're right, I tried in IE and Chrome and it works, the problem occurs only in Firefox. What a strange fact... how can this be possible ??! Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted December 21, 2015 Share Posted December 21, 2015 Hum..this works for me Hmm, in fact, after some new checks with Wingnut, it appears that it doesn't work so nice in IE and Chrome, after all.It works for the first moves, but after some tries the object stay stuck against the green box. Quote Link to comment Share on other sites More sharing options...
JohnK Posted December 22, 2015 Author Share Posted December 22, 2015 The technique that DK gave to me in this thread seems to alleviate the problem. Line added before checking intersectioncurrentMesh.computeWorldMatrix(true)However the jump from intersection to safe can be sometimes not smooth. Something to do with when the timing when rendering and intersect checking takes place???? http://www.babylonjs-playground.com/#11JY4O#6 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.