Raycast 3d not detecting curved section of trimesh

Godot Version

Godot v4.7.stable - Windows 11 (build 26200) - Multi-window, 2 monitors - Direct3D 12 (Forward+) - dedicated Intel(R) Graphics (Intel Corporation; 32.0.101.8724) - Intel(R) Core™ Ultra 5 225 (10 threads) - 15.40 GiB memory - WASAPI (96000 Hz, Stereo/mono)

Question

I’m trying to make a CAD/3d model style camera. To rotate around the point the mouse is on, I need to raycast from the mouse to the object to get the center of rotation. The raycast is having trouble detecting the curved part of the model that has smaller sections of the trimesh.

The model was imported from onshape as gtlf, and I added collision using a staticbody trimesh on the import settings. Here’s how I cast the ray if you need it:

var from: Vector3 = camera.project_ray_origin(get_viewport().get_mouse_position())
var to: Vector3 = from + camera.project_ray_normal(get_viewport().get_mouse_position()) * RAY_LENGTH
var query := PhysicsRayQueryParameters3D.create(from, to)
raycast_result = get_world_3d().direct_space_state.intersect_ray(query)

And the whole project if you want to check it out for yourself:

What happens if you enable backface_collision for the collider shape?

Also, what happens if you set shape’s margin to 0?

I assume you mean the collision shape for the object. Setting margin to 0 did nothing with and without backface_collision. backface_collision made it seem like the curve wasnt event there. When I rotated so the main part of the object behind the curve, it would hit the object behind the curve

It only has trouble on those small sections on the curve. All of the bigger sections detect perfectly fine

Those triangles are really really small. What happens if you scale the mesh up by an order of magnitude?

If I try to scale using any of the transforms doesnt work. However, reimporting with a higher root scale (10.0) detects the curve

Scale the mesh up in your 3d modelling app and use that. This size of triangles may be sufficiently small for floating point accuracy and numerical tolerance of the physics engine to come into play.

You’ll notice that your original small mesh cannot even be selected in the Godot 3d viewport if you click on the curved part.