dgud / wings

Wings3D is an advanced sub-division 3D modeller.
http://www.wings3d.com
Other
571 stars 90 forks source link

Collada importer is missing hard edges #586

Open Micheus opened 1 week ago

Micheus commented 1 week ago

There are situations in which the hard edges are not imported (all or a few ones). That can be noticed even using files exported by Wings3D which although them can be correctly opened by other 3D apps and viewer showing the hard edges (or sharp edges).

It was reported at Discord.

dgud commented 6 days ago

Which format? Wasn't this on vrml?
Is this fixed by the patches just merged by @elblake?

Micheus commented 6 days ago

Which format? Wasn't this on vrml? No. Pure Collada (wpc_collada and collada_import) and I just rebuilt Wings3D (checking your fix-otp27 branch) the issue is still present: image

In fact, I already started to try figure it out (not deeply) and I found the problem can/should be related to the evaluation of normals (that will be used to set the hard edges).

In /e3d/e3d_mesh->hard_edges_from_normals (L112) I noticed the normal imported is evaluated against the computed one by Wings3D. So, specifically about reimported file, Wings3D exported using 6 decimals (0.000000) and the computed one doesn't has this "limit" and they don't match. Similar thing should happens with files that come from other apps that may have a decimal value slight different of the one computed by Wings3D).

So, what do you think we can do about that? Would be valid we "truncate" the computed value by Wings3D or use only the imported value to evaluate the hard edges?

I'm attaching the prism element (from the image above | it's the .dae file) in case you want to print out the values in that function and see what I'm seeing. :-)

test-dae.zip

dgud commented 6 days ago

So it is just matter of comparing them: i..e abs(Computed-Imported) < ?EPSILON they are equal then.

dgud commented 6 days ago

Hmm it's already done here ?

is_equal_v(N,N) -> true; is_equal_v(N1,N2) -> e3d_vec:dist_sqr(N1,N2) < ?EPSILON.

dgud commented 6 days ago

The current algorithm has problems when not all edges around the face is hard.

Micheus commented 6 days ago

Hmm it's already done here ?

is_equal_v(N,N) -> true; is_equal_v(N1,N2) -> e3d_vec:dist_sqr(N1,N2) < ?EPSILON.

As I said I didn't go deep on it, but I'm going to check it better looking for this you are pointing.