I’m having some issues with picking on a heightfield and thought maybe someone here could help me.
So, here is the situation:
-we created a mesh corresponding to a heightfield. We display it, there is no problem, no hole in, everything seems to be ok.
-we want to pick the exact altitude of this mesh/heightfield at one point. So we use what seems to me to be the standard collisions in panda.
-most time, it worked correctly, but in some case, the collision doesn’t work and my CollisionHandlerQueue is empty even if I’m sure the mesh and the ray should have collide.
Here is the code where I initialize the picking objects:
I have been suggested that maybe the issue come from the fact that the intersection point is just on a vertex or an edge of a triangle.
The fact that sometimes when a picking “failed” I get the same no-collision result when moving for a short distance on a direction and a correct result when moving in another direction even of a very small distance seems to confirm it.
Does it seems possible to you? Is it a normal/known situation?
I also noticed that I often got several collision results from a picking, all the result being in fact the same point.
If you can afford it, you might try doubling down on your terrain geometry- create a new mesh explicitly for collision (don’t actually render it), oversizing each triangle slightly so they overlap/intersect on points that were previously ambiguous vertices/edges. You’d start to see some slight inaccuracy around some edges, but you should be more likely to get ~some~ collision registering.
Now, I never use render at all. I though it was just a normal nodePath.
(I have created more than one nodePath and I change scene with, base.cam.node().setScene())
So at this time, render is just an empty NodePath.
Does render has something special when it come for CollisionTraverser ?
Or is there any other thing like setScene that I should use ?
If you don’t know whether you’re using base.cTrav, you’re not.
I assure you, though, that collisions do work correctly when not parented under render; we do that all the time. So something else must be going on in your case that only makes it appear to be working only when under render.
That’s really unnecessary, since it’s already done at collision check, when calculating the distance of the collision point to each of triangle edge.
It would be a good addition if the espilon is exposed to python. Even better if each collision solid has its own adjustable espilon, so a thin solid like a ray could use a larger one.