Example #1
0
    public static void GetNeighbourForAllPossibleNeighbours(int triangulationIndex, int index, List <OutsideEdgeNeighbourDirection> addResult)
    {
        for (int i = 0; i < 3; ++i)
        {
            Vector3Int offset       = Vector3Int.zero;
            Vector2Int edgeVertices = new Vector2Int(TriangulationTable.triangulation[triangulationIndex][index + i], TriangulationTable.triangulation[triangulationIndex][index + ((i + 1) % 3)]);
            GetEdgeAxisDirection(ref offset, edgeVertices.x);
            GetEdgeAxisDirection(ref offset, edgeVertices.y);
            //r = r.Map(f => { if (Mathf.Abs(f) == 2)  return (int)Mathf.Sign(f) * 1;  else  return 0;  });
            offset = new Vector3Int(
                Mathf.Abs(offset.x) == 2 ? (int)Mathf.Sign(offset.x) : 0,
                Mathf.Abs(offset.y) == 2 ? (int)Mathf.Sign(offset.y) : 0,
                Mathf.Abs(offset.z) == 2 ? (int)Mathf.Sign(offset.z) : 0);
            if (offset != Vector3.zero)
            {
                //try find edge for every other comb if exists
                OutsideEdgeNeighbourDirection neighbour = new OutsideEdgeNeighbourDirection(index / 3, edgeVertices.x, edgeVertices.y, i, (i + 1) % 3, offset);
                addResult.Add(neighbour);

                int vertexKey = BuildSmallKeyFromEdgeIndices(edgeVertices.x, edgeVertices.y);

                if (!hasNeighoursComputedForVertexPair.Contains(vertexKey))
                {
                    hasNeighoursComputedForVertexPair.Add(vertexKey);
                    for (int otherTriangulationIndex = 1; otherTriangulationIndex < 255; otherTriangulationIndex++)
                    {
                        OutsideNeighbourConnectionInfo info;
                        if (TryGetIndexWithEdges(otherTriangulationIndex, neighbour.rotatedEdgePair.x, neighbour.rotatedEdgePair.y, out info))
                        {
                            int key = BuildKeyFromEdgeIndices(otherTriangulationIndex, edgeVertices.x, edgeVertices.y);
                            externNeighboursLookup[key] = info;
                        }
                    }
                }
            }
        }
    }
Example #2
0
 public MissingNeighbourData(OutsideEdgeNeighbourDirection neighbour, Vector3Int cubeEntity)
 {
     this.outsideNeighbour = neighbour;
     this.originCubeEntity = cubeEntity;
 }