-
Notifications
You must be signed in to change notification settings - Fork 221
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
fix computeFaceNormal: use corner whose angle is closest to right angle for cross product #131
base: master
Are you sure you want to change the base?
Conversation
…le for cross product
Benchmarking the code with over 5000 test meshes doesn't show any performance impact. |
source/xatlas/xatlas.cpp
Outdated
static float angle(const Vector3 &a, const Vector3 &b) | ||
{ | ||
const Vector3 c = cross(a, b); | ||
return abs(atan2(length(c), dot(a, b))); |
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.
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.
Not so sure, atan2
should give results in the range [-pi, pi], while atan
gives results in the range [-pi/2, pi/2].
Apart from that, that smells like premature optimization imo ("no visible slowdown").
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.
yes it is premature optimization. don't touch it, the test showed it's not necessary
bunch of warnings you could cleanup
|
I tried it. no visible slowdown. LGTM |
Should Vectors be normalized before the cross product? |
@siliconvoodoo @henkson |
And you probably need to remove the |
@mifth
That was probably only needed because I used those |
Oh, right! A new variable is needed. About the name I would leave it to you if you don't mind. I believe something like Yeah it seems the |
Just have got in my mind. What do you think about |
the k prefix is just one of usual conventions to denote a hard constant. (usually the type that get inlined at code generation and they have no ODR existence) |
This change provides a fix for issue #130.
angle
that calculates the angle between 2 Vector3 objectsMesh.computeFaceNormal
method: verify the angles of all face vertices, and use the vertex whose angle is the closest to a right angle (90°). This makes the cross product numerically more stable.