public void NodeCount() { const int primitiveCount = 1_000; for (int i = 0; i < 10; i++) { BVHTree bvh = RandomBVH(primitiveCount); int nodeCount = CountNodes(bvh.Root); Debug.WriteLine($"Node count in percentage of primitives: {(float)nodeCount / primitiveCount}"); Assert.IsTrue(nodeCount <= primitiveCount * 2); }
public void LoadTile(WowContinent continent, int x, int y) { Scene = _builder.BuildTile(MpqFilePaths.MapToInternalName(continent), x, y); BVHTree = new BVHTree( Scene.Terrain .Concat(Scene.Liquids) .Concat(Scene.Doodads) .Concat(Scene.Wmos)); BuildResult = null; if (CurrentNavigationMeshRenderer != null) CurrentNavigationMeshRenderer.ClearCache(); TileLoaded(this, EventArgs.Empty); }
public void LoadTile(WowContinent continent, int x, int y) { Scene = _builder.BuildTile(MpqFilePaths.MapToInternalName(continent), x, y); BVHTree = new BVHTree( Scene.Terrain .Concat(Scene.Liquids) .Concat(Scene.Doodads) .Concat(Scene.Wmos)); BuildResult = null; if (CurrentNavigationMeshRenderer != null) { CurrentNavigationMeshRenderer.ClearCache(); } TileLoaded(this, EventArgs.Empty); }
protected void BuildBVH(GeometryDescriptor <VertexPositionNormalTextureTangentBitangent> PNTTBGeometryDescriptor, GeometryDescriptor <VertexPositionNormal> PNGeometryDescriptor, GeometryDescriptor <VertexPositionTexture> PTGeometryDescriptor, GeometryDescriptor <VertexPositionColor> PCGeometryDescriptor, GeometryDescriptor <VertexPosition> PGeometryDescriptor) { var splitMethod = SplitMethods.SAH; var PNTTBMeshBVHArray = PNTTBGeometryDescriptor.MeshBVHArray; var PNMeshBVHArray = PNGeometryDescriptor.MeshBVHArray; var PTMeshBVHArray = PTGeometryDescriptor.MeshBVHArray; var PCMeshBVHArray = PCGeometryDescriptor.MeshBVHArray; var PMeshBVHArray = PGeometryDescriptor.MeshBVHArray; var tuplePNTTB = BVHTreeBuilder <MeshBVH <VertexPositionNormalTextureTangentBitangent> > .Build(PNTTBMeshBVHArray, splitMethod); BVHTree PNTTBTree = tuplePNTTB.Item1; PNTTBMeshBVHArray = tuplePNTTB.Item2; int PNTTBTotalNodes = tuplePNTTB.Item3; var tuplePN = BVHTreeBuilder <MeshBVH <VertexPositionNormal> > .Build(PNMeshBVHArray, splitMethod); BVHTree PNTree = tuplePN.Item1; PNMeshBVHArray = tuplePN.Item2; int PNTotalNodes = tuplePN.Item3; var tuplePT = BVHTreeBuilder <MeshBVH <VertexPositionTexture> > .Build(PTMeshBVHArray, splitMethod); BVHTree PTTree = tuplePT.Item1; PTMeshBVHArray = tuplePT.Item2; int PTTotalNodes = tuplePT.Item3; var tuplePC = BVHTreeBuilder <MeshBVH <VertexPositionColor> > .Build(PCMeshBVHArray, splitMethod); BVHTree PCTree = tuplePC.Item1; PCMeshBVHArray = tuplePC.Item2; int PCTotalNodes = tuplePC.Item3; _bvhRuntimeNodesPNTTB = BVHRuntime.ConstructBVHRuntime(PNTTBTree, PNTTBTotalNodes); _bvhRuntimeNodesPN = BVHRuntime.ConstructBVHRuntime(PNTree, PNTotalNodes); _bvhRuntimeNodesPT = BVHRuntime.ConstructBVHRuntime(PTTree, PTTotalNodes); _bvhRuntimeNodesPC = BVHRuntime.ConstructBVHRuntime(PCTree, PCTotalNodes); var maxPrimitives = Math.Max(PNTTBMeshBVHArray.Length, Math.Max(PNMeshBVHArray.Length, Math.Max(PTMeshBVHArray.Length, PCMeshBVHArray.Length))); _bvhTraversalStack = new int[maxPrimitives]; }
public void initBVHTreeDataBase() { directionalLights = new List <DirectionalLight>(); pointLights = new List <PointLight>(); collectLightData(); materials = new List <RTMaterial>(); materialMap = new Dictionary <string, uint>(); KDtriangles = new List <Triangle>(); collectDataForBVHTree(); BVHTreeList = new List <RTBVHNode>(); triangleList = new List <RTTriangle>(); BVHTree tree = new BVHTree(KDtriangles, useBVHTreeStructure); BVHNode root = tree.root; BVHTreeToArrayDfs(root, BVHTreeList, triangleList, 0); }