Beispiel #1
0
        private void AddVertices(ref RTBoundingBox boundingBox, Vector3 vertex)
        {
            Vector3 worldVex = transform.localToWorldMatrix.MultiplyPoint(vertex);

            boundingBox.min = Vector3.Min(boundingBox.min, worldVex);
            boundingBox.max = Vector3.Max(boundingBox.max, worldVex);
        }
 public RTBoundingBoxToGPU(RTBoundingBox boundingBox)
 {
     this.leftID  = boundingBox.leftID;
     this.rightID = boundingBox.rightID;
     this.max     = boundingBox.max;
     this.min     = boundingBox.min;
 }
        private static RTBoundingBox CombineAllBox(List <RTBoundingBox> boxes)
        {
            RTBoundingBox root = RTBoundingBox.Empty;

            foreach (var box in boxes)
            {
                root = Combine2Box(root, box);
            }
            return(root);
        }
        private static RTBoundingBox Combine2Box(RTBoundingBox a, RTBoundingBox b)
        {
            var max = Vector3.Max(a.max, b.max);
            var min = Vector3.Min(a.min, b.min);

            return(new RTBoundingBox(-1, -1,
                                     max,
                                     min,
                                     Mathf.Min(a.primitiveBegin, b.primitiveBegin),
                                     a.primitiveCount + b.primitiveCount));
        }
Beispiel #5
0
        public static RTBoundingBox RTBoundingBoxFromTriangle(int primitiveCounter, Vector3 v0, Vector3 v1, Vector3 v2)
        {
            RTBoundingBox box = Empty;

            AddVerticesToBox(ref box, v0);
            AddVerticesToBox(ref box, v1);
            AddVerticesToBox(ref box, v2);
            box.primitiveBegin = primitiveCounter;
            box.primitiveCount = 1;
            return(box);
        }
        private static RTBoundingBox Combine2Box(RTBoundingBox a, RTBoundingBox b)
        {
            var max = Vector3.Max(a.max, b.max);
            var min = Vector3.Min(a.min, b.min);

            a.geoIndices.UnionWith(b.geoIndices); // The union of triangle indices from both bounding boxes
                                                  // Use UnionWith instead of Linq Union to avoid creating a new IEnumerable

            return(new RTBoundingBox(-1,
                                     -1,
                                     max,
                                     min,
                                     a.geoIndices));
        }
        public static RTBoundingBox RTBoundingBoxFromTriangle(int triangleIndex, Vector3 v0, Vector3 v1, Vector3 v2)
        {
            RTBoundingBox box = new RTBoundingBox(
                leftID: -1,
                rightID: -1,
                max: new Vector3(float.MinValue, float.MinValue, float.MinValue),
                min: new Vector3(float.MaxValue, float.MaxValue, float.MaxValue),
                geoIndices: new HashSet <int>()
            {
                triangleIndex
            }
                );

            AddVerticesToBox(ref box, v0);
            AddVerticesToBox(ref box, v1);
            AddVerticesToBox(ref box, v2);

            return(box);
        }
 public void AddBoundingBox(RTBoundingBox box)
 {
     m_boxes.Add(box);
 }
Beispiel #9
0
 public void AddBoundingBox(RTBoundingBox box)
 {
     topLevelBVH.AddBoundingBox(box);
 }
 public static void AddVerticesToBox(ref RTBoundingBox boundingBox, Vector3 vertex)
 {
     boundingBox.min = Vector3.Min(boundingBox.min, vertex);
     boundingBox.max = Vector3.Max(boundingBox.max, vertex);
 }