ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/OniSplit/Akira/OctreeBuilder.cs
Revision: 1114
Committed: Wed Jan 22 14:08:57 2020 UTC (5 years, 8 months ago) by iritscen
File size: 1430 byte(s)
Log Message:
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3
4 namespace Oni.Akira
5 {
6 internal static class OctreeBuilder
7 {
8 private static readonly BoundingBox rootBoundingBox = new BoundingBox(new Vector3(-4096.0f), new Vector3(4096.0f));
9
10 public static OctreeNode Build(PolygonMesh mesh, bool debug)
11 {
12 IEnumerable<Polygon> polygons = mesh.Polygons;
13
14 if (debug)
15 polygons = polygons.Concatenate(mesh.Ghosts);
16
17 var root = new OctreeNode(rootBoundingBox, polygons, mesh.Rooms);
18 root.Build();
19 return root;
20 }
21
22 public static OctreeNode Build(PolygonMesh mesh, GunkFlags excludeFlags)
23 {
24 var root = new OctreeNode(rootBoundingBox, mesh.Polygons.Where(p => (p.Flags & excludeFlags) == 0), mesh.Rooms);
25 root.Build();
26 return root;
27 }
28
29 public static OctreeNode Build(PolygonMesh mesh, Func<Polygon, bool> polygonFilter)
30 {
31 var root = new OctreeNode(rootBoundingBox, mesh.Polygons.Where(polygonFilter), mesh.Rooms);
32 root.Build();
33 return root;
34 }
35
36 public static OctreeNode BuildRoomsOctree(PolygonMesh mesh)
37 {
38 var root = new OctreeNode(rootBoundingBox, new Polygon[0], mesh.Rooms);
39 root.Build();
40 return root;
41 }
42 }
43 }