/// <summary> /// Gets a vector with the maximum x,y and z values of both vectors. /// </summary> /// <param name="value1">The first value.</param> /// <param name="value2">The second value.</param> /// <returns>A vector with the maximum x,y and z values of both vectors.</returns> #region public static JVector Max(JVector value1, JVector value2) public static TSVector Max(TSVector value1, TSVector value2) { TSVector result; TSVector.Max(ref value1, ref value2, out result); return(result); }
public static void CreateMerged(ref TSBBox original, ref TSBBox additional, out TSBBox result) { TSVector tSVector; TSVector.Min(ref original.min, ref additional.min, out tSVector); TSVector tSVector2; TSVector.Max(ref original.max, ref additional.max, out tSVector2); result.min = tSVector; result.max = tSVector2; }
public static TSBBox CreateFromPoints(TSVector[] points) { TSVector tSVector = new TSVector(FP.MaxValue); TSVector tSVector2 = new TSVector(FP.MinValue); for (int i = 0; i < points.Length; i++) { TSVector.Min(ref tSVector, ref points[i], out tSVector); TSVector.Max(ref tSVector2, ref points[i], out tSVector2); } return(new TSBBox(tSVector, tSVector2)); }
public void BuildOctree() { this.triBoxes = new TSBBox[this.tris.Length]; this.rootNodeBox = new TSBBox(new TSVector(FP.PositiveInfinity, FP.PositiveInfinity, FP.PositiveInfinity), new TSVector(FP.NegativeInfinity, FP.NegativeInfinity, FP.NegativeInfinity)); for (int i = 0; i < this.tris.Length; i++) { TSVector.Min(ref this.positions[this.tris[i].I1], ref this.positions[this.tris[i].I2], out this.triBoxes[i].min); TSVector.Min(ref this.positions[this.tris[i].I0], ref this.triBoxes[i].min, out this.triBoxes[i].min); TSVector.Max(ref this.positions[this.tris[i].I1], ref this.positions[this.tris[i].I2], out this.triBoxes[i].max); TSVector.Max(ref this.positions[this.tris[i].I0], ref this.triBoxes[i].max, out this.triBoxes[i].max); TSVector.Min(ref this.rootNodeBox.min, ref this.triBoxes[i].min, out this.rootNodeBox.min); TSVector.Max(ref this.rootNodeBox.max, ref this.triBoxes[i].max, out this.rootNodeBox.max); } List <Octree.BuildNode> list = new List <Octree.BuildNode>(); list.Add(new Octree.BuildNode()); list[0].box = this.rootNodeBox; TSBBox[] array = new TSBBox[8]; for (int j = 0; j < this.tris.Length; j++) { int num = 0; TSBBox tSBBox = this.rootNodeBox; while (tSBBox.Contains(ref this.triBoxes[j]) == TSBBox.ContainmentType.Contains) { int num2 = -1; for (int k = 0; k < 8; k++) { this.CreateAABox(ref tSBBox, (Octree.EChild)k, out array[k]); bool flag = array[k].Contains(ref this.triBoxes[j]) == TSBBox.ContainmentType.Contains; if (flag) { num2 = k; break; } } bool flag2 = num2 == -1; if (flag2) { list[num].triIndices.Add(j); break; } int num3 = -1; for (int l = 0; l < list[num].nodeIndices.Count; l++) { bool flag3 = list[list[num].nodeIndices[l]].childType == num2; if (flag3) { num3 = l; break; } } bool flag4 = num3 == -1; if (flag4) { Octree.BuildNode buildNode = list[num]; list.Add(new Octree.BuildNode { childType = num2, box = array[num2] }); num = list.Count - 1; tSBBox = array[num2]; buildNode.nodeIndices.Add(num); } else { num = list[num].nodeIndices[num3]; tSBBox = array[num2]; } } } this.nodes = new Octree.Node[list.Count]; this.nodeStackPool = new ArrayResourcePool <ushort>(list.Count); for (int m = 0; m < this.nodes.Length; m++) { this.nodes[m].nodeIndices = new ushort[list[m].nodeIndices.Count]; for (int n = 0; n < this.nodes[m].nodeIndices.Length; n++) { this.nodes[m].nodeIndices[n] = (ushort)list[m].nodeIndices[n]; } this.nodes[m].triIndices = new int[list[m].triIndices.Count]; list[m].triIndices.CopyTo(this.nodes[m].triIndices); this.nodes[m].box = list[m].box; } list.Clear(); }
public void AddPoint(ref TSVector point) { TSVector.Max(ref this.max, ref point, out this.max); TSVector.Min(ref this.min, ref point, out this.min); }