private BoundingBox CreateAABox(BoundingBox aabb, EChild child) { var dims = 0.5f * (aabb.Max - aabb.Min); var offset = new Vector3(); switch (child) { case EChild.PPP: offset = new Vector3(1, 1, 1); break; case EChild.PPM: offset = new Vector3(1, 1, 0); break; case EChild.PMP: offset = new Vector3(1, 0, 1); break; case EChild.PMM: offset = new Vector3(1, 0, 0); break; case EChild.MPP: offset = new Vector3(0, 1, 1); break; case EChild.MPM: offset = new Vector3(0, 1, 0); break; case EChild.MMP: offset = new Vector3(0, 0, 1); break; case EChild.MMM: offset = new Vector3(0, 0, 0); break; default: Debug.WriteLine("Octree.CreateAABox got impossible child"); break; } var result = new BoundingBox(); result.Min = aabb.Min + new Vector3(offset.X * dims.X, offset.Y * dims.Y, offset.Z * dims.Z); result.Max = result.Min + dims; var extra = 0.00001f; result.Min -= extra * dims; result.Max += extra * dims; return(result); }
/// <summary> /// Create a bounding box appropriate for a child, based on a parents AABox /// </summary> /// <param name="aabb"></param> /// <param name="child"></param> /// <param name="result"></param> #region private void CreateAABox(ref JBBox aabb, EChild child,out JBBox result) private void CreateAABox(ref TSBBox aabb, EChild child, out TSBBox result) { TSVector dims; TSVector.Subtract(ref aabb.max, ref aabb.min, out dims); TSVector.Multiply(ref dims, FP.Half, out dims); TSVector offset = TSVector.zero; switch (child) { case EChild.PPP: offset = new TSVector(1, 1, 1); break; case EChild.PPM: offset = new TSVector(1, 1, 0); break; case EChild.PMP: offset = new TSVector(1, 0, 1); break; case EChild.PMM: offset = new TSVector(1, 0, 0); break; case EChild.MPP: offset = new TSVector(0, 1, 1); break; case EChild.MPM: offset = new TSVector(0, 1, 0); break; case EChild.MMP: offset = new TSVector(0, 0, 1); break; case EChild.MMM: offset = new TSVector(0, 0, 0); break; default: System.Diagnostics.Debug.WriteLine("Octree.CreateAABox got impossible child"); break; } result = new TSBBox(); result.min = new TSVector(offset.x * dims.x, offset.y * dims.y, offset.z * dims.z); TSVector.Add(ref result.min, ref aabb.min, out result.min); TSVector.Add(ref result.min, ref dims, out result.max); // expand it just a tiny bit just to be safe! FP extra = FP.EN5; TSVector temp; TSVector.Multiply(ref dims, extra, out temp); TSVector.Subtract(ref result.min, ref temp, out result.min); TSVector.Add(ref result.max, ref temp, out result.max); }
/// <summary> /// Create a bounding box appropriate for a child, based on a parents AABox /// </summary> /// <param name="aabb"></param> /// <param name="child"></param> /// <param name="result"></param> #region private void CreateAABox(ref JBBox aabb, EChild child,out JBBox result) private void CreateAABox(ref JBBox aabb, EChild child, out JBBox result) { JVector dims; JVector.Subtract(ref aabb.Max, ref aabb.Min, out dims); JVector.Multiply(ref dims, 0.5f, out dims); JVector offset = JVector.Zero; switch (child) { case EChild.PPP: offset = new JVector(1, 1, 1); break; case EChild.PPM: offset = new JVector(1, 1, 0); break; case EChild.PMP: offset = new JVector(1, 0, 1); break; case EChild.PMM: offset = new JVector(1, 0, 0); break; case EChild.MPP: offset = new JVector(0, 1, 1); break; case EChild.MPM: offset = new JVector(0, 1, 0); break; case EChild.MMP: offset = new JVector(0, 0, 1); break; case EChild.MMM: offset = new JVector(0, 0, 0); break; default: System.Diagnostics.Debug.WriteLine("Octree.CreateAABox got impossible child"); break; } result = new JBBox(); result.Min = new JVector(offset.X * dims.X, offset.Y * dims.Y, offset.Z * dims.Z); JVector.Add(ref result.Min, ref aabb.Min, out result.Min); JVector.Add(ref result.Min, ref dims, out result.Max); // expand it just a tiny bit just to be safe! double extra = 0.00001f; JVector temp; JVector.Multiply(ref dims, extra, out temp); JVector.Subtract(ref result.Min, ref temp, out result.Min); JVector.Add(ref result.Max, ref temp, out result.Max); }
/// <summary> /// Create a bounding box appropriate for a child, based on a parents AABox /// </summary> /// <param name="aabb"></param> /// <param name="child"></param> /// <param name="result"></param> #region private void CreateAABox(ref JBBox aabb, EChild child,out JBBox result) private void CreateAABox(ref BBox aabb, EChild child, out BBox result) { Vector3 dims; Vector3.Subtract(ref aabb.Max, ref aabb.Min, out dims); Vector3.Multiply(ref dims, 0.5f, out dims); Vector3 offset = Vector3.zero; switch (child) { case EChild.PPP: offset = new Vector3(1, 1, 1); break; case EChild.PPM: offset = new Vector3(1, 1, 0); break; case EChild.PMP: offset = new Vector3(1, 0, 1); break; case EChild.PMM: offset = new Vector3(1, 0, 0); break; case EChild.MPP: offset = new Vector3(0, 1, 1); break; case EChild.MPM: offset = new Vector3(0, 1, 0); break; case EChild.MMP: offset = new Vector3(0, 0, 1); break; case EChild.MMM: offset = new Vector3(0, 0, 0); break; default: System.Diagnostics.Debug.WriteLine("Octree.CreateAABox got impossible child"); break; } result = new BBox(); result.Min = new Vector3(offset.x * dims.x, offset.y * dims.y, offset.z * dims.z); Vector3.Add(ref result.Min, ref aabb.Min, out result.Min); Vector3.Add(ref result.Min, ref dims, out result.Max); // expand it just a tiny bit just to be safe! float extra = 0.00001f; Vector3 temp; Vector3.Multiply(ref dims, extra, out temp); Vector3.Subtract(ref result.Min, ref temp, out result.Min); Vector3.Add(ref result.Max, ref temp, out result.Max); }
/// <summary> /// Create a bounding box appropriate for a child, based on a parents AABox /// </summary> /// <param name="aabb"></param> /// <param name="child"></param> /// <returns>BoundingBox</returns> private BoundingBox CreateAABox(BoundingBox aabb, EChild child) { Vector3 dims = 0.5f * (aabb.Max - aabb.Min); Vector3 offset = new Vector3(); switch (child) { case EChild.PPP: offset = new Vector3(1, 1, 1); break; case EChild.PPM: offset = new Vector3(1, 1, 0); break; case EChild.PMP: offset = new Vector3(1, 0, 1); break; case EChild.PMM: offset = new Vector3(1, 0, 0); break; case EChild.MPP: offset = new Vector3(0, 1, 1); break; case EChild.MPM: offset = new Vector3(0, 1, 0); break; case EChild.MMP: offset = new Vector3(0, 0, 1); break; case EChild.MMM: offset = new Vector3(0, 0, 0); break; default: System.Diagnostics.Debug.WriteLine("Octree.CreateAABox got impossible child"); //TRACE("tOctree::CreateAABox Got impossible child: %d", child); //offset.Set(0, 0, 0); break; } BoundingBox result = new BoundingBox(); result.Min = (aabb.Min + new Vector3(offset.X * dims.X, offset.Y * dims.Y, offset.Z * dims.Z)); result.Max = (result.Min + dims); // expand it just a tiny bit just to be safe! float extra = 0.00001f; result.Min = (result.Min - extra * dims); result.Max = (result.Max + extra * dims); return(result); }
/// <summary> /// Create a bounding box appropriate for a child, based on a parents AABox /// </summary> /// <param name="aabb"></param> /// <param name="child"></param> /// <returns></returns> private BoundingBox CreateAABox(BoundingBox aabb, EChild child) { Vector3 dims = 0.5f * (aabb.Max - aabb.Min); Vector3 offset = new Vector3(); switch (child) { case EChild.PPP: offset = new Vector3(1, 1, 1); break; case EChild.PPM: offset = new Vector3(1, 1, 0); break; case EChild.PMP: offset = new Vector3(1, 0, 1); break; case EChild.PMM: offset = new Vector3(1, 0, 0); break; case EChild.MPP: offset = new Vector3(0, 1, 1); break; case EChild.MPM: offset = new Vector3(0, 1, 0); break; case EChild.MMP: offset = new Vector3(0, 0, 1); break; case EChild.MMM: offset = new Vector3(0, 0, 0); break; default: System.Diagnostics.Debug.WriteLine("Octree.CreateAABox got impossible child"); //TRACE("tOctree::CreateAABox Got impossible child: %d", child); //offset.Set(0, 0, 0); break; } BoundingBox result = new BoundingBox(); result.Min = (aabb.Min + new Vector3(offset.X * dims.X, offset.Y * dims.Y, offset.Z * dims.Z)); result.Max = (result.Min + dims); // expand it just a tiny bit just to be safe! float extra = 0.00001f; result.Min = (result.Min - extra * dims); result.Max = (result.Max + extra * dims); return result; }
/// <summary> /// Create a bounding box appropriate for a child, based on a parents AABox /// </summary> /// <param name="aabb"></param> /// <param name="child"></param> /// <param name="result"></param> #region private void CreateAABox(ref JBBox aabb, EChild child,out JBBox result) private void CreateAABox(ref JBBox aabb, EChild child,out JBBox result) { JVector dims; JVector.Subtract(ref aabb.Max, ref aabb.Min, out dims); JVector.Multiply(ref dims, 0.5f, out dims); JVector offset = JVector.Zero; switch (child) { case EChild.PPP: offset = new JVector(1, 1, 1); break; case EChild.PPM: offset = new JVector(1, 1, 0); break; case EChild.PMP: offset = new JVector(1, 0, 1); break; case EChild.PMM: offset = new JVector(1, 0, 0); break; case EChild.MPP: offset = new JVector(0, 1, 1); break; case EChild.MPM: offset = new JVector(0, 1, 0); break; case EChild.MMP: offset = new JVector(0, 0, 1); break; case EChild.MMM: offset = new JVector(0, 0, 0); break; default: System.Diagnostics.Debug.WriteLine("Octree.CreateAABox got impossible child"); break; } result = new JBBox(); result.Min = new JVector(offset.X * dims.X, offset.Y * dims.Y, offset.Z * dims.Z); JVector.Add(ref result.Min, ref aabb.Min, out result.Min); JVector.Add(ref result.Min, ref dims, out result.Max); // expand it just a tiny bit just to be safe! float extra = 0.00001f; JVector temp; JVector.Multiply(ref dims, extra, out temp); JVector.Subtract(ref result.Min, ref temp, out result.Min); JVector.Add(ref result.Max, ref temp, out result.Max); }