/// Update the bounding box of the path public Bounds CalculateBoundsWithTransform(Transform transform) { // Loop through all segments and keep track of the minmax points of all their bounding boxes MinMax3D minMax = new MinMax3D(); for (int i = 0; i < NumSegments; i++) { Vector3[] p = GetPointsInSegment(i); for (int j = 0; j < p.Length; j++) { p[j] = MathUtility.TransformPoint(p[j], transform, space); } minMax.AddValue(p[0]); minMax.AddValue(p[3]); List <float> extremePointTimes = CubicBezierUtility.ExtremePointTimes(p[0], p[1], p[2], p[3]); foreach (float t in extremePointTimes) { minMax.AddValue(CubicBezierUtility.EvaluateCurve(p, t)); } } return(new Bounds((minMax.Min + minMax.Max) / 2, minMax.Max - minMax.Min)); }
/// Update the bounding box of the path void UpdateBounds() { if (boundsUpToDate) { return; } // Loop through all segments and keep track of the minmax points of all their bounding boxes MinMax3D minMax = new MinMax3D(); for (int i = 0; i < NumSegments; i++) { Vector3[] p = GetPointsInSegment(i); minMax.AddValue(p[0]); minMax.AddValue(p[3]); List <float> extremePointTimes = CubicBezierUtility.ExtremePointTimes(p[0], p[1], p[2], p[3]); foreach (float t in extremePointTimes) { minMax.AddValue(CubicBezierUtility.EvaluateCurve(p, t)); } } boundsUpToDate = true; bounds = new Bounds((minMax.Min + minMax.Max) / 2, minMax.Max - minMax.Min); }
/// Update the bounding box of the path void UpdateBounds() { if (this.boundsUpToDate) { return; } // Loop through all segments and keep track of the minmax points of all their bounding boxes var minMax = new MinMax3D(); for (var i = 0; i < this.NumSegments; i++) { var p = this.GetPointsInSegment(i); minMax.AddValue(p[0]); minMax.AddValue(p[3]); var extremePointTimes = CubicBezierUtility.ExtremePointTimes(p[0], p[1], p[2], p[3]); foreach (var t in extremePointTimes) { minMax.AddValue(CubicBezierUtility.EvaluateCurve(p, t)); } } this.boundsUpToDate = true; this.bounds = new Bounds((minMax.Min + minMax.Max) / 2, minMax.Max - minMax.Min); }