PiRSquared17 / alembic

Automatically exported from code.google.com/p/alembic
Other
0 stars 0 forks source link

Maya AbcExport does not preserve hard edges #211

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Reproduce:
1. Create a poly cube
2. AbcExport
3. AbcImport

What is the expected output? What do you see instead?
Expected: The edges of the cube are all hard edges
Actual: The edges of the cube are all soft edges

What version of the product are you using? On what operating system?
1.0rc has no problems. This bug is new in 1.0 on all platforms.

Please provide any additional information below.
It can be fixed by checking the smoothing for all edges.
In MayaMeshWriter.cpp,302:
    MPlug plug = lMesh.findPlug("noNormals", true, &status);
    if (status == MS::kSuccess && plug.asBool() == true)
    {
        return;
    }
    // we need to check the locked state of the normals
    else if ( status != MS::kSuccess )
    {
        bool userSetNormals = false;
        bool hasHardEdges   = false;

        // go through all per face-vertex normals and verify if any of them
        // has been tweaked by users
        unsigned int numFaces = lMesh.numPolygons();
        for (unsigned int faceIndex = 0; faceIndex < numFaces; faceIndex++)
        {
            MIntArray normals;
            lMesh.getFaceNormalIds(faceIndex, normals);
            unsigned int numNormals = normals.length();
            for (unsigned int n = 0; n < numNormals; n++)
            {
                if (lMesh.isNormalLocked(normals[n]))
                {
                    userSetNormals = true;
                    break;
                }
            }
        }

        // go through all edges and verify if any of them is hard edge
        unsigned int numEdges = lMesh.numEdges();
        for (unsigned int edgeIndex = 0; edgeIndex < numEdges; edgeIndex++)
        {
            if (!lMesh.isEdgeSmooth(edgeIndex))
            {
                hasHardEdges = true;
                break;
            }
        }

        // we looped over all the normals and they were all calculated by Maya
        // so we won't write any of them out
        if (!userSetNormals && !hasHardEdges)
        {
            return;
        }
    }

Thanks!

Original issue reported on code.google.com by shinc...@gmail.com on 18 Aug 2011 at 3:44

GoogleCodeExporter commented 9 years ago

Original comment by ble...@gmail.com on 25 Aug 2011 at 10:50

GoogleCodeExporter commented 9 years ago
We are double checking to make sure this is the best workflow to use.

In the meantime one way to force the normals to write out is to create a 
noNormals boolean attribute and make sure it is set to false.  The double 
negative will always generate normals.

The reason we try to avoid writing out normals when it appears that they are 
default is because of a bug in some versions of Maya where loading them back in 
is waaaay too slow.

Original comment by miller.lucas on 25 Aug 2011 at 11:28

GoogleCodeExporter commented 9 years ago
Fix implemented here:

http://code.google.com/r/millerlucas-dev/source/detail?r=cf06a89fbeda595effb7c75
dc484b357d743f822

I moved the hard edge loop check inside the check for !userSetNormals so cases 
where at least one of them was changed by the user, we won't need to do a 
redundant edge check. (since the normals will get written anyway)

Original comment by miller.lucas on 26 Aug 2011 at 1:19

GoogleCodeExporter commented 9 years ago

Original comment by miller.lucas on 29 Aug 2011 at 5:03

GoogleCodeExporter commented 9 years ago

Original comment by miller.lucas on 19 Sep 2011 at 9:32