public Model3d Raycast(Ray3d ray) { if (m_octree != null) { // :: lets the compiler know to look outside class scope return(Octree3d.Raycast(m_octree, ray)); } Model3d result = null; FloatL result_t = -1; for (int i = 0, size = m_modleList.Count; i < size; ++i) { FloatL t = IntersectionTest3D.Ray3dWithModel3d(ray, m_modleList[i]); if (result == null && t >= 0) { result = m_modleList[i]; result_t = t; } else if (result != null && t < result_t) { result = m_modleList[i]; result_t = t; } } return(result); }
public List <Model3d> Query(AABB3d aabb) { if (m_octree != null) { // :: lets the compiler know to look outside class scope return(Octree3d.Query(m_octree, aabb)); } List <Model3d> result = new List <Model3d>(); for (int i = 0, size = m_modleList.Count; i < size; ++i) { OBB3d bounds = m_modleList[i].GetOBB(); if (IntersectionTest3D.AABB3dWithOBB3d(aabb, bounds)) { result.Add(m_modleList[i]); } } return(result); }
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); }