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

Keep default normal when smooth computation leads to null normal #18

Open
GoogleCodeExporter opened this issue Aug 6, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Download the 3DS file http://www.baument.com/restore/Models/Faucet1.zip
available at http://www.baument.com/restore/archives.html
2. Read it with lib3ds
3. In smooth normals computation part of lib3ds_mesh_calculate_vertex_normals 
function of lib3ds_mesh.c, this should lead to a few incorrect normals (I say 
"should" because I got this result using a pseudo-translation of lib3ds in Java 
3D).

What is the expected output? What do you see instead?
Getting default normals from lib3ds_vector_normalize when length is 0 isn't a 
major issue, but it would be better to keep the default normal in that case 
(i.e. the normal computed before smoothing operation). After line 222 of 
lib3ds_mesh.c, I would suggest to add this test:

    if (lib3ds_vector_length(n) == 0) {
        lib3ds_vector_copy(n, fa[3*i+j].normal);
    }

(with an additional lib3ds_vector_length_squared function, you could spare a 
call to sqrt here)


What version of the product are you using? 
I looked to source code of version 20080909

Original issue reported on code.google.com by [email protected] on 16 Sep 2014 at 9:42

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

No branches or pull requests

1 participant