Ray + trianglepick: what is "distance"?

to handle fast moving objects, i use findPick using a ray from the objects old position to its new position. if there are objects between the new and old one, i get a few pickresults and move the object back to the intersection nearest to its old position.

i thought i should use the pickresult with the smallest distance and move my objects to the pickresults intersectionspoint, but this way, sometimes i get teleported through my entire map.

isn't distance the distance between the ray's origin and the intersection point? if not, what distance makes sense here?

i'll see if i can properly reproduce the error using my model. if i can, i'll upload the model + code somewhere. just be patient.

isn't distance the distance between the ray's origin and the intersection point

I believe it is... Maybe add a printout statement for the distance you get. This way you can be sure that intersection reports the correct distance.

something is odd then. which coordinates should i use and expect when raypicking? the world ones? the local ones of the node i'm calling findPick on?

My spider senses are telling me that one should go for world coordinates.

sometimes the distance is infinity and the intersectionpoint is 0,0,0

what does that mean?

and about that distance again:

this is clearly unclear. the distance is kind of right, i’m standing right in front of a wall, but the intersectionpoint is at a wall far, far away.

Does it say it will give you intersections in order? Maybe they are not sorted.

setCheckDistance need to be set to true on the collision results.

it is. otherwise, distance would be 0, and the intersectionspoint wouldn't be set. and even if the sorting would be wrong, the distance and intersectionpoint are in the same pickresult

Curious…  Is there anyway you could make a test out of this?

Would be nice to have a test… (unit test anyone?) so it's not a random 1.00001 entry :slight_smile: