godot
godot copied to clipboard
Fix floor snapping for CSG shapes with collision
This fixes https://github.com/godotengine/godot/issues/89832
I found that the cause of this behaviour was that the CSG Shapes with collision enabled were not being included in the exclude list for the raycast that finds the object/floor underneath being placed. This is because they do not use PhysicsBody3D but instead use PhysicsServer3D directly. At certain sizes, specifically small sizes, the raycast can then hit the object that is meant to be being placed causing it to be pushed up.
To fix this I have done the following:
- Add get_collision_rid function to CSGShape3D.
- Add additional checks when gathering nodes to exclude from raycast made when using the Snap Object to Floor feature of the 3D editor so that it finds and includes CSGShape3Ds that have collision enabled.
I think this is right but can't code review for the next few days.
After having another look at this I've added the method binding + doc description so this new CSGShape3D function is accessible from the scripting interface, just as get_rid is for CollisionObject3D derived classes.