iiceman Posted January 27, 2015 Share Posted January 27, 2015 Howdy, http://www.babylonjs-playground.com/#11DXRI This is the main problem from the other thread about moving with collisions. Ray casting just doesn't seem to work right as soon as the mesh is scaled (along the y axis?). This really seems like a bug to me ... or I am doing something horribly wrong here :-/ Can that be fixed somehow? Quote Link to comment Share on other sites More sharing options...
Temechon Posted January 28, 2015 Share Posted January 28, 2015 Hi, It's really weird because the pickedMesh is indeed the box... I've been trying to compute the mesh world matrix, but nothing seems to change. Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 28, 2015 Author Share Posted January 28, 2015 Yeah, weird, eh? I think I tried that, too. Well, it works if you reference the pickedMesh... but for pickedPoint to really get the point on the surface it's somehow messed up. Would be cool if you find a reason for that Thanks for the help! Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 28, 2015 Share Posted January 28, 2015 The problem is in the abstractMesh intersects function - line 837 :var worldDirection = BABYLON.Vector3.TransformNormal(direction, world);actually, the direction vector is already correct (And I believe,already in world coordinates, as it is being calculated using the actual distance between the points), this shouldn't be calculated. If you remove this line (or skip it in the debugger :-) ) everything works as expected. So, a quick fix would be removing all references to worldDirection and changing them to direction, or changing this line to:var worldDirection = direction;Which is kind'a redundant :-) As this is the first time this error appears, I am not sure this is a bug (well, it is, but is removing this line of code leaves everything else intact?). This requires further testing. Temechon 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 28, 2015 Share Posted January 28, 2015 Direction is coming from ray.direction so he is in local spacewe need to return it to global space hence the transofrmation with worldMatrix So I have a bug somewhere else I'll check this quickly! Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 28, 2015 Share Posted January 28, 2015 Isn't the ray being transformed to world coordinates in the pickWithRay function (actually inverted)?world.invertToRef(this._pickWithRayInverseMatrix);return Ray.Transform(ray, this._pickWithRayInverseMatrix);because the direction the the scaled case was actually 0,-2,0 and not the given 0,-1,0. This is why I thought it is in world coordinates. The direction variable is also being recalculated using the distance from the intersection function (which is correct) as a scale. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 28, 2015 Share Posted January 28, 2015 OK fixed it. For some reasons I added a normalize which obviously was not required Fixed with next push Wingnut and iiceman 2 Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 28, 2015 Author Share Posted January 28, 2015 SWEET! Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 29, 2015 Share Posted January 29, 2015 Nice anomaly/bug find, iicepuppy! And a darned good job investigating it... to determine it was scaling-related. And then a swell playground proving it (which now works fine). And thanks for the framework fix, DK! You guys rock! 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.