Ray length bug?

It seems to be a length calculation bug.
The length value between two vectors is correct(1.414), but give it to a Ray function as the length parameter, i get a longer length. The latest Babylon version is the same.

PG: https://www.babylonjs-playground.com/#ZHDBJ#130

This is because the helper scales the direction given by the length given and so the helper line will only be of the given length if the direction is a unit vector, eg

This use of a unit vector in the helper could be forced by changing to

this._renderPoints = [ray.origin, ray.origin.add(ray.direction.clone().normalize().scale(ray.length))];

However as this would be a breaking change we need to ask @Deltakosh whether this should be done or a note about the consequences for the ray helper of not using of unit vector for direction when constructing the ray should be put in the documentation.

3 Likes

Ok, i get it.
Thanks for your reply. :metal:

1 Like