219 lines
6.4 KiB
C#
219 lines
6.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace ProBuilder2.Common
|
|
{
|
|
// Token: 0x0200005C RID: 92
|
|
public class pb_WingedEdge : IEquatable<pb_WingedEdge>, IEnumerable
|
|
{
|
|
// Token: 0x060002B7 RID: 695 RVA: 0x00020F55 File Offset: 0x0001F355
|
|
public bool Equals(pb_WingedEdge b)
|
|
{
|
|
return b != null && this.edge.local.Equals(b.edge.local);
|
|
}
|
|
|
|
// Token: 0x060002B8 RID: 696 RVA: 0x00020F7C File Offset: 0x0001F37C
|
|
public override bool Equals(object b)
|
|
{
|
|
pb_WingedEdge pb_WingedEdge = b as pb_WingedEdge;
|
|
if (pb_WingedEdge != null && this.Equals(pb_WingedEdge))
|
|
{
|
|
return true;
|
|
}
|
|
pb_Edge pb_Edge = b as pb_Edge;
|
|
return pb_Edge == null || !this.Equals(pb_Edge) || true;
|
|
}
|
|
|
|
// Token: 0x060002B9 RID: 697 RVA: 0x00020FC0 File Offset: 0x0001F3C0
|
|
public override int GetHashCode()
|
|
{
|
|
return this.edge.local.GetHashCode();
|
|
}
|
|
|
|
// Token: 0x060002BA RID: 698 RVA: 0x00020FD2 File Offset: 0x0001F3D2
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return this.GetEnumerator();
|
|
}
|
|
|
|
// Token: 0x060002BB RID: 699 RVA: 0x00020FDA File Offset: 0x0001F3DA
|
|
public pb_WingedEdgeEnumerator GetEnumerator()
|
|
{
|
|
return new pb_WingedEdgeEnumerator(this);
|
|
}
|
|
|
|
// Token: 0x060002BC RID: 700 RVA: 0x00020FE4 File Offset: 0x0001F3E4
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Common: {0}\nLocal: {1}\nOpposite: {2}\nFace: {3}", new object[]
|
|
{
|
|
this.edge.common.ToString(),
|
|
this.edge.local.ToString(),
|
|
(this.opposite != null) ? this.opposite.edge.ToString() : "null",
|
|
this.face.ToString()
|
|
});
|
|
}
|
|
|
|
// Token: 0x060002BD RID: 701 RVA: 0x00021060 File Offset: 0x0001F460
|
|
public pb_WingedEdge GetAdjacentEdgeWithCommonIndex(int common)
|
|
{
|
|
if (this.next.edge.common.Contains(common))
|
|
{
|
|
return this.next;
|
|
}
|
|
if (this.previous.edge.common.Contains(common))
|
|
{
|
|
return this.previous;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// Token: 0x060002BE RID: 702 RVA: 0x000210B4 File Offset: 0x0001F4B4
|
|
public static List<pb_Edge> SortEdgesByAdjacency(pb_Face face)
|
|
{
|
|
List<pb_Edge> list = new List<pb_Edge>(face.edges);
|
|
return pb_WingedEdge.SortEdgesByAdjacency(list);
|
|
}
|
|
|
|
// Token: 0x060002BF RID: 703 RVA: 0x000210D4 File Offset: 0x0001F4D4
|
|
public static List<pb_Edge> SortEdgesByAdjacency(List<pb_Edge> edges)
|
|
{
|
|
for (int i = 1; i < edges.Count; i++)
|
|
{
|
|
int y = edges[i - 1].y;
|
|
for (int j = i + 1; j < edges.Count; j++)
|
|
{
|
|
if (edges[j].x == y || edges[j].y == y)
|
|
{
|
|
pb_Edge pb_Edge = edges[j];
|
|
edges[j] = edges[i];
|
|
edges[i] = pb_Edge;
|
|
}
|
|
}
|
|
}
|
|
return edges;
|
|
}
|
|
|
|
// Token: 0x060002C0 RID: 704 RVA: 0x00021164 File Offset: 0x0001F564
|
|
public static Dictionary<int, List<pb_WingedEdge>> GetSpokes(List<pb_WingedEdge> wings)
|
|
{
|
|
Dictionary<int, List<pb_WingedEdge>> dictionary = new Dictionary<int, List<pb_WingedEdge>>();
|
|
List<pb_WingedEdge> list = null;
|
|
for (int i = 0; i < wings.Count; i++)
|
|
{
|
|
if (dictionary.TryGetValue(wings[i].edge.common.x, out list))
|
|
{
|
|
list.Add(wings[i]);
|
|
}
|
|
else
|
|
{
|
|
dictionary.Add(wings[i].edge.common.x, new List<pb_WingedEdge> { wings[i] });
|
|
}
|
|
if (dictionary.TryGetValue(wings[i].edge.common.y, out list))
|
|
{
|
|
list.Add(wings[i]);
|
|
}
|
|
else
|
|
{
|
|
dictionary.Add(wings[i].edge.common.y, new List<pb_WingedEdge> { wings[i] });
|
|
}
|
|
}
|
|
return dictionary;
|
|
}
|
|
|
|
// Token: 0x060002C1 RID: 705 RVA: 0x0002125C File Offset: 0x0001F65C
|
|
public static List<int> SortCommonIndicesByAdjacency(List<pb_WingedEdge> wings, HashSet<int> common)
|
|
{
|
|
List<pb_Edge> list = (from x in wings
|
|
where common.Contains(x.edge.common.x) && common.Contains(x.edge.common.y)
|
|
select x into y
|
|
select y.edge.common).ToList<pb_Edge>();
|
|
if (list.Count != common.Count)
|
|
{
|
|
return null;
|
|
}
|
|
return (from x in pb_WingedEdge.SortEdgesByAdjacency(list)
|
|
select x.x).ToList<int>();
|
|
}
|
|
|
|
// Token: 0x060002C2 RID: 706 RVA: 0x000212F5 File Offset: 0x0001F6F5
|
|
public static List<pb_WingedEdge> GetWingedEdges(pb_Object pb, bool oneWingPerFace = false)
|
|
{
|
|
return pb_WingedEdge.GetWingedEdges(pb, pb.faces, oneWingPerFace, null);
|
|
}
|
|
|
|
// Token: 0x060002C3 RID: 707 RVA: 0x00021308 File Offset: 0x0001F708
|
|
public static List<pb_WingedEdge> GetWingedEdges(pb_Object pb, IEnumerable<pb_Face> faces, bool oneWingPerFace = false, Dictionary<int, int> sharedIndexLookup = null)
|
|
{
|
|
Dictionary<int, int> dictionary = ((sharedIndexLookup != null) ? sharedIndexLookup : pb.sharedIndices.ToDictionary());
|
|
IEnumerable<pb_Face> enumerable = faces.Distinct<pb_Face>();
|
|
List<pb_WingedEdge> list = new List<pb_WingedEdge>();
|
|
Dictionary<pb_Edge, pb_WingedEdge> dictionary2 = new Dictionary<pb_Edge, pb_WingedEdge>();
|
|
int num = 0;
|
|
foreach (pb_Face pb_Face in enumerable)
|
|
{
|
|
List<pb_Edge> list2 = pb_WingedEdge.SortEdgesByAdjacency(pb_Face);
|
|
int count = list2.Count;
|
|
pb_WingedEdge pb_WingedEdge = null;
|
|
pb_WingedEdge pb_WingedEdge2 = null;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
pb_Edge pb_Edge = list2[i];
|
|
pb_WingedEdge pb_WingedEdge3 = new pb_WingedEdge();
|
|
pb_WingedEdge3.edge = new pb_EdgeLookup(dictionary[pb_Edge.x], dictionary[pb_Edge.y], pb_Edge.x, pb_Edge.y);
|
|
pb_WingedEdge3.face = pb_Face;
|
|
if (i < 1)
|
|
{
|
|
pb_WingedEdge = pb_WingedEdge3;
|
|
}
|
|
if (i > 0)
|
|
{
|
|
pb_WingedEdge3.previous = pb_WingedEdge2;
|
|
pb_WingedEdge2.next = pb_WingedEdge3;
|
|
}
|
|
if (i == count - 1)
|
|
{
|
|
pb_WingedEdge3.next = pb_WingedEdge;
|
|
pb_WingedEdge.previous = pb_WingedEdge3;
|
|
}
|
|
pb_WingedEdge2 = pb_WingedEdge3;
|
|
pb_WingedEdge pb_WingedEdge4;
|
|
if (dictionary2.TryGetValue(pb_WingedEdge3.edge.common, out pb_WingedEdge4))
|
|
{
|
|
pb_WingedEdge4.opposite = pb_WingedEdge3;
|
|
pb_WingedEdge3.opposite = pb_WingedEdge4;
|
|
}
|
|
else
|
|
{
|
|
pb_WingedEdge3.opposite = null;
|
|
dictionary2.Add(pb_WingedEdge3.edge.common, pb_WingedEdge3);
|
|
}
|
|
if (!oneWingPerFace || i < 1)
|
|
{
|
|
list.Add(pb_WingedEdge3);
|
|
}
|
|
}
|
|
num += count;
|
|
}
|
|
return list;
|
|
}
|
|
|
|
// Token: 0x040001EB RID: 491
|
|
public pb_EdgeLookup edge;
|
|
|
|
// Token: 0x040001EC RID: 492
|
|
public pb_Face face;
|
|
|
|
// Token: 0x040001ED RID: 493
|
|
public pb_WingedEdge next;
|
|
|
|
// Token: 0x040001EE RID: 494
|
|
public pb_WingedEdge previous;
|
|
|
|
// Token: 0x040001EF RID: 495
|
|
public pb_WingedEdge opposite;
|
|
}
|
|
}
|