I draw a simple line with Tube. When the rotation or position of this line changes, the collision area takes up too much space. I am facing this issue with intersectsMesh. When I check with intersectsMesh it naturally crashes everywhere. How can I solve this problem? Can you help me?
You can use intersectsMesh in the precise mode, which will orient the bounding box according to the object’s orientation Mesh Intersections | Babylon.js Documentation
Sorry but when I try this I fail. Could you please show me the pg I shared?
How are you trying to do this? Your pg isn’t using intersectsMesh.
I’m doing this in my own project. I created a pg with a code similar to the one you used.
Oh, I just saw how you built the tube, my apologies. If you create the tube in this way, its bounding box will be very big. It would be better to create it along one axis only, then rotate it, then you don’t even need the precise intersection: Tube as Line | Babylon.js Playground (babylonjs.com)
Thank you for your answer but in my system the line will not be in a single plane. I wish you were right
Unfortunately, I tried the information in this document but it doesn’t work.
You just need to create the line in one axis, then you can rotate it to lay along more than one axis If you create it along more than one axis then its bounding box will always cover more space
If different solutions were not mentioned in the documents, you would be right, but different solutions are mentioned in the babylonjs documents. Most importantly, intersectsMesh is said to be able to communicate directly with the mesh instead of the boundingbox. However, either the documents are wrong or there is a problem that we cannot see.
But this bounding box can be more or less precise, and that’s why we have our second parameter. In short, if this parameter is set to true (false by default), then the bounding box is closer to the mesh (OBB bounding type), but it’s a more costly calculation. Be aware that this type of bounding box is especially useful when your mesh is rotated to an angle.
The docs mention that the bounding box used in precise is closer to the mesh, not the mesh
I can’t believe that babylon is helpless in such a simple function and it makes me so sad. I’m sure babylon we were offering a solution to this but we can’t see it. Frankly, this is very sad.
@farukcelim this is an open source project so feel free to contribute improvments in this regard.
The main point is speeeeeeed, why are you trying to call into intersectsMesh ? what is your exact use case ? as there might be more efficient ways to do it. intersectsMesh relying on full meshes would be a perf hole in real time if used everywhere and it is rarely the appropriate solution.
Thanks for your explanation. You can be sure that I offer my best wishes to babylonjs, but I continue to do my best. You are correct in what you say about the problem. There may be a better solution and I’ve looked into those as well. What I want to do is; A line or a tube will symbolize connections between different points. While this is happening, I will be constantly updating the coordinates of things like line or tube that I use for connection. I can do all this. However, the problem begins when I check whether the tube (line, etc.) I use as the link icon has hit something. The control mechanism controls the tube’s delimiter instead of the tube’s mesh. The delimiter, on the other hand, exists in the form of a rectangle, unlike the tube that goes as a line when the tube’s coordinate changes. Thus, the limiter larger than the mesh of the tube is hit without hitting the tube. I hope I have conveyed the details correctly. Thanks for your interest in advance. Your ideas are very valuable to me.
In this case I think you could consider a casting a ray for each part of the tube or line as the tube could be assimilated to a line.
This should provide a rather fast and accurate solution without checking all the faces of both meshes.
Yes, I discovered ray casting myself. Not drawing with Path gives me problems but I’m still looking into it. Thanks for your recommendation. I’m curious about your opinions on Mr @Cedric and Mr @RaananW :).
If tube is composed of straight lines, I would compute the shortest distance from the object center the lines.
If the object to test is a sphere, then it becomes really easy to know if it intersects.