public void SetContent(Mesh3d mesh) { m_mesh3d = mesh; Vector3L[] vertices = mesh.GetVertices(); Vector3L min = vertices[0]; Vector3L max = vertices[0]; for (int i = 1; i < mesh.m_triangleList.Count * 3; ++i) { min.x = FixPointMath.Min(vertices[i].x, min.x); min.y = FixPointMath.Min(vertices[i].y, min.y); min.z = FixPointMath.Min(vertices[i].z, min.z); max.x = FixPointMath.Max(vertices[i].x, max.x); max.y = FixPointMath.Max(vertices[i].y, max.y); max.z = FixPointMath.Max(vertices[i].z, max.z); } m_aabb = Mesh3d.FromMinMax(min, max); }
bool Accelerate(Vector3L position, FloatL size) { if (m_octree != null) { return(false); } Vector3L min = new Vector3L(position.x - size, position.y - size, position.z - size); Vector3L max = new Vector3L(position.x + size, position.y + size, position.z + size); // Construct tree root m_octree = new OctreeNode(); m_octree.m_bounds = Mesh3d.FromMinMax(min, max); m_octree.m_children = null; for (int i = 0, size2 = m_modleList.Count; i < size2; ++i) { m_octree.m_models.Add(m_modleList[i]); } // Create tree Octree3d.SplitTree(m_octree, 5); return(true); }