Skip to content

Commit 6367936

Browse files
Implementation of pull request SebLague#142 from Megadiablo.
Fix detect count of points, anchor points and segments SebLague#142
1 parent d289d0e commit 6367936

1 file changed

Lines changed: 23 additions & 28 deletions

File tree

Assets/PathCreator/Core/Runtime/Objects/BezierPath.cs

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -155,34 +155,29 @@ public void SetPoint(int i, Vector3 localPosition, bool suppressPathModifiedEven
155155
}
156156
}
157157

158-
/// Total number of points in the path (anchors and controls)
159-
public int NumPoints
160-
{
161-
get
162-
{
163-
return points.Count;
164-
}
165-
}
166-
167-
/// Number of anchor points making up the path
168-
public int NumAnchorPoints
169-
{
170-
get
171-
{
172-
return (IsClosed) ? points.Count / 3 : (points.Count + 2) / 3;
173-
}
174-
}
175-
176-
/// Number of bezier curves making up this path
177-
public int NumSegments
178-
{
179-
get
180-
{
181-
return points.Count / 3;
182-
}
183-
}
184-
185-
/// Path can exist in 3D (xyz), 2D (xy), or Top-Down (xz) space
158+
/// Total number of points in the path (anchors and controls)
159+
public int NumPoints
160+
{
161+
get { return points?.Count ?? 0; }
162+
}
163+
164+
/// Number of anchor points making up the path
165+
public int NumAnchorPoints
166+
{
167+
get
168+
{
169+
int count = NumPoints;
170+
return (IsClosed) ? count / 3 : (count + 2) / 3;
171+
}
172+
}
173+
174+
/// Number of bezier curves making up this path
175+
public int NumSegments
176+
{
177+
get { return NumPoints / 3; }
178+
}
179+
180+
/// Path can exist in 3D (xyz), 2D (xy), or Top-Down (xz) space
186181
/// 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)
187182
public PathSpace Space
188183
{

0 commit comments

Comments
 (0)