Hello all,
is there a way to evaluate intersection between plane mesh and ground mesh? It does not work for me. Here my PG, iirc it did in the past, else i must have missed something.
Hello all,
is there a way to evaluate intersection between plane mesh and ground mesh? It does not work for me. Here my PG, iirc it did in the past, else i must have missed something.
Hmmm I tried checking your PG in 4.2.1 and it didnāt work either, but that makes sense, because intersectsMesh checks the bounding box (either object aligned or axis aligned), and in any of these cases the groundās BB will be intersecting with the planeās BB. If the collider wasnāt a plane moveWithCollisions could be an alternative Camera Collisions | Babylon.js Documentation (babylonjs.com), but the plane doesnāt work well with an ellipsoid collision shapeā¦
For this case youād probably have to check the triangle-plane intersection with all of the groundmapās triangles, or do some kind of partial occlusion query⦠@Evgeni_Popov any ideas?
I tried triangle-plane intersection and got closer to the solution. The box & plane works, but not plane & heightmapGround intersection. Maybe I have to additionally consider normal/rotation of triangles?
May be ask @pirateJC The solution could be around using a cube for the heightmap.
Something around his hex video series and the other work he did on procedural terrain with raw textures? And then may be not, but I thought it was worth asking
I am not sure if this is the right thing, because I would love to be able to compare triangles of mesh-mesh intersection, that could be used for any mesh intersections.
Interesting question here. Iām sure youāve already seen this, but if you were trying to simply detect when meshes intersect, this document should have everything you need: Mesh Intersections | Babylon.js Documentation
However, if I understand correctly, youāre trying to not only evaluate if a mesh is intersecting another mesh, but what specific triangles in the given meshes are intersecting?
Letās bring in @Evgeni_Popov here who might be able to help guide us.
You got it, I want to know if triangle-triangle intersection happened. Intersection of OBB and AABB wonāt be precise enough to determine if the plane and ground with height intersects i.e. if there are hills. As far as I can tell it does always intersect because bounding box of ground uses max height.
I think mesh-mesh intersection on triangle level would be ānice to haveā for the whole community, not only in case you want to place a building site.
Edit: Thanks to this PG of @Raggar, I got it:
Adapted PG for Plane-Ground:
I canāt take credit for that PG, unfortunately
Yes. Let me upvote this one
In fine, your solution works nicely but itās a lot of lines of code for something that (in my opinion) could be expected as a ābuilt-inā feature (as you say ānice to haveā). In other words, I donāt think it will be the only and last time this problem will occur. Actually, Iām gonna soak this right away Although in my use case, I can (I am currently) deal(ing) with the less precise method. Though, itās good to know that thereās this alternative
Yeah, I guess I could optimize it for my use case too i.e. only compare triangles inside 3D plane. But it actually was just because I was curious how to determine intersection on triangle level.
In the current case it allows optimization of bounding boxes. To reduce code I use javascript and remove visibilty features. Maybe someone is able to implement it? Or are you satisfied with a reduced version?
I wonāt have use of it just now. As I said, I can do with the less precise version. I would have liked an āin betweenā solution making a more precise bounding box from something like faces. I have the feeling that even making check with two simple bounding boxes will be less costly on performance. Currently Iām using this technique precisely for perf gain. Iām clearing āinner spacesā (rooms) based on cam intersect. My only problem being that my rooms arenāt just square. But then, I was also thinking about other use cases (and may be future projects of mine) and thought this would indeed be a ānice to haveā. I guess at this point, if somebody wants to put additional efforts into it, thereās already a base to work from now. Makes it more engaging. Weāll see what eventually might come out of it in the future.
Anyways, thx a lot for sharing and have a great day