godotengine / godot

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

CSGSphere is broken in the `master` branch #47339

Closed mrjustaguy closed 3 years ago

mrjustaguy commented 3 years ago

Godot version:

Godot Engine v4.0.dev.custom_build.f121328ce

OS/device including version:

Windows 10, Not GPU related

Issue description:

The CSG Sphere that is Generated over the last month or so with the default 12-6 settings looks like a cylinder with a pair of cones at the ends, which isn't very spherical, and when Doing a CSG Subtract between 2 of them the cuts are VERY broken, and not at all like what the usual CSG issues give. The issue seems to be in the Generated Sphere Mesh, as a pair of CSGMeshes with sphere meshes work as expected.

Steps to reproduce: Preform operations with CSG Sphere in any build where the default CSG Sphere doesn't look anything near a sphere, so from late jan-early feb to now, and note at the very wierd cutting behaviors. The issue is probably with Wierd mix of interior and exterior triangles in the generated sphere mesh (CSGBox when inside it's invisible, not the case for CSGSphere)

Minimal reproduction project:

CSG.zip

louisVottero commented 3 years ago

Just showing an image of the geometry cgs_sphere

Calinou commented 3 years ago

I can reproduce this on commit 98b5280d1 with two CSGSpheres (one of them subtracting its parent).

I bisected this to commit 1d5042c9e265219dec8da7311879f12ef3ef698b. cc @aaronfranke

1d5042c9e265219dec8da7311879f12ef3ef698b is the first bad commit
commit 1d5042c9e265219dec8da7311879f12ef3ef698b
Author: Aaron Franke <arnfranke@yahoo.com>
Date:   Fri Apr 3 05:50:40 2020 -0400

    Use Math_TAU and deg2rad/rad2deg in more places and optimize code

 core/math/camera_matrix.cpp                        |  4 +--
 core/math/geometry_3d.cpp                          | 15 +++++----
 core/math/math_funcs.h                             |  8 ++---
 editor/node_3d_editor_gizmos.cpp                   | 38 ++++++++++------------
 editor/plugins/canvas_item_editor_plugin.cpp       | 10 +++---
 editor/plugins/editor_preview_plugins.cpp          | 12 ++++---
 editor/plugins/node_3d_editor_plugin.cpp           | 15 +++++----
 modules/csg/csg_shape.cpp                          | 26 ++++++++-------
 modules/opensimplex/open_simplex_noise.cpp         |  6 ++--
 scene/2d/cpu_particles_2d.cpp                      |  8 ++---
 scene/2d/line_builder.cpp                          |  2 +-
 scene/3d/cpu_particles_3d.cpp                      | 15 +++++----
 scene/3d/immediate_geometry_3d.cpp                 | 11 ++++---
 scene/3d/node_3d.cpp                               |  4 +--
 scene/3d/physics_body_3d.cpp                       |  4 +--
 scene/resources/capsule_shape_2d.cpp               |  5 +--
 scene/resources/circle_shape_2d.cpp                |  3 +-
 scene/resources/primitive_meshes.cpp               | 28 ++++++++--------
 scene/resources/style_box.cpp                      |  4 +--
 servers/audio/audio_filter_sw.cpp                  |  6 ++--
 servers/audio/effects/audio_effect_chorus.cpp      |  4 +--
 servers/audio/effects/audio_effect_delay.cpp       |  2 +-
 servers/audio/effects/audio_effect_distortion.cpp  |  4 +--
 servers/audio/effects/audio_effect_phaser.cpp      |  6 ++--
 .../effects/audio_effect_spectrum_analyzer.cpp     |  3 +-
 servers/audio/effects/eq.cpp                       |  4 +--
 servers/audio/effects/reverb.cpp                   |  4 +--
 servers/physics_2d/space_2d_sw.cpp                 |  2 +-
 .../physics_3d/joints/cone_twist_joint_3d_sw.cpp   |  6 ++--
 servers/physics_3d/space_3d_sw.cpp                 |  2 +-
 servers/rendering/renderer_canvas_cull.cpp         |  4 ++-
 .../renderer_rd/renderer_canvas_render_rd.cpp      |  2 +-
 .../renderer_rd/renderer_scene_render_rd.cpp       |  2 +-
 servers/rendering_server.cpp                       | 10 +++---
 34 files changed, 149 insertions(+), 130 deletions(-)

Correct

Correct

Broken (what I tried bissected for at first)

Broken

Broken 2 (alternative form I saw during bisecting)

Last seen on commit 1d5042c9e during bisecting.

Broken 2

Minimal reproduction project: test_csgsphere.zip Remember to rename all instances of Transform to Transform3D in test.scn if running this project on latest master.

aaronfranke commented 3 years ago

@mrjustaguy Can you test that #49723 fixes the bug for you?

mrjustaguy commented 3 years ago

I have been unable to get the issue with that PR in my testing, so it seems it fixes it.