Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detect count of points, anchor points and segments #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions Assets/PathCreator/Core/Runtime/Objects/BezierPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,20 @@ public void SetPoint(int i, Vector3 localPosition, bool suppressPathModifiedEven
}

/// Total number of points in the path (anchors and controls)
public int NumPoints
{
get
{
return points.Count;
}
}
public int NumPoints => points?.Count ?? 0;

/// Number of anchor points making up the path
public int NumAnchorPoints
{
get
{
return (IsClosed) ? points.Count / 3 : (points.Count + 2) / 3;
int count = NumPoints;
return (IsClosed) ? count / 3 : (count + 2) / 3;
}
}

/// Number of bezier curves making up this path
public int NumSegments
{
get
{
return points.Count / 3;
}
}
public int NumSegments => NumPoints / 3;

/// Path can exist in 3D (xyz), 2D (xy), or Top-Down (xz) space
/// In xy or xz space, points will be clamped to that plane (so in a 2D path, for example, points will always be at 0 on z axis)
Expand Down Expand Up @@ -826,4 +815,4 @@ public void NotifyPathModified()
#endregion

}
}
}