
didac
Members-
Posts
7 -
Joined
-
Last visited
Everything posted by didac
-
solved Mesh collisions only horizontal movement
didac replied to didac's topic in Questions & Answers
Hi timetocode, this was exactly what I was looking for! If I understand it correctly, it is exactly what I was doing, but instead of computing the WoldMatrix as a part of the rendering, doing it directly, without all the overhead of the rendering, and without the (small) fraction of time where the object is intersecting. Thank you very much. -
solved Mesh collisions only horizontal movement
didac replied to didac's topic in Questions & Answers
I don't know why, without the scene.render(), and AFTER moving the position, the intersect() check does NOT detect the intersection. Maybe the intersect() needs the scene to be rendered work? Or probably the render() activates something that is not activated without it. If you comment the scene.render() line in https://playground.babylonjs.com/#1UK40Z#7 it clearly stops working. Probably you have a better intuition of the situation. In any case now it works correctly (maybe adding an overhead that is not completely necessary, but that I don't know how to avoid). Thanks for the help! -
solved Mesh collisions only horizontal movement
didac replied to didac's topic in Questions & Answers
Well, I got something working. I don't know if its very inefficient but it works alright. It basically consists in rendering the scene outside of the rendering loop to check the intersections, and if there are intersections, I undo the operation and render again (without rendering again it still works but it glitches a little bit). https://playground.babylonjs.com/#1UK40Z#7 -
solved Mesh collisions only horizontal movement
didac replied to didac's topic in Questions & Answers
Hi Wingnut, You got the issue correctly. Thanks a lot for the comment and the ideas. Certainly backing up the mesh 3-5 diffs is not ideal, because if that is the case, then why not 6 or 7 diffs? I'll give it another try and let's see what I get. -
solved Mesh collisions only horizontal movement
didac replied to didac's topic in Questions & Answers
I will rephrase my question: if I am moving an object with the mouse, I have the position before the movement, and I have the increment given by the mouse. If BEFORE the movement the two objects are not intersecting, but AFTER applying the increment with mesh.position.addInPlace(increment) they are intersecting, how can I avoid doing the movement BEFORE actually doing it? I had the idea of checking the intersection after the movement, and if they intersect, subtract the increment and go to the original position. However, it looks like when I increase the position and then do the intersects check, the intersects() method does not detect the intersection just in the moment, but it has to do the rendering or something, and THEN it detects the intersection, when I have no longer control on it. Do you have any idea on how to deal with it? (Playground: https://playground.babylonjs.com/#1UK40Z#2, please move the purple object towards the red one. The purple object turns white when it contacts the red one, and it cannot move back again because the system detects that it is intersecting the red one) Thanks a lot! Edit: is it a good idea to render before checking the intersect? (added the line 149 in https://playground.babylonjs.com/#1UK40Z#3) -
solved Mesh collisions only horizontal movement
didac replied to didac's topic in Questions & Answers
Thanks Deltakosh! Is it possible to check the intersects before moving the object? -
Hi, I would like to create an environment with several objects (in the playground, 2 objects) that cannot be at the same position at the same time (cannot be superimposed). I used the moveWithCollisions method for the Mesh objects, and while it works as expected, when two objects collide and the ellipsoids around them are not identical in size, one of the objects goes to the top or to the bottom of the other. I would like for them to just stay in the same vertical position, and if they collide, simply prevent them from moving, not moving to the top or to the bottom of the other object. Is there any thing you recommend? Playground: https://playground.babylonjs.com/#1UK40Z If you move the red object towards the purple one, when they contact, the red object moves to the top of the purple one, and I would like them to stay one next to the other. Thanks!