/// <summary> /// Gets all the <see cref="Brush"/> objects associated with the given <paramref name="model"/>. /// </summary> /// <param name="bsp">This <see cref="BSP"/> object.</param> /// <param name="model">The <see cref="Model"/> object to get all <see cref="Brush"/> objects for.</param> /// <returns> /// A <see cref="List"/><<see cref="Brush"/>> containing all the <see cref="Brush"/> objects occurring /// within the passed <see cref="Model"/> object, or <c>null</c> if the BSP doesn't have brushes. /// </returns> /// <remarks> /// The proper way to go from a <see cref="Model"/> reference to a collection of <see cref="Brush"/> objects /// depends on the type of BSP we're operating on. In the case of Quake 3, for example, models directly reference /// brushes, but Quake 2 and Source require a full tree traversal. /// </remarks> public static List <Brush> GetBrushesInModel(this BSP bsp, Model model) { if (model.firstBrush >= 0) { return(bsp.GetReferencedObjects <Brush>(model, "brushes")); } if (model.firstLeaf >= 0) { List <Leaf> leavesInModel = bsp.GetReferencedObjects <Leaf>(model, "leaves"); return(bsp.GetBrushesInLeafList(leavesInModel)); } if (model.headNode >= 0) { return(bsp.GetBrushesInLeafList(bsp.GetLeavesInTree(bsp.nodes[model.headNode]))); } return(new List <Brush>(0)); }