Esempio n. 1
0
 public void CopyTo(Topology.FaceEdge[] array, int arrayIndex)
 {
     for (int i = 0; i < _length; ++i)
     {
         array[arrayIndex++] = new Topology.FaceEdge(_topology, _edgeIndices[i]);
     }
 }
Esempio n. 2
0
 private float Cost(Topology.FaceEdge edge, int pathLength)
 {
     if (edge.face.isInternal && _faceBlockedStates[edge] == false)
     {
         return(1f);
     }
     else
     {
         return(float.PositiveInfinity);
     }
 }
Esempio n. 3
0
            public static Partition Create(Topology.FaceEdge edge, IVertexAttribute <Vector3> vertexPositions, Surface surface)
            {
                var prevEdge    = edge.prev;
                var vPos0       = vertexPositions[prevEdge];
                var vPos1       = vertexPositions[edge];
                var edgeVector  = vPos1 - vPos0;
                var edgeNormal  = surface.GetNormal(vPos0);
                var planeNormal = Vector3.Cross(edgeVector, edgeNormal).normalized;

                return(new Partition(planeNormal, vPos0, edge.twinIndex, edge.index));
            }
Esempio n. 4
0
 private void PartitionEdgeOver(int parentIndex, Vector3 p0, Vector3 p1, Topology.FaceEdge edge, IVertexAttribute <Vector3> vertexPositions, ref int nextPartitionIndex)
 {
     if (_partitionBinaryTree[parentIndex]._overPartitionIndex != 0)
     {
         PartitionEdge(_partitionBinaryTree[parentIndex]._overPartitionIndex, p0, p1, edge, vertexPositions, ref nextPartitionIndex);
     }
     else
     {
         _partitionBinaryTree[parentIndex]._overPartitionIndex = nextPartitionIndex;
         if (nextPartitionIndex >= _partitionBinaryTree.Length)
         {
             ExtendBinaryTree();
         }
         _partitionBinaryTree[nextPartitionIndex] = Partition.Create(edge, vertexPositions, _surface);
         ++nextPartitionIndex;
     }
 }
Esempio n. 5
0
        private float Cost(Topology.FaceEdge edge, int pathLength)
        {
            if (_faceUnits[edge] != null)
            {
                return(float.PositiveInfinity);
            }

            switch (_faceTerrainIndices[edge])
            {
            case 0: return(1f);

            case 1: return(float.PositiveInfinity);

            case 2: return(3f);

            case 3: return(9f);

            default: throw new NotImplementedException();
            }
        }
