Ejemplo n.º 1
0
        /// <summary>
        /// Create a bounding volume hierarchy for the given mesh.
        /// </summary>
        /// <param name="mesh">The mesh to add the BVH to.</param>
        /// <returns>The created BVH tree.</returns>
        public static ITraceable CreateBVHData(this Mesh mesh, BvhCreationOptions bvhCreationOptions = BvhCreationOptions.LegacySlowConstructionFastTracing)
        {
            // test new BvHBuilderAac
            // BvhBuilderAac.Create(mesh);

            var allPolys = new List <ITraceable>();

            mesh.AddTraceables(null, Matrix4X4.Identity, allPolys);

            return(BoundingVolumeHierarchy.CreateNewHierachy(allPolys, bvhCreationOptions));
        }
        public static ITraceable CreateNewHierachy(List <ITraceable> tracePrimitives, BvhCreationOptions bvhCreationOptions = BvhCreationOptions.LegacySlowConstructionFastTracing)
        {
            ITraceable output = null;

            using (new QuickTimer("LocalOrderClustering", 1))
            {
                //output = BvhBuilderLocallyOrderedClustering.Create(tracePrimitives);
                //return output;
            }

            switch (bvhCreationOptions)
            {
            case BvhCreationOptions.LegacyFastConstructionSlowTracing:
                using (new QuickTimer("LegacyFastConstructionSlowTracing", 1))
                {
                    output = BvhBuilderBottomUp.Create(tracePrimitives, 0);
                }
                break;

            case BvhCreationOptions.LegacySlowConstructionFastTracing:
                using (new QuickTimer("LegacySlowConstructionFastTracing", 1))
                {
                    output = BvhBuilderBottomUp.Create(tracePrimitives);
                }
                break;

            case BvhCreationOptions.LocFastContructionFastTracing:
                using (new QuickTimer("LocFastContructionFastTracing", 1))
                {
                    output = BvhBuilderLocallyOrderedClustering.Create(tracePrimitives);
                }
                break;

            default:
                output = BvhBuilderBottomUp.Create(tracePrimitives);
                break;
            }

            return(output);
        }
Ejemplo n.º 3
0
        public static ITraceable CreateTraceData(FaceList faceList, List <Vector3Float> vertexList, BvhCreationOptions bvhCreationOptions = BvhCreationOptions.FavorFastTracing)
        {
            var allPolys = new List <ITraceable>();

            foreach (var face in faceList)
            {
                allPolys.Add(new TriangleShape(vertexList[face.v0], vertexList[face.v1], vertexList[face.v2], null));
            }

            return(BoundingVolumeHierarchy.CreateNewHierachy(allPolys, bvhCreationOptions));
        }