private static bool Deduplicate(float3 position, float3 normal, int material, int freeTriIndex, NativeDeduplicationCache dedupeCache, out int dedupedTriIndex)
        {
            //TODO Find sensible value
            const float quantization = 1024f;

            int hash = HashVertex(position, normal, material, quantization);

            if (!dedupeCache.table.TryGetValue(hash, out int index))
            {
                index = -1;
            }

            if (index >= 0)
            {
                int nodeIndex          = index;
                DedupedVertexNode node = dedupeCache.nodes[nodeIndex];

                while (true)
                {
                    DedupedVertex deduped = node.vertex;

                    if (IsVertexEqual(position, normal, material, deduped.position, deduped.normal, deduped.material, quantization))
                    {
                        //Equal vertex found, return index
                        dedupedTriIndex = deduped.triIndex;
                        return(true);
                    }

                    if (node.next >= 0)
                    {
                        nodeIndex = node.next;
                        node      = dedupeCache.nodes[nodeIndex];
                    }
                    else
                    {
                        //Hash contained but no equal vertex, append new node to linked list
                        dedupeCache.nodes[nodeIndex] = new DedupedVertexNode(deduped, dedupeCache.nodes.Length);
                        dedupeCache.nodes.Add(new DedupedVertexNode(new DedupedVertex(position, normal, material, freeTriIndex)));
                        break;
                    }
                }
            }
            else
            {
                //Hash not yet contained, add a new initial node
                Assert.IsTrue(dedupeCache.table.TryAdd(hash, dedupeCache.nodes.Length));
                dedupeCache.nodes.Add(new DedupedVertexNode(new DedupedVertex(position, normal, material, freeTriIndex)));
            }

            dedupedTriIndex = freeTriIndex;
            return(false);
        }
 internal DedupedVertexNode(DedupedVertex vertex) : this(vertex, -1)
 {
 }
 internal DedupedVertexNode(DedupedVertex vertex, int next)
 {
     this.vertex = vertex;
     this.next   = next;
 }