Esempio n. 6
0
        private void PartitionEdge(int partitionIndex, Vector3 p0, Vector3 p1, Topology.FaceEdge edge, IVertexAttribute <Vector3> vertexPositions, ref int nextPartitionIndex)
        {
            var     partition = _partitionBinaryTree[partitionIndex];
            var     relation  = partition.Compare(p0, 0.0001f) * 3 + partition.Compare(p1, 0.0001f);
            Vector3 underIntersection;
            Vector3 overIntersection;

            switch (relation)
            {
            case -4:                     // Both points are under.
            case -3:
            case -1:
                PartitionEdgeUnder(partitionIndex, p0, p1, edge, vertexPositions, ref nextPartitionIndex);
                break;

            case -2:                     // p0 is under and p1 is over.
                partition.Intersect(p0, p1, out underIntersection, out overIntersection);
                PartitionEdgeUnder(partitionIndex, p0, overIntersection, edge, vertexPositions, ref nextPartitionIndex);
                PartitionEdgeOver(partitionIndex, underIntersection, p1, edge, vertexPositions, ref nextPartitionIndex);
                break;

            case 0:                     // Both points are directly on the partition plane.
                break;

            case 2:                     // p0 is over and p1 is under.
                partition.Intersect(p1, p0, out underIntersection, out overIntersection);
                PartitionEdgeUnder(partitionIndex, overIntersection, p1, edge, vertexPositions, ref nextPartitionIndex);
                PartitionEdgeOver(partitionIndex, p0, underIntersection, edge, vertexPositions, ref nextPartitionIndex);
                break;

            case 1:                     // Both points are over.
            case 3:
            case 4:
                PartitionEdgeOver(partitionIndex, p0, p1, edge, vertexPositions, ref nextPartitionIndex);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 7
0
 public void Add(Topology.FaceEdge item)
 {
     throw new NotSupportedException();
 }
Esempio n. 8
0
 public int IndexOf(Topology.FaceEdge item)
 {
     return(Array.IndexOf(_edgeIndices, item.index));
 }
Esempio n. 9
0
 public bool Contains(Topology.FaceEdge item)
 {
     return(Array.IndexOf(_edgeIndices, item.index) != -1);
 }
Esempio n. 10
0
		/// <inheritdoc/>
		public abstract T this[Topology.FaceEdge e] { get; set; }
Esempio n. 11
0
		/// <summary>
		/// Accesses the vertex attribute value in the array corresponding to the vertex of the given edge.
		/// </summary>
		/// <param name="e">The edge whose vertex's attribute value is to be accessed.</param>
		/// <returns>The vertex attribute value corresponding to the vertex of the given edge.</returns>
		public T this[Topology.FaceEdge e]
		{
			get { return array[e.vertex.index]; }
			set { array[e.vertex.index] = value; }
		}
 /// <summary>
 /// Lookup the attribute value for the vertex of the edge indicated, wrapping according to the attribute's surface if necessary.
 /// </summary>
 /// <param name="e">The edge whose vertex's attribute value is desired.</param>
 /// <returns>The attribute value for the next vertex of the edge indicated, relative to the edge's near face.</returns>
 /// <remarks><para>To get the raw value unwrapped, see <see cref="P:MakeIt.Tile.VertexArrayAttribute`1.Item(MakeIt.Tile.Topology.Vertex)"/></para></remarks>
 public override Vector3 this[Topology.FaceEdge e]
 {
     get { return(surface.OffsetFaceToVertAttribute(array[e.vertex.index], e.wrap)); }
     set { array[e.vertex.index] = surface.ReverseOffsetFaceToVertAttribute(array[e.vertex.index], e.wrap); }
 }
Esempio n. 13
0
        private static void ExportVertexToSVG(System.IO.TextWriter writer, Topology.Vertex vertex, Topology.FaceEdge edge, Func <Vector3, Vector2> flatten, IVertexAttribute <Vector3> vertexPositions, Vector2 transformedVertexDotRadius, string vertexFormat, string vertexIndexFormat, SVGStyle style, string additionalClasses)
        {
            var p = flatten(vertexPositions[edge]);

            writer.WriteLine(vertexFormat, p.x, p.y, transformedVertexDotRadius.x, transformedVertexDotRadius.y, additionalClasses);

            if (style.showVertexIndices)
            {
                writer.WriteLine(vertexIndexFormat, p.x, p.y, vertex.index, additionalClasses);
            }
        }
Esempio n. 14
0
        private static void ExportEdgeToSVG(System.IO.TextWriter writer, ISurface surface, Topology.FaceEdge edge, Topology.FaceEdge nearVertexFaceEdge, Topology.FaceEdge farVertexFaceEdge, Func <Vector3, Vector2> flatten, IVertexAttribute <Vector3> vertexPositions, string arrowFormat, string edgeIndexFormat, SVGStyle style, string additionalClasses)
        {
            var p0            = vertexPositions[nearVertexFaceEdge];
            var p1            = vertexPositions[farVertexFaceEdge];
            var n0            = surface.GetNormal(p0);
            var n1            = surface.GetNormal(p1);
            var edgeDirection = (p1 - p0).normalized;
            var edgeNormal0   = (n0 + n1).normalized;
            var edgeNormal1   = Vector3.Cross(edgeDirection, edgeNormal0);

            var offset0 = edgeDirection * (style.vertexCircleRadius + style.edgeSeparation);
            var offset1 = edgeNormal1 * style.edgeSeparation * 0.5f;
            var offset2 = -edgeDirection * style.edgeArrowOffset.x + edgeNormal1 * style.edgeArrowOffset.y;

            Vector2 arrow0 = flatten(p0 + offset0 + offset1);
            Vector2 arrow1 = flatten(p1 - offset0 + offset1);
            Vector2 arrow2 = flatten(p1 - offset0 + offset1 + offset2);

            writer.WriteLine(arrowFormat, arrow0.x, arrow0.y, arrow1.x, arrow1.y, arrow2.x, arrow2.y, additionalClasses);

            if (style.showEdgeIndices)
            {
                var edgeCenter = flatten((p0 + p1) * 0.5f + edgeNormal1 * (style.edgeSeparation * 0.5f + style.edgeIndexOffset));
                writer.WriteLine(edgeIndexFormat, edgeCenter.x, edgeCenter.y, edge.index, additionalClasses);
            }
        }
Esempio n. 15
0
 public void Insert(int index, Topology.FaceEdge item)
 {
     throw new NotSupportedException();
 }
Esempio n. 16
0
		/// <inheritdoc/>
		public override T this[Topology.FaceEdge e]
		{
			get { return constant; }
			set { throw new NotSupportedException("Values of a constant vertex attribute cannot be changed."); }
		}
Esempio n. 17
0
 public bool Remove(Topology.FaceEdge item)
 {
     throw new NotSupportedException();
 }
Esempio n. 18
0
 private void PartitionEdge(Topology.FaceEdge edge, IVertexAttribute <Vector3> vertexPositions, ref int nextPartitionIndex)
 {
     PartitionEdge(0, vertexPositions[edge.prev], vertexPositions[edge], edge, vertexPositions, ref nextPartitionIndex);
 }