Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Fixed the deselecting of faces that are behind the face you clicked on #24

Merged
merged 3 commits into from
Jan 22, 2018
Merged
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
32 changes: 22 additions & 10 deletions Scripts/Tools/SurfaceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,36 @@ void OnMouseDown (SceneView sceneView, Event e)
List<Polygon> raycastHits = csgModel.RaycastBuiltPolygonsAll(ray).Select(hit => csgModel.GetSourcePolygon(hit.Polygon.UniqueIndex)).Where(item => item != null).ToList();
Polygon sourcePolygon = null;

// Walk through the hits from front to back and find if any of them are in the selection set
for (int i = 0; i < raycastHits.Count; i++)
// User is trying to multiselect, let's not make life difficult for them by only accepting the nearest polygon
if (SabreInput.IsModifier(e, EventModifiers.Shift))
{
if(selectedSourcePolygons.Contains(raycastHits[i]))
// Use the first polygon that was hit
if (raycastHits.Count > 0)
{
sourcePolygon = raycastHits[i];
break;
sourcePolygon = raycastHits[0];
}
}

// None of the hit polygons are in the selection set, so just use the first hit polygon if it's available
if(sourcePolygon == null && raycastHits.Count >= 1)
else
{
sourcePolygon = raycastHits[0];
// Walk through the hits from front to back and find if any of them are in the selection set
for (int i = 0; i < raycastHits.Count; i++)
{
if (selectedSourcePolygons.Contains(raycastHits[i]))
{
sourcePolygon = raycastHits[i];
break;
}
}

// None of the hit polygons are in the selection set, so just use the first hit polygon if it's available
if (sourcePolygon == null && raycastHits.Count >= 1)
{
sourcePolygon = raycastHits[0];
}
}

// If a polygon has been hit
if(sourcePolygon != null)
if (sourcePolygon != null)
{
// Reset drag values
totalDelta = Vector2.zero;
Expand Down