-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Mend gaps in meshes caused by trigonometric funcs. #100020
Conversation
v += 1.0; | ||
w = sin(0.5 * Math_PI * v); | ||
y = radius * cos(0.5 * Math_PI * v); | ||
if (j == (rings + 1)) { | ||
w = 0.0; | ||
y = -radius; | ||
} else { | ||
w = cos(0.5 * Math_PI * v); | ||
y = -sin(0.5 * Math_PI * v) * radius; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid unnecessary addition and subtraction.
sin((x+1)π/2) == cos(xπ/2)
cos((x+1)π/2) == -sin(xπ/2)
ADD_TANGENT(-Math::cos(angi), 0.0, Math::sin(angi), 1.0); | ||
ADD_TANGENT(normali.y, 0.0, -normali.x, 1.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosine and sine already calculated above: reuse.
9ce9a18
to
9b83465
Compare
Originally posted by @fire in #94199 (comment) Tested CSG-meshes! Since only the sphere had gaps, I stuffed it to this pr~ |
I suspect the capsule also has the same gap. |
I don't think we have CSGCapsules... |
Any of these meshes can be put into CSGMesh3D https://docs.godotengine.org/en/stable/classes/class_primitivemesh.html From earlier testing RibbonTrailMesh, SphereMesh and PlaneMesh mathematically cannot work. |
Ah! I see! All the primitive meshes that had gaps are already included CapsuleMesh, CylinderMesh, SphereMesh, TorusMesh and TubeTrailMesh ^^/ This means there shouldn't be gaps in CSGMesh3D either! Or at least those that are caused by the trig functions... but I haven't found other causes and my naive test passes for all the shapes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested all primitive mesh shapes except those that aren't mathematically usable with CSG.
The manifold definition requires the meshes to be watertight.
Note that the pull request is insufficient; will also need the Godot Engine master as of eb51030 or newer
csg-mend-gaps-game-project.zip
Edited:
Did not do a style review.
This comment was marked as outdated.
This comment was marked as outdated.
9b83465
to
b4c6f9b
Compare
Thanks! |
Fixes: #93865
Supersedes: #94199
Simple, ugly solution: Ensure last iteration uses the same values as the first. Here's a cheat-sheet to help reviewing: