Ray casts on certain GridMap objects need to be much longer in order to hit the object. Recreating the issue seems to require:
A semi-complicated mesh (I was able to recreate the issue with a hemisphere mesh but not a cube)
The scale of the object to be set high (e.g. 100)
The "Apply MeshInstance Transforms" option to be selected when the mesh library is exported
When ray casts do hit, they appear to report the correct position, but need to be extremely long (e.g. 100m) in order to actually hit the object. The colliders otherwise seems to work fine for physics purposes, so the issue seems isolated to ray casting.
In this photo, the 3 cylinders are showing the ray cast distance for a set of RayCast3D nodes. They should all be hitting the object, but only the green one is:
Steps to reproduce
To create a mesh library with this issue, add a MeshInstance to a scene, set the mesh to something non-trivial (e.g. a sphere), and set the scale set to (100, 100, 100). Create a Trimesh Static Body on the mesh using the Mesh drop-down in the editor. Export the scene as a mesh library and make sure "Apply MeshInstanace Transforms" is checked. In a new scene, create a grid map with the exported mesh library and place one or more of the objects. Then perform any ray cast activity involving the grid map, either with the RayCast3D node or direct space state intersect_ray.
Godot version
4.0.1
System information
Windows 10, Vulkan, NVIDIA GeForce RTX 3060 Laptop GPU, Driver 528.24
Issue description
Ray casts on certain GridMap objects need to be much longer in order to hit the object. Recreating the issue seems to require:
When ray casts do hit, they appear to report the correct position, but need to be extremely long (e.g. 100m) in order to actually hit the object. The colliders otherwise seems to work fine for physics purposes, so the issue seems isolated to ray casting.
In this photo, the 3 cylinders are showing the ray cast distance for a set of RayCast3D nodes. They should all be hitting the object, but only the green one is:
Steps to reproduce
To create a mesh library with this issue, add a MeshInstance to a scene, set the mesh to something non-trivial (e.g. a sphere), and set the scale set to (100, 100, 100). Create a Trimesh Static Body on the mesh using the Mesh drop-down in the editor. Export the scene as a mesh library and make sure "Apply MeshInstanace Transforms" is checked. In a new scene, create a grid map with the exported mesh library and place one or more of the objects. Then perform any ray cast activity involving the grid map, either with the RayCast3D node or direct space state
intersect_ray
.Minimal reproduction project
grid-map-raycasts.zip