/// <summary> /// Gets all <see cref="Leaf"/> objects referenced by this <see cref="Model"/>. /// </summary> /// <param name="bsp">This <see cref="BSP"/>.</param> /// <param name="model">The <see cref="Model"/> to get all <see cref="Leaf"/> objects from.</param> /// <returns>A <see cref="List{T}"/><<see cref="Leaf"/>> containing all <see cref="Leaf"/> objects referenced by <paramref name="model"/>.</returns> public static List <Leaf> GetLeavesInModel(this BSP bsp, Model model) { List <Leaf> result = null; if (model.FirstLeafIndex < 0) { if (model.HeadNodeIndex >= 0) { result = bsp.GetLeavesInNode(bsp.nodes[model.HeadNodeIndex]); } } else { result = new List <Leaf>(model.NumLeaves); for (int i = 0; i < model.NumLeaves; i++) { result.Add(bsp.leaves[model.FirstLeafIndex + i]); } } return(result); }