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

Normal generation errors #5032

Merged
merged 3 commits into from
Feb 24, 2017
Merged

Normal generation errors #5032

merged 3 commits into from
Feb 24, 2017

Conversation

tfili
Copy link
Contributor

@tfili tfili commented Feb 23, 2017

Fix issue where we can't generate correct normals. Triangles are either degenerate or part of coplanar triangles with opposite winding order.

Added tests for both cases.

CC CesiumGS/gltf-pipeline#242

…er degenerate or part of coplanar triangles with opposite winding order.
normalValues[i3 + 2] = 1.0;

// We can run into an issue where a vertex is used with 2 primitives that have opposite winding order.
if (Cartesian3.equals(Cartesian3.ZERO, normal)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have more than 2 triangles. Would a better test be to only add a normal if its dot product with the sum is greater than zero?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, never mind. I can think of some geometries that Cesium can generate where this wouldn't be true. Also, add an epsilon check here.

}

// We end up with a zero vector probably because of a degenerate triangle
if (Cartesian3.equals(Cartesian3.ZERO, normal)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an epsilon check.

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

2 participants