PhysicsShapeQuery sometimes ignores CSG shapes

Godot Version

v4.5.1.stable.steam [f62fdbde1]

Question

Im trying to make random platforms in the sky with CSGBoxes, i dont want to create platforms that touch another platforms so i use PhysicsShapeQueryParameters3D to detect if new platform would collide with another, but for some reason sometimes it doesnt register collision with CSGBoxes at all, giving me empty result.
get_world_3d().direct_space_state.intersect_shape(shape_query_params) is the method i use.
I update shape size and position before this step

something like this

query_shape.size = new_size
query_params.transform = Transform3D.IDENTITY.translated((begin_point+end_point)/2)
get_world_3d()…

To visualize result i put MeshInstance in that same place with same parameters (size, position)

indicator.global_transform = query_params.transform
indicator.mesh.size = query_params.shape.size

To debug this, i place platform on the next step if previous result was “not collided”

video

However, as i said, sometimes it does not register collision with some of CSG

Make sure that collision is enabled for csg nodes.

It is enabled

For script-created csg nodes as well?

Yes

continious testing demo

I added a check before platform is placing with another query intersect_shape, sometimes it does help, but it keep skips that particular platform on the top, idk why

Btw, i do not use CSGCombiner for CSG nodes, %Combiner is a regualr Node3D

UPD: Bug seems persistent with all Physics Engine options

Please try it yourself

TAB - lock/unlock mouse
F - next step (to generate platform)
WASD/SPACE/SHIFT - move

Could be Jolt. What happens if you switch to Godot Physics?

Same with ALL options, GodotPhysics3D, Jolt and Default (which i believe is Jolt?)

I hope i just did something wrong but right now i dont have time to check that

Seems like it’s a godot bug after all.

The problem is, i dont know how to explain that on github…

Try to make a minimal reproduction project, simpler than what you have now. Maybe strip it to only 2 colliders whose boxes can be adjusted via input, and try to determine if there are specific positions/relations where the problem happens.

The problem looks different between physics engines though. With Jolt, the intersection results contain multiple entries for the same collider, which is quite weird, and sometimes they don’t report any intersections. Godot’s physics appears to more stable, it reports correctly in most cases but produces some misses as well.

I haven’t checked for eventual bugs in your code.