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
Inherited Members
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
Fields
Empty
Creates an empty edge defined as (-1, -1)
.
Declaration
public static readonly Edge Empty
Field Value
Type | Description |
---|---|
Edge |
See Also
a
Stores an index that corresponds to a mesh vertex array.
Declaration
public int a
Field Value
Type | Description |
---|---|
int |
See Also
b
Stores an index that corresponds to a mesh vertex array.
Declaration
public int b
Field Value
Type | Description |
---|---|
int |
See Also
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 |
Examples
{0, 1} + {4, 5} = {5, 6}
See Also
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
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
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
See Also
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
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
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
See Also
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
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 |
Examples
Subtract( {7, 10}, {4, 5} ) = {3, 5}
See Also
ToString()
Returns a string representation of the edge.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | String formatted as |
Overrides
See Also
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 |
See Also
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 |
See Also
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
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
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 |
See Also
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 |