docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct Edge

    Represents an edge connecting two vertices.

    This might point to an index in the vertices (local) or the sharedVertices (common) array. The ProBuilder terminology "local" and "common" refers to whether this is an index from the list of all vertices in the ProBuilderMesh or an index from the list of only shared vertices.

    Implements
    IEquatable<Edge>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.ProBuilder
    Assembly: Unity.ProBuilder.dll
    Syntax
    [Serializable]
    public struct Edge : IEquatable<Edge>

    Constructors

    Edge(int, int)

    Creates a new edge from two vertex indexes.

    Declaration
    public Edge(int a, int b)
    Parameters
    Type Name Description
    int a

    An index corresponding to a mesh vertex array.

    int b

    An index corresponding to a mesh vertex array.

    See Also
    sharedVertices
    EdgeLookup

    Fields

    Empty

    Creates an empty edge defined as (-1, -1).

    Declaration
    public static readonly Edge Empty
    Field Value
    Type Description
    Edge
    See Also
    sharedVertices
    EdgeLookup

    a

    Stores an index that corresponds to a mesh vertex array.

    Declaration
    public int a
    Field Value
    Type Description
    int
    See Also
    sharedVertices
    EdgeLookup

    b

    Stores an index that corresponds to a mesh vertex array.

    Declaration
    public int b
    Field Value
    Type Description
    int
    See Also
    sharedVertices
    EdgeLookup

    Methods

    Add(Edge, Edge)

    Adds two edges index values.

    Declaration
    public static Edge Add(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a

    Left edge parameter.

    Edge b

    Right edge parameter.

    Returns
    Type Description
    Edge

    The sum of a + b.

    Examples

    {0, 1} + {4, 5} = {5, 6}

    See Also
    sharedVertices
    EdgeLookup

    Contains(int)

    Tests whether this edge contains an index.

    Declaration
    public bool Contains(int index)
    Parameters
    Type Name Description
    int index

    The index to compare against x and y.

    Returns
    Type Description
    bool

    True if x or y is equal to a. False if not.

    See Also
    sharedVertices
    EdgeLookup

    Contains(Edge)

    Tests whether this edge has any matching index to the other edge b.

    Declaration
    public bool Contains(Edge other)
    Parameters
    Type Name Description
    Edge other

    The edge to compare against.

    Returns
    Type Description
    bool

    True if x or y matches either b.x or b.y.

    See Also
    sharedVertices
    EdgeLookup

    Equals(object)

    Tests whether this object is equal to another object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare against.

    Returns
    Type Description
    bool

    True if the edges are equal, false if not.

    Overrides
    ValueType.Equals(object)
    See Also
    sharedVertices
    EdgeLookup

    Equals(Edge)

    Tests whether this Edge is equal to another Edge object.

    Declaration
    public bool Equals(Edge other)
    Parameters
    Type Name Description
    Edge other

    The Edge to compare against.

    Returns
    Type Description
    bool

    True if the edges are equal, false if not.

    See Also
    sharedVertices
    EdgeLookup

    Equals(Edge, Dictionary<int, int>)

    Compares edges and takes shared triangles into account.

    Declaration
    public bool Equals(Edge other, Dictionary<int, int> lookup)
    Parameters
    Type Name Description
    Edge other

    The edge to compare against.

    Dictionary<int, int> lookup

    A common vertex indexes lookup dictionary. See pb_IntArray for more information.

    Returns
    Type Description
    bool

    True if edges are perceptually equal (that is, they point to the same common indexes).

    Remarks

    Generally you just pass ProBuilderMesh.sharedIndexes.ToDictionary() to lookup, but it's more efficient to do it once and reuse that dictionary if possible.

    See Also
    sharedVertices
    EdgeLookup

    GetHashCode()

    Returns the hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    An integer that is the hash code for this instance.

    Overrides
    ValueType.GetHashCode()
    See Also
    sharedVertices
    EdgeLookup

    IsValid()

    Tests whether this edge points to valid vertex indexes.

    Declaration
    public bool IsValid()
    Returns
    Type Description
    bool

    True if x and y are both greater than -1.

    See Also
    sharedVertices
    EdgeLookup

    Subtract(Edge, Edge)

    Subtracts edge b from a.

    Declaration
    public static Edge Subtract(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a

    The edge to subtract from.

    Edge b

    The value to subtract.

    Returns
    Type Description
    Edge

    The difference of a - b.

    Examples

    Subtract( {7, 10}, {4, 5} ) = {3, 5}

    See Also
    sharedVertices
    EdgeLookup

    ToString()

    Returns a string representation of the edge.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    String formatted as [a, b].

    Overrides
    ValueType.ToString()
    See Also
    sharedVertices
    EdgeLookup

    Operators

    operator +(Edge, int)

    Creates a new Edge by adding an integer to both indices on an Edge object.

    Declaration
    public static Edge operator +(Edge a, int b)
    Parameters
    Type Name Description
    Edge a

    The Edge to add to.

    int b

    The value to add.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a + b), (a.b + b)}.

    See Also
    sharedVertices
    EdgeLookup

    operator +(Edge, Edge)

    Creates a new Edge by adding the two left indices together and the two right indices together from both Edge objects.

    Declaration
    public static Edge operator +(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a

    Left edge.

    Edge b

    Right edge.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a + b.a), (a.b + b.b)}.

    See Also
    sharedVertices
    EdgeLookup

    operator ==(Edge, Edge)

    Compares two objects for equality.

    Declaration
    public static bool operator ==(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a

    The first Edge instance.

    Edge b

    The second Edge instance.

    Returns
    Type Description
    bool

    True if the objects are equal; false if not.

    See Also
    sharedVertices
    EdgeLookup

    operator !=(Edge, Edge)

    Returns true if the two objects are not equal.

    Declaration
    public static bool operator !=(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a

    The first Edge instance.

    Edge b

    The second Edge instance.

    Returns
    Type Description
    bool

    True if the objects are not equal; false if they are equal.

    See Also
    sharedVertices
    EdgeLookup

    operator -(Edge, int)

    Creates a new Edge by subtracting an integer from both indices on an Edge object.

    Declaration
    public static Edge operator -(Edge a, int b)
    Parameters
    Type Name Description
    Edge a

    The Edge to subtract from.

    int b

    The value to subtract.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a - b), (a.b - b)}.

    See Also
    sharedVertices
    EdgeLookup

    operator -(Edge, Edge)

    Creates a new Edge by subtracting the two left indices together and the two right indices together from both Edge objects.

    Declaration
    public static Edge operator -(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a

    Left edge.

    Edge b

    Right edge.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a - b.a), (a.b - b.b)}.

    See Also
    sharedVertices
    EdgeLookup

    Implements

    IEquatable<T>

    See Also

    sharedVertices
    EdgeLookup
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)