public void CopyTo(Topology.FaceEdge[] array, int arrayIndex) { for (int i = 0; i < _length; ++i) { array[arrayIndex++] = new Topology.FaceEdge(_topology, _edgeIndices[i]); } }
private float Cost(Topology.FaceEdge edge, int pathLength) { if (edge.face.isInternal && _faceBlockedStates[edge] == false) { return(1f); } else { return(float.PositiveInfinity); } }
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)); }
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; } }
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(); } }
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(); } }
public void Add(Topology.FaceEdge item) { throw new NotSupportedException(); }
public int IndexOf(Topology.FaceEdge item) { return(Array.IndexOf(_edgeIndices, item.index)); }
public bool Contains(Topology.FaceEdge item) { return(Array.IndexOf(_edgeIndices, item.index) != -1); }
/// <inheritdoc/> public abstract T this[Topology.FaceEdge e] { get; set; }
/// <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); } }
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); } }
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); } }
public void Insert(int index, Topology.FaceEdge item) { throw new NotSupportedException(); }
/// <inheritdoc/> public override T this[Topology.FaceEdge e] { get { return constant; } set { throw new NotSupportedException("Values of a constant vertex attribute cannot be changed."); } }
public bool Remove(Topology.FaceEdge item) { throw new NotSupportedException(); }
private void PartitionEdge(Topology.FaceEdge edge, IVertexAttribute <Vector3> vertexPositions, ref int nextPartitionIndex) { PartitionEdge(0, vertexPositions[edge.prev], vertexPositions[edge], edge, vertexPositions, ref nextPartitionIndex); }