public Octree(Triangle[] triangles, Mesh parentMesh) { _parentMesh = parentMesh; _children = new Octree[8]; _triangles = triangles; Vector3 max; Vector3 min; FindEdges(out min, out max); _boundingBox = new Box(min.x, max.x, min.y, max.y, min.z, max.z); if (triangles.Length > TriangleCountInLeaf) { Subdivide(min, max); } else { _directTriangleChildren = new List<Triangle>(triangles); } }
public void Init(Mesh mesh) { _mesh = mesh; _edge1 = V2 - V1; _edge2 = V3 - V1; Vector3 crossProduct = Vector3.Cross(_edge2, _edge1); Normal = crossProduct.Normalized(); }