Exporters: Maya To GLTF Missing Mesh

Created on 31 Jul 2020  路  8Comments  路  Source: BabylonJS/Exporters

If I export with mesh optimisations on a mesh get lost in the conversion.

with mesh optimizations

    {
      "skin": 0,
      "mesh": 0,
      "name": "Head"
    },
    {
      "name": "Body"
    },

without

    {
      "skin": 0,
      "mesh": 0,
      "name": "Head"
    },
    {
      "skin": 1,
      "mesh": 1,
      "name": "Body"
    },

I can't provide the asset unfortunately, but this is in the Maya graph.

Capture

I realise there are a million things that can go wrong here.

bug maya

All 8 comments

So I've got a fix for this that works for us.

C# // GlobalVertex.cs if (UV2 != null && other.UV2 != null && !other.UV2.IsAlmostEqualTo(UV2, Tools.Epsilon)) { return false; }

other.UV2 was null, and adding a check solves our issue. Happy to raise a PR for this, but unsure if I should add this change to the other attributes (Position,Normal,UV,Weights...)?

Yes, thanks for looking into this! I agree that we should be doing a more sophisticated check here.

Imagine 3 scenarios:

v1 does not have uv2, v2 does not have uv2:
these have equivalent uv2 values.

v1has uv2, v2 does not have uv2, or v1 doesnt have UV2, v2 has UV2:
one vertex has coordinates, the other doesnt, we can't consider these vertices as equivalent.

v1 has UV2, v2 has UV2:
we should consider these as equivalent if they both have equivalent uv2 values.

Using this criteria, I'd rather we do something similar to:

if (UV2 == null && other.UV2 != null || UV2 != null && other.UV2 == null || !other.UV2.IsAlmostEqualTo(UV2, Tools.Epsilon)
{
    return false;
}

I agree that we should add similar checks to all other attributes as well (though we probably don't need to add these checks for Position)

Would you like to open a PR with these changes? :)

Yep I can do these changes :+1:

Hey @philSG do you mind sending a new PR?

Yes Sorry I got side tracked with a high priority thing, I'm getting back on this area today.

I assume while PR has been done and no activity has been recorded since a while on the topic, issue is solved.

Seems the PR introduce invalid logic when testing and this is related to #874.
following code
if ((UV2 == null && other.UV2 != null) || (UV2 != null && other.UV2 == null) || !other.UV2.IsAlmostEqualTo(UV2, Tools.Epsilon))
let possibility of other.UV2 to be null (UV2 == null && other.UV2 == null) and throw exception, preventing the node to be exported.
To simplify, because only used into Maya exporter, we may introduce the null checking logic into the IsAlmostEqualTo(..) extensions

       public static bool IsAlmostEqualTo(this float[] current, float[] other, float epsilon)
        {
        if( current == null )
        {
        return other == null;
            }
        if( other == null )
        {
        return false;
        }
            if (current.Length != other.Length)
            {
                return false;
            }
            for (int index = 0; index < current.Length; index++)
            {
                if (Math.Abs(current[index] - other[index]) > epsilon)
                {
                    return false;
                }
            }
            return true;
        }

And change the Global Vertex Equals accordly

if (!XXXX.IsAlmostEqualTo(other.XXXX, Tools.Epsilon) { return false; }
then the GlobalVertex Equals become

        public override bool Equals(object obj)
        {
            if (obj != null && obj is GlobalVertex other)
            {
                // Note the logic located into the Tools.IsAlmostEqualTo Extension is also check for null parameters.
                return 
                    other.BaseIndex == BaseIndex &&
                    other.Position.IsAlmostEqualTo(Position, Tools.Epsilon) &&
                    other.Normal.IsAlmostEqualTo(Normal, Tools.Epsilon) &
                    other.UV.IsAlmostEqualTo(UV, Tools.Epsilon) &&
                    other.UV2.IsAlmostEqualTo(UV2, Tools.Epsilon) &&
                    other.Weights.IsAlmostEqualTo(Weights, Tools.Epsilon) &&
                    other.WeightsExtra.IsAlmostEqualTo(WeightsExtra, Tools.Epsilon) &&
                    other.Color.IsAlmostEqualTo(Color, Tools.Epsilon) && 
                    other.BonesIndices == BonesIndices;
            }
            return false;
        }

I made the test and this is solving the issues so far.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

echadwick-wayfair picture echadwick-wayfair  路  4Comments

jsellam picture jsellam  路  7Comments

qualmon picture qualmon  路  6Comments

echadwick-wayfair picture echadwick-wayfair  路  3Comments

MaximeOrlandi picture MaximeOrlandi  路  7Comments