272 lines
7.9 KiB
C#
272 lines
7.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace ProBuilder2.Common
|
|
{
|
|
// Token: 0x0200000E RID: 14
|
|
[Serializable]
|
|
public class pb_Edge : IEquatable<pb_Edge>
|
|
{
|
|
// Token: 0x0600005E RID: 94 RVA: 0x0000DE18 File Offset: 0x0000C218
|
|
public pb_Edge()
|
|
{
|
|
}
|
|
|
|
// Token: 0x0600005F RID: 95 RVA: 0x0000DE20 File Offset: 0x0000C220
|
|
public pb_Edge(int _x, int _y)
|
|
{
|
|
this.x = _x;
|
|
this.y = _y;
|
|
}
|
|
|
|
// Token: 0x06000060 RID: 96 RVA: 0x0000DE36 File Offset: 0x0000C236
|
|
public pb_Edge(pb_Edge edge)
|
|
{
|
|
this.x = edge.x;
|
|
this.y = edge.y;
|
|
}
|
|
|
|
// Token: 0x06000061 RID: 97 RVA: 0x0000DE56 File Offset: 0x0000C256
|
|
public bool IsValid()
|
|
{
|
|
return this.x > -1 && this.y > -1 && this.x != this.y;
|
|
}
|
|
|
|
// Token: 0x06000062 RID: 98 RVA: 0x0000DE84 File Offset: 0x0000C284
|
|
public override string ToString()
|
|
{
|
|
return string.Concat(new object[] { "[", this.x, ", ", this.y, "]" });
|
|
}
|
|
|
|
// Token: 0x06000063 RID: 99 RVA: 0x0000DED0 File Offset: 0x0000C2D0
|
|
public bool Equals(pb_Edge edge)
|
|
{
|
|
return edge != null && ((this.x == edge.x && this.y == edge.y) || (this.x == edge.y && this.y == edge.x));
|
|
}
|
|
|
|
// Token: 0x06000064 RID: 100 RVA: 0x0000DF2D File Offset: 0x0000C32D
|
|
public override bool Equals(object b)
|
|
{
|
|
return this.Equals(b as pb_Edge);
|
|
}
|
|
|
|
// Token: 0x06000065 RID: 101 RVA: 0x0000DF3C File Offset: 0x0000C33C
|
|
public override int GetHashCode()
|
|
{
|
|
int num = 27;
|
|
num = num * 29 + ((this.x >= this.y) ? this.y : this.x);
|
|
return num * 29 + ((this.x >= this.y) ? this.x : this.y);
|
|
}
|
|
|
|
// Token: 0x06000066 RID: 102 RVA: 0x0000DF9D File Offset: 0x0000C39D
|
|
public static pb_Edge operator +(pb_Edge a, pb_Edge b)
|
|
{
|
|
return new pb_Edge(a.x + b.x, a.y + b.y);
|
|
}
|
|
|
|
// Token: 0x06000067 RID: 103 RVA: 0x0000DFBE File Offset: 0x0000C3BE
|
|
public static pb_Edge operator -(pb_Edge a, pb_Edge b)
|
|
{
|
|
return new pb_Edge(a.x - b.x, a.y - b.y);
|
|
}
|
|
|
|
// Token: 0x06000068 RID: 104 RVA: 0x0000DFDF File Offset: 0x0000C3DF
|
|
public static pb_Edge operator +(pb_Edge a, int b)
|
|
{
|
|
return new pb_Edge(a.x + b, a.y + b);
|
|
}
|
|
|
|
// Token: 0x06000069 RID: 105 RVA: 0x0000DFF6 File Offset: 0x0000C3F6
|
|
public static pb_Edge operator -(pb_Edge a, int b)
|
|
{
|
|
return new pb_Edge(a.x - b, a.y - b);
|
|
}
|
|
|
|
// Token: 0x0600006A RID: 106 RVA: 0x0000E00D File Offset: 0x0000C40D
|
|
public int[] ToArray()
|
|
{
|
|
return new int[] { this.x, this.y };
|
|
}
|
|
|
|
// Token: 0x0600006B RID: 107 RVA: 0x0000E028 File Offset: 0x0000C428
|
|
public bool Equals(pb_Edge b, Dictionary<int, int> lookup)
|
|
{
|
|
int num = lookup[this.x];
|
|
int num2 = lookup[this.y];
|
|
int num3 = lookup[b.x];
|
|
int num4 = lookup[b.y];
|
|
return (num == num3 && num2 == num4) || (num == num4 && num2 == num3);
|
|
}
|
|
|
|
// Token: 0x0600006C RID: 108 RVA: 0x0000E088 File Offset: 0x0000C488
|
|
public bool Contains(int a)
|
|
{
|
|
return this.x == a || this.y == a;
|
|
}
|
|
|
|
// Token: 0x0600006D RID: 109 RVA: 0x0000E0A4 File Offset: 0x0000C4A4
|
|
public bool Contains(pb_Edge b)
|
|
{
|
|
return this.x == b.x || this.y == b.x || this.x == b.y || this.y == b.x;
|
|
}
|
|
|
|
// Token: 0x0600006E RID: 110 RVA: 0x0000E0F8 File Offset: 0x0000C4F8
|
|
public bool Contains(int a, pb_IntArray[] sharedIndices)
|
|
{
|
|
int num = sharedIndices.IndexOf(a);
|
|
return Array.IndexOf<int>(sharedIndices[num], this.x) > -1 || Array.IndexOf<int>(sharedIndices[num], this.y) > -1;
|
|
}
|
|
|
|
// Token: 0x0600006F RID: 111 RVA: 0x0000E140 File Offset: 0x0000C540
|
|
public static pb_Edge[] GetUniversalEdges(pb_Edge[] edges, Dictionary<int, int> sharedIndicesLookup)
|
|
{
|
|
pb_Edge[] array = new pb_Edge[edges.Length];
|
|
for (int i = 0; i < edges.Length; i++)
|
|
{
|
|
array[i] = new pb_Edge(sharedIndicesLookup[edges[i].x], sharedIndicesLookup[edges[i].y]);
|
|
}
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06000070 RID: 112 RVA: 0x0000E18F File Offset: 0x0000C58F
|
|
public static pb_Edge[] GetUniversalEdges(pb_Edge[] edges, pb_IntArray[] sharedIndices)
|
|
{
|
|
return pb_Edge.GetUniversalEdges(edges, sharedIndices.ToDictionary());
|
|
}
|
|
|
|
// Token: 0x06000071 RID: 113 RVA: 0x0000E19D File Offset: 0x0000C59D
|
|
public static pb_Edge GetLocalEdgeFast(pb_Edge edge, pb_IntArray[] sharedIndices)
|
|
{
|
|
return new pb_Edge(sharedIndices[edge.x][0], sharedIndices[edge.y][0]);
|
|
}
|
|
|
|
// Token: 0x06000072 RID: 114 RVA: 0x0000E1C0 File Offset: 0x0000C5C0
|
|
public static bool ValidateEdge(pb_Object pb, pb_Edge edge, out pb_Tuple<pb_Face, pb_Edge> validEdge)
|
|
{
|
|
pb_Face[] faces = pb.faces;
|
|
pb_IntArray[] sharedIndices = pb.sharedIndices;
|
|
pb_Edge pb_Edge = new pb_Edge(sharedIndices.IndexOf(edge.x), sharedIndices.IndexOf(edge.y));
|
|
int num = -1;
|
|
int num2 = -1;
|
|
int num3 = -1;
|
|
int num4 = -1;
|
|
for (int i = 0; i < faces.Length; i++)
|
|
{
|
|
if (faces[i].distinctIndices.ContainsMatch(sharedIndices[pb_Edge.x].array, out num, out num3) && faces[i].distinctIndices.ContainsMatch(sharedIndices[pb_Edge.y].array, out num2, out num4))
|
|
{
|
|
int num5 = faces[i].distinctIndices[num];
|
|
int num6 = faces[i].distinctIndices[num2];
|
|
validEdge = new pb_Tuple<pb_Face, pb_Edge>(faces[i], new pb_Edge(num5, num6));
|
|
return true;
|
|
}
|
|
}
|
|
validEdge = null;
|
|
return false;
|
|
}
|
|
|
|
// Token: 0x06000073 RID: 115 RVA: 0x0000E29C File Offset: 0x0000C69C
|
|
public static List<pb_Edge> ValidateEdges(pb_Object pb, pb_Edge[] edges)
|
|
{
|
|
pb_Face[] faces = pb.faces;
|
|
Dictionary<int, int> dictionary = pb.sharedIndices.ToDictionary();
|
|
HashSet<pb_EdgeLookup> hashSet = new HashSet<pb_EdgeLookup>(pb_EdgeLookup.GetEdgeLookup(edges, dictionary));
|
|
List<pb_Edge> list = new List<pb_Edge>();
|
|
bool flag = false;
|
|
int num = 0;
|
|
while (num < faces.Length && !flag)
|
|
{
|
|
pb_Edge[] edges2 = faces[num].edges;
|
|
int num2 = 0;
|
|
while (num2 < edges2.Length && !flag)
|
|
{
|
|
pb_EdgeLookup pb_EdgeLookup = new pb_EdgeLookup(dictionary[edges2[num2].x], dictionary[edges2[num2].y], edges2[num2].x, edges2[num2].y);
|
|
if (hashSet.Contains(pb_EdgeLookup))
|
|
{
|
|
hashSet.Remove(pb_EdgeLookup);
|
|
flag = hashSet.Count < 1;
|
|
list.Add(pb_EdgeLookup.local);
|
|
}
|
|
num2++;
|
|
}
|
|
num++;
|
|
}
|
|
return list;
|
|
}
|
|
|
|
// Token: 0x06000074 RID: 116 RVA: 0x0000E388 File Offset: 0x0000C788
|
|
public static pb_Edge[] GetLocalEdges_Fast(pb_Edge[] edges, pb_IntArray[] sharedIndices)
|
|
{
|
|
pb_Edge[] array = new pb_Edge[edges.Length];
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
array[i] = new pb_Edge(sharedIndices[edges[i].x][0], sharedIndices[edges[i].y][0]);
|
|
}
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06000075 RID: 117 RVA: 0x0000E3DC File Offset: 0x0000C7DC
|
|
public static pb_Edge[] AllEdges(pb_Face[] faces)
|
|
{
|
|
List<pb_Edge> list = new List<pb_Edge>();
|
|
foreach (pb_Face pb_Face in faces)
|
|
{
|
|
list.AddRange(pb_Face.edges);
|
|
}
|
|
return list.ToArray();
|
|
}
|
|
|
|
// Token: 0x06000076 RID: 118 RVA: 0x0000E41C File Offset: 0x0000C81C
|
|
public static bool ContainsDuplicateFast(pb_Edge[] edges, pb_Edge edge)
|
|
{
|
|
int num = 0;
|
|
for (int i = 0; i < edges.Length; i++)
|
|
{
|
|
if (edges[i].Equals(edge))
|
|
{
|
|
num++;
|
|
}
|
|
}
|
|
return num > 1;
|
|
}
|
|
|
|
// Token: 0x06000077 RID: 119 RVA: 0x0000E458 File Offset: 0x0000C858
|
|
public static Vector3[] VerticesWithEdges(pb_Edge[] edges, Vector3[] vertices)
|
|
{
|
|
Vector3[] array = new Vector3[edges.Length * 2];
|
|
int num = 0;
|
|
for (int i = 0; i < edges.Length; i++)
|
|
{
|
|
array[num++] = vertices[edges[i].x];
|
|
array[num++] = vertices[edges[i].y];
|
|
}
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06000078 RID: 120 RVA: 0x0000E4D0 File Offset: 0x0000C8D0
|
|
public static pb_Edge[] GetPerimeterEdges(pb_Edge[] edges)
|
|
{
|
|
int[] count = pbUtil.FilledArray<int>(0, edges.Length);
|
|
for (int i = 0; i < edges.Length - 1; i++)
|
|
{
|
|
for (int j = i + 1; j < edges.Length; j++)
|
|
{
|
|
if (edges[i].Equals(edges[j]))
|
|
{
|
|
count[i]++;
|
|
count[j]++;
|
|
}
|
|
}
|
|
}
|
|
return edges.Where((pb_Edge val, int index) => count[index] < 1).ToArray<pb_Edge>();
|
|
}
|
|
|
|
// Token: 0x04000085 RID: 133
|
|
public int x;
|
|
|
|
// Token: 0x04000086 RID: 134
|
|
public int y;
|
|
}
|
|
}
|