/// <summary> /// Add a new part to the composition. /// </summary> /// <param name="part">The part to add. This object must not already be owned by another composition.</param> public virtual void Add(Part part) { if (part.Owner != null) { throw new ArgumentException("The part already belongs to a composition."); } part.Owner = this; _parts.Add(part); AlignedBox tmp; part.BoundingBox(out tmp); AlignedBox.Merge(ref BoundingBox, ref tmp, out BoundingBox); }
/// <summary> /// Applies the specified transform to bring all parts of the composition into world-space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public virtual void ApplyTransform(ref Transform transform) { for (int i = 0; i < _parts.Count; i++) { _parts[i].ApplyTransform(ref transform); } if (_parts.Count > 0) { AlignedBox tmp; _parts[0].BoundingBox(out BoundingBox); for (int i = 1; i < _parts.Count; i++) { _parts[i].BoundingBox(out tmp); AlignedBox.Merge(ref BoundingBox, ref tmp, out BoundingBox); } } }