Skip to content
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

CalcTangents: zero vector is invalid for tangent/bitangent #5432

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JensEhrhardt-eOPUS
Copy link

This fix helps when the calculated tangent of a face is a zero vector

@turol
Copy link
Member

turol commented Jan 22, 2024

Comparing floats with == is dangerous. What happens if the values are negative zeroes instead of positive zeroes? What if they're sufficiently small (around FLT_MIN) that calculating the length still ends up zero?

@JensEhrhardt-eOPUS
Copy link
Author

committed a version that also checks for small vectors

@turol
Copy link
Member

turol commented Jan 22, 2024

0.5 is way too big for this use case. Tangents are supposed to be unit-length.

@JensEhrhardt-eOPUS
Copy link
Author

length of (0.5, 0.5, 0.5) == 0.866 is smaller than any normalized 3D vector

@JulianKnodt
Copy link
Contributor

er sorry why not just check the length is sufficiently different from 1? i.e. Length(Vector) - 1 < EPSILON, where EPSILON is a small number such as 1e-3? It's a bit hard to understand the intent from reading the current code

The current implementation marks all vectors invalid if they're in the range [-0.5, 0.5], but I'm not sure if it's problematic if the vector is too large.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants