-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Round primitive meshes contain gaps. #93865
Comments
Running a related quick test:
prints:
So indeed we can't count on the value matching. |
Hello! First timer here, would I be alright if I take on this issue? |
Can this be fixed by using safesin and safecos functions from MathUtils library? |
Yes, of course! It's ok to take issues if no one posted about taking them before you |
Great! I'll do my best then 🫡 |
Since it's not part of the engine and there are ways to solve this without adding more third party code that wouldn't be an appropriate solution IMO |
@CatMachina Hello, it's been a few days so I was wondering if you were still working on this? If not I'll take over :) |
Hey @mickeyordog! Sorry, still cracking at it, could you check back in a few days? 😅 |
Hey @CatMachina, I had my eye on this issue for quite a while and I have implemented a fix. Do you mind if I add a pr? |
Not at all @ayanchavand! I'm sure there are other issues that will inevitably crop up in the future. I wouldn't want to duplicate effort here. I would also love to see how you solved it 👀 |
Yes. |
Tested versions
v4.3.beta2.official [b75f048]
Tested version on v4.3.beta2.official [b75f048], but likely has been present for a long time. First I noticed it #80710 (comment) (and subsequently forgot.)
System information
Godot v4.3.beta2 - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4090 (NVIDIA; 31.0.15.3699) - AMD Ryzen 9 7950X 16-Core Processor (32 Threads)
Issue description
Primitive meshes that contain round surfaces, i.e. SphereMesh, CapsuleMesh, CylinderMesh and TorusMesh, have minuscule gaps. This is due to the fact that some of the vertices at the seams do not align. The gaps are unlikely to be seen in regular use but here's an image of an unconventional shader that exaggerates them:
Capsule and sphere, using a shader that expands vertices based on their floating-point presentations mantissa (for visualization purposes only; do not use the shader to debug the issue, as it might be inaccurate):
The gaps are more of an issue when manipulating the meshes in code, e.g. when iterating unique vertices to create edge-meshes.
The cause is likely a precision issue originating from calculating the same position twice with different values. Example code from CylinderMesh:
godot/scene/resources/3d/primitive_meshes.cpp
Lines 1010 to 1015 in 9db1a96
(
sin(0)
andsin(TAU)
might not be identical due to limited precision, unlike in math)For a fix, I'd suggest either reusing values for positions that are already calculated or ensuring that the values used to derive the positions are identical.
Steps to reproduce
The unaligned vertices can be found using the following script:
Minimal reproduction project (MRP)
Project containing both the shader used to demonstrate the gaps and the script to find them:
primitive_meshes.zip
The text was updated successfully, but these errors were encountered: