restructuring BVH + midpt algo