using System; using System.Collections.Generic; namespace Parabox.CSG { // Token: 0x02000017 RID: 23 internal class CSG_Node { // Token: 0x060000AB RID: 171 RVA: 0x0000D7F5 File Offset: 0x0000BBF5 public CSG_Node() { this.front = null; this.back = null; } // Token: 0x060000AC RID: 172 RVA: 0x0000D80B File Offset: 0x0000BC0B public CSG_Node(List list) { this.Build(list); } // Token: 0x060000AD RID: 173 RVA: 0x0000D81A File Offset: 0x0000BC1A public CSG_Node(List list, CSG_Plane plane, CSG_Node front, CSG_Node back) { this.polygons = list; this.plane = plane; this.front = front; this.back = back; } // Token: 0x060000AE RID: 174 RVA: 0x0000D840 File Offset: 0x0000BC40 public CSG_Node Clone() { return new CSG_Node(this.polygons, this.plane, this.front, this.back); } // Token: 0x060000AF RID: 175 RVA: 0x0000D86C File Offset: 0x0000BC6C public void ClipTo(CSG_Node other) { this.polygons = other.ClipPolygons(this.polygons); if (this.front != null) { this.front.ClipTo(other); } if (this.back != null) { this.back.ClipTo(other); } } // Token: 0x060000B0 RID: 176 RVA: 0x0000D8BC File Offset: 0x0000BCBC public void Invert() { for (int i = 0; i < this.polygons.Count; i++) { this.polygons[i].Flip(); } this.plane.Flip(); if (this.front != null) { this.front.Invert(); } if (this.back != null) { this.back.Invert(); } CSG_Node csg_Node = this.front; this.front = this.back; this.back = csg_Node; } // Token: 0x060000B1 RID: 177 RVA: 0x0000D948 File Offset: 0x0000BD48 public void Build(List list) { if (list.Count < 1) { return; } if (this.plane == null || !this.plane.Valid()) { this.plane = new CSG_Plane(); this.plane.normal = list[0].plane.normal; this.plane.w = list[0].plane.w; } if (this.polygons == null) { this.polygons = new List(); } List list2 = new List(); List list3 = new List(); for (int i = 0; i < list.Count; i++) { this.plane.SplitPolygon(list[i], this.polygons, this.polygons, list2, list3); } if (list2.Count > 0) { if (this.front == null) { this.front = new CSG_Node(); } this.front.Build(list2); } if (list3.Count > 0) { if (this.back == null) { this.back = new CSG_Node(); } this.back.Build(list3); } } // Token: 0x060000B2 RID: 178 RVA: 0x0000DA78 File Offset: 0x0000BE78 public List ClipPolygons(List list) { if (!this.plane.Valid()) { return list; } List list2 = new List(); List list3 = new List(); for (int i = 0; i < list.Count; i++) { this.plane.SplitPolygon(list[i], list2, list3, list2, list3); } if (this.front != null) { list2 = this.front.ClipPolygons(list2); } if (this.back != null) { list3 = this.back.ClipPolygons(list3); } else { list3.Clear(); } list2.AddRange(list3); return list2; } // Token: 0x060000B3 RID: 179 RVA: 0x0000DB14 File Offset: 0x0000BF14 public List AllPolygons() { List list = this.polygons; List list2 = new List(); List list3 = new List(); if (this.front != null) { list2 = this.front.AllPolygons(); } if (this.back != null) { list3 = this.back.AllPolygons(); } list.AddRange(list2); list.AddRange(list3); return list; } // Token: 0x060000B4 RID: 180 RVA: 0x0000DB74 File Offset: 0x0000BF74 public static CSG_Node Union(CSG_Node a1, CSG_Node b1) { CSG_Node csg_Node = a1.Clone(); CSG_Node csg_Node2 = b1.Clone(); csg_Node.ClipTo(csg_Node2); csg_Node2.ClipTo(csg_Node); csg_Node2.Invert(); csg_Node2.ClipTo(csg_Node); csg_Node2.Invert(); csg_Node.Build(csg_Node2.AllPolygons()); return new CSG_Node(csg_Node.AllPolygons()); } // Token: 0x060000B5 RID: 181 RVA: 0x0000DBCC File Offset: 0x0000BFCC public static CSG_Node Subtract(CSG_Node a1, CSG_Node b1) { CSG_Node csg_Node = a1.Clone(); CSG_Node csg_Node2 = b1.Clone(); csg_Node.Invert(); csg_Node.ClipTo(csg_Node2); csg_Node2.ClipTo(csg_Node); csg_Node2.Invert(); csg_Node2.ClipTo(csg_Node); csg_Node2.Invert(); csg_Node.Build(csg_Node2.AllPolygons()); csg_Node.Invert(); return new CSG_Node(csg_Node.AllPolygons()); } // Token: 0x060000B6 RID: 182 RVA: 0x0000DC30 File Offset: 0x0000C030 public static CSG_Node Intersect(CSG_Node a1, CSG_Node b1) { CSG_Node csg_Node = a1.Clone(); CSG_Node csg_Node2 = b1.Clone(); csg_Node.Invert(); csg_Node2.ClipTo(csg_Node); csg_Node2.Invert(); csg_Node.ClipTo(csg_Node2); csg_Node2.ClipTo(csg_Node); csg_Node.Build(csg_Node2.AllPolygons()); csg_Node.Invert(); return new CSG_Node(csg_Node.AllPolygons()); } // Token: 0x04000032 RID: 50 public List polygons; // Token: 0x04000033 RID: 51 public CSG_Node front; // Token: 0x04000034 RID: 52 public CSG_Node back; // Token: 0x04000035 RID: 53 public CSG_Plane plane; } }