Skip to content

Commit

Permalink
Merge pull request #11 from Netherlands3D/feature/polygon-height
Browse files Browse the repository at this point in the history
Feature/polygon height
  • Loading branch information
TomSimons authored Apr 17, 2024
2 parents 0ae6a6f + bf57e88 commit 0256aed
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

[2.3.0]

### Added

- Made some fields and methods extendable, added property to set world plane.

## [2.2.4]

### Fixed
Expand Down
34 changes: 21 additions & 13 deletions Runtime/Scripts/SelectionTools/PolygonInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public enum DrawMode
[SerializeField] private DrawMode mode = DrawMode.CreateAndEdit;
public DrawMode Mode => mode;

private InputAction pointerAction;
private InputAction tapAction;
private InputAction escapeAction;
private InputAction finishAction;
private InputAction tapSecondaryAction;
private InputAction clickAction;
private InputAction modifierAction;
protected InputAction pointerAction;
protected InputAction tapAction;
protected InputAction escapeAction;
protected InputAction finishAction;
protected InputAction tapSecondaryAction;
protected InputAction clickAction;
protected InputAction modifierAction;

[SerializeField] private LineRenderer polygonLineRenderer;
[SerializeField] private LineRenderer previewLineRenderer;
Expand All @@ -91,6 +91,12 @@ public enum DrawMode
protected Vector3 lastNormal = Vector3.zero;
protected Plane worldPlane;

public Plane WorldPlane
{
get => worldPlane;
set => worldPlane = value;
}

private bool closedLoop = false;
private bool snappingToStartPoint = false;
private bool polygonFinished = false;
Expand All @@ -111,12 +117,14 @@ public enum DrawMode
[Header("Invoke")]
public UnityEvent<bool> blockCameraDrag;
public UnityEvent<List<Vector3>> createdNewPolygonArea;

[Header("Optional Invoke")]
public UnityEvent<List<Vector3>> editedPolygonArea;

[Tooltip("Contains the list of points the line is made of")] public UnityEvent<List<Vector3>> previewLineHasChanged;
[Tooltip("Contains the list of points the line is made of")]
public UnityEvent<List<Vector3>> previewLineHasChanged;

void Awake()
protected virtual void Awake()
{
mainCamera = Camera.main;
polygonLineRenderer.startColor = polygonLineRenderer.endColor = lineColor;
Expand Down Expand Up @@ -274,7 +282,7 @@ private void DetermineIfShouldAutoDraw()

return;
}

//if mode is not edit mode, we check if we are not auto drawing, but we are clicking and the auto draw modifier is pressed
if (!autoDrawPolygon && clickAction.IsPressed() && modifierAction.IsPressed())
{
Expand Down Expand Up @@ -379,8 +387,8 @@ private void CloseLoop(bool isNewPolygon, bool checkPreviewLine = true)
{
if (closedLoop)
return;
if (positions.Count == minPointsToCloseLoop -1) // add an extra point at the current mouse position to attempt to create a valid shape

if (positions.Count == minPointsToCloseLoop - 1) // add an extra point at the current mouse position to attempt to create a valid shape
{
Tap();
}
Expand Down Expand Up @@ -421,7 +429,7 @@ private void CloseLoop(bool isNewPolygon, bool checkPreviewLine = true)
positions.Add(closingLineEnd);
}
}

closedLoop = true;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eu.netherlands3d.selection-tools",
"version": "2.2.4",
"version": "2.3.0",
"displayName": "Netherlands3D - Selection Tools",
"description": "Tool to draw areas, and make selections",
"unity": "2022.2",
Expand Down

0 comments on commit 0256aed

Please sign in to comment.