Skip to content

Commit ac73189

Browse files
committed
0.5.9
1 parent 06447eb commit ac73189

8 files changed

Lines changed: 43 additions & 14 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# eppz! `Geometry`
22

3+
* 0.5.9
4+
5+
+ Polygon / segment sources now can be updates on `Update` or `LateUpdate`
6+
+ Test scenes
7+
+ Updated update modes
8+
39
* 0.5.8
410

511
+ Test scenes

Components/PolygonSource.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using UnityEngine.Serialization;
1111

1212

13+
1314
namespace EPPZ.Geometry.Components
1415
{
1516

@@ -20,7 +21,9 @@ public class PolygonSource : MonoBehaviour
2021

2122
public Transform[] pointTransforms;
2223
[Range (-2,2)] public float offset = 0.0f;
23-
public bool updateModel = false;
24+
25+
public enum UpdateMode { Awake, Update, LateUpdate };
26+
public UpdateMode update = UpdateMode.Awake;
2427

2528
public Polygon polygon;
2629

@@ -34,12 +37,21 @@ void Awake()
3437

3538
void Update()
3639
{
37-
if (updateModel)
38-
{
39-
// Update polygon model with transforms, also update calculations.
40-
polygon.UpdatePointPositionsWithSource(this);
41-
if (offset != 0.0f) polygon = polygon.OffsetPolygon(offset);
42-
}
40+
if (update == UpdateMode.Update)
41+
{ UpdateModel(); }
42+
}
43+
44+
void LateUpdate()
45+
{
46+
if (update == UpdateMode.LateUpdate)
47+
{ UpdateModel(); }
48+
}
49+
50+
void UpdateModel()
51+
{
52+
// Update polygon model with transforms, also update calculations.
53+
polygon.UpdatePointPositionsWithSource(this);
54+
if (offset != 0.0f) polygon = polygon.OffsetPolygon(offset);
4355
}
4456
}
4557
}

Components/SegmentSource.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class SegmentSource : MonoBehaviour
1818

1919

2020
public Transform[] pointTransforms;
21-
public bool updateModel = false;
21+
22+
public enum UpdateMode { Awake, Update, LateUpdate };
23+
public UpdateMode update = UpdateMode.Awake;
2224

2325
public Segment segment;
2426

@@ -28,14 +30,23 @@ void Awake()
2830
// Construct a segment model from transforms.
2931
segment = Segment.SegmentWithSource(this);
3032
}
31-
33+
3234
void Update()
3335
{
34-
if (updateModel)
35-
{
36-
// Update segment model with transforms, also update calculations.
37-
segment.UpdateWithSource(this);
38-
}
36+
if (update == UpdateMode.Update)
37+
{ UpdateModel(); }
38+
}
39+
40+
void LateUpdate()
41+
{
42+
if (update == UpdateMode.LateUpdate)
43+
{ UpdateModel(); }
44+
}
45+
46+
void UpdateModel()
47+
{
48+
// Update segment model with transforms, also update calculations.
49+
segment.UpdateWithSource(this);
3950
}
4051
}
4152
}
40 Bytes
Binary file not shown.
40 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.

Scenes/3 Polygon permiter-Point containment (Default).unity renamed to Scenes/3. Polygon permiter-Point containment (Default).unity

49.5 KB
Binary file not shown.
40 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)