MetaCGOptions findPreviousReferenceCPOptions(CurvySpline spline, float tf, out CurvySplineSegment cp) { MetaCGOptions options; cp = spline.TFToSegment(tf); do { options = cp.GetMetadata <MetaCGOptions>(true); if (cp.IsFirstVisibleControlPoint) { return(options); } cp = cp.PreviousSegment; }while (cp && !options.UVEdge && !options.ExplicitU && !options.HasDifferentMaterial); return(options); }
MetaCGOptions findNextReferenceCPOptions(CurvySpline spline, float tf, out CurvySplineSegment cp) { MetaCGOptions options; float localF; cp = spline.TFToSegment(tf, out localF); do { cp = cp.NextControlPoint; options = cp.GetMetadata <MetaCGOptions>(true); if (!spline.Closed && cp.IsLastVisibleControlPoint) { return(options); } }while (!options.UVEdge && !options.ExplicitU && !options.HasDifferentMaterial && !cp.IsFirstSegment); return(options); }
public MetaCGOptions GetNextDefined(out CurvySplineSegment cp) { cp = ControlPoint.NextControlPoint; MetaCGOptions res; while (cp) { res = cp.GetMetadata <MetaCGOptions>(true); if (res.UVEdge || res.ExplicitU || res.HasDifferentMaterial) { return(res); } if (Spline.Closed && cp.IsFirstVisibleControlPoint) { return(null); } cp = cp.NextControlPoint; } return(null); }
public MetaCGOptions GetPreviousDefined(out CurvySplineSegment cp) { if (Spline.Closed && ControlPoint.IsFirstVisibleControlPoint) { cp = ControlPoint; return(this); } cp = ControlPoint.PreviousControlPoint; MetaCGOptions res; while (cp && !cp.IsLastVisibleControlPoint) { res = cp.GetMetadata <MetaCGOptions>(true); if (res.UVEdge || res.ExplicitU || res.HasDifferentMaterial) { return(res); } cp = cp.PreviousControlPoint; } return(null); }
/// <summary> /// Rasterization Helper class /// </summary> public static List <ControlPointOption> GetControlPointsWithOptions(CGDataRequestMetaCGOptions options, CurvySpline shape, float startDist, float endDist, bool optimize, out int initialMaterialID, out float initialMaxStep) { var res = new List <ControlPointOption>(); initialMaterialID = 0; initialMaxStep = float.MaxValue; CurvySplineSegment startSeg = shape.DistanceToSegment(startDist); float clampedEndDist = shape.ClampDistance(endDist, shape.IsClosed ? CurvyClamping.Loop : CurvyClamping.Clamp); if (clampedEndDist == 0) { clampedEndDist = endDist; } CurvySplineSegment finishSeg = (clampedEndDist == shape.Length) ? shape.LastVisibleControlPoint : shape.DistanceToSegment(clampedEndDist); if (endDist != shape.Length && endDist > finishSeg.Distance) { finishSeg = finishSeg.NextControlPoint; } MetaCGOptions cgOptions; float loopOffset = 0; if (startSeg) { cgOptions = startSeg.GetMetadata <MetaCGOptions>(true); initialMaxStep = (cgOptions.MaxStepDistance == 0) ? float.MaxValue : cgOptions.MaxStepDistance; if (options.CheckMaterialID) { initialMaterialID = cgOptions.MaterialID; } int currentMaterialID = initialMaterialID; float maxDist = cgOptions.MaxStepDistance; /* * if ((options.CheckMaterialID && cgOptions.MaterialID != 0) || * (optimize && cgOptions.MaxStepDistance != 0)) * res.Add(new ControlPointOption(startSeg.LocalFToTF(0), * startSeg.Distance, * true, * cgOptions.MaterialID, * options.CheckHardEdges && cgOptions.HardEdge, * initialMaxStep, * (options.CheckExtendedUV && cgOptions.UVEdge), * options.CheckExtendedUV && cgOptions.ExplicitU, * cgOptions.FirstU, * cgOptions.SecondU)); */ var seg = startSeg.NextSegment ?? startSeg.NextControlPoint; do { cgOptions = seg.GetMetadata <MetaCGOptions>(true); if (seg.ControlPointIndex < startSeg.ControlPointIndex) { loopOffset = shape.Length; } if (options.IncludeControlPoints || (options.CheckHardEdges && cgOptions.HardEdge) || (options.CheckMaterialID && cgOptions.MaterialID != currentMaterialID) || (optimize && cgOptions.MaxStepDistance != maxDist) || (options.CheckExtendedUV && (cgOptions.UVEdge || cgOptions.ExplicitU)) ) { bool matDiff = cgOptions.MaterialID != currentMaterialID; maxDist = (cgOptions.MaxStepDistance == 0) ? float.MaxValue : cgOptions.MaxStepDistance; currentMaterialID = options.CheckMaterialID ? cgOptions.MaterialID : initialMaterialID; res.Add(new ControlPointOption(seg.LocalFToTF(0) + Mathf.FloorToInt(loopOffset / shape.Length), seg.Distance + loopOffset, options.IncludeControlPoints, currentMaterialID, options.CheckHardEdges && cgOptions.HardEdge, cgOptions.MaxStepDistance, (options.CheckExtendedUV && cgOptions.UVEdge) || matDiff, options.CheckExtendedUV && cgOptions.ExplicitU, cgOptions.FirstU, cgOptions.SecondU)); } seg = seg.NextSegment; } while (seg && seg != finishSeg); // Check UV settings of last cp (not a segment if open spline!) if (options.CheckExtendedUV && !seg && finishSeg.IsLastVisibleControlPoint) { cgOptions = finishSeg.GetMetadata <MetaCGOptions>(true); if (cgOptions.ExplicitU) { res.Add(new ControlPointOption(1, finishSeg.Distance + loopOffset, options.IncludeControlPoints, currentMaterialID, options.CheckHardEdges && cgOptions.HardEdge, cgOptions.MaxStepDistance, (options.CheckExtendedUV && cgOptions.UVEdge) || (options.CheckMaterialID && cgOptions.MaterialID != currentMaterialID), options.CheckExtendedUV && cgOptions.ExplicitU, cgOptions.FirstU, cgOptions.SecondU)); } } } return(res); }
MetaCGOptions findNextReferenceCPOptions(CurvySpline spline, float tf, out CurvySplineSegment cp) { MetaCGOptions options; float localF; cp = spline.TFToSegment(tf, out localF); do { cp = cp.NextControlPoint; options = cp.GetMetadata<MetaCGOptions>(true); if (!spline.Closed && cp.IsLastVisibleControlPoint) return options; } while (!options.UVEdge && !options.ExplicitU && !options.HasDifferentMaterial && !cp.IsFirstSegment); return options; }
MetaCGOptions findPreviousReferenceCPOptions(CurvySpline spline, float tf, out CurvySplineSegment cp) { MetaCGOptions options; cp = spline.TFToSegment(tf); do { options = cp.GetMetadata<MetaCGOptions>(true); if (cp.IsFirstVisibleControlPoint) return options; cp = cp.PreviousSegment; } while (cp && !options.UVEdge && !options.ExplicitU &&!options.HasDifferentMaterial); return options; }
public MetaCGOptions GetNextDefined(out CurvySplineSegment cp) { cp = ControlPoint.NextControlPoint; MetaCGOptions res; while (cp) { res = cp.GetMetadata<MetaCGOptions>(true); if (res.UVEdge || res.ExplicitU || res.HasDifferentMaterial) return res; if (Spline.Closed && cp.IsFirstVisibleControlPoint) return null; cp = cp.NextControlPoint; } return null; }
public MetaCGOptions GetPreviousDefined(out CurvySplineSegment cp) { if (Spline.Closed && ControlPoint.IsFirstVisibleControlPoint) { cp = ControlPoint; return this; } cp = ControlPoint.PreviousControlPoint; MetaCGOptions res; while (cp && !cp.IsLastVisibleControlPoint) { res = cp.GetMetadata<MetaCGOptions>(true); if (res.UVEdge || res.ExplicitU || res.HasDifferentMaterial) return res; cp = cp.PreviousControlPoint; } return null; }