godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.85k stars 19.44k forks source link

Collision wireframes of CSGBox3D doesn't hide in the scene view when gizmos are hidden #87919

Open kebabskal opened 5 months ago

kebabskal commented 5 months ago

Tested versions

Reproducible in Godot v4.2.1.stable and v4.3 custom build

System information

Godot v4.2.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 (NVIDIA; 31.0.15.4633) - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)

Issue description

When unchecking View Gizmos in the Perspective menu in the Editor 3D Scene collision wireframes for CSG nodes doesn't get hidden. This is inconsistent with for example CollisionShape3D's, which properly gets hidden.

image

Hiding the node Hiding the node makes the collider disappear, but if you open another scene and then return the render mesh is hidden but the collision mesh is again showing.

image

Why is this an issue? This gets visually noisy and makes tuning the look of my game difficult.

image

Steps to reproduce

  1. Create a 3D Scene
  2. Add a CSGBox3D and turn Collisions On
  3. Toggle "View Gizmos" in the Perspective menu in the Scene View
  4. Observe how CSG Collision Wireframes don't get hidden like they would with CollisionShape3D

Minimal reproduction project (MRP)

csg-wireframe-issue-reproduction-project.zip

smix8 commented 5 months ago

The normal node debug shapes for collisions are part of CollisionObject3D::_update_shape_data(). The CSG debug is part of CSGShape3D::_update_debug_collision_shape().

That the gizmo toggles do nothing is nearly always a sign of a debug that is done by servers directly as the gizmos only react on nodes that are controlled by an editor gizmo that toggles both material and visibility. If those do not exist those gizmo toggles do nothing.

haifromkai commented 4 months ago

I'm also using Godot 4.2.1.stable.mono and I can't seem to toggle off the blue wireframes for my CSGBox3D Nodes when looking from the viewport.

image

kebabskal commented 4 months ago

I've started looking into this. I ended up just commenting out some code locally, but since there seems to be atleast one other person bothered by this, I'll drop my findings below:

Where are the collision shapes drawn?

CSGShape3D::_update_debug_collision_shape() seems to be where the shapes are submitted to be drawn. It asks if it should from CSGShape3D::_is_debug_collision_shape_visible() which always returns true in the editor.

If I comment out the contents of CSGShape3D::_update_debug_collision_shape() the blue collision wireframes goes away. Gray wireframes are still shown when "Show Gizmos" is toggled on. I assume these are the regular "draw" shapes.

I don't know if the draw and collision shapes are always going to be the same, and if so, would there ever be a use for drawing the collisions wires? One version would be to just draw them once, in gray if collision is off and in blue if on.

I'm not sure if it's also somehow affected by the fact that only root CSG shapes are drawn etc.

Reading the Show Gizmos state

While the state of the Show Gizmos checkbox is somehow saved in the menu there doesn't seem to be good central place to query for it without having a reference to the actual popup menu. Instead, toggling it seems to directly change a culling mask on the viewport camera through camera->set_cull_mask(layers).

I'll keep looking once I have a bit more time.

haifromkai commented 4 months ago

I appreciate you sharing what you've found so far, I'll try out the commenting out method when I get the chance to!