From 284fc2e9f4364258f0c40bc9cb6178b78815dd56 Mon Sep 17 00:00:00 2001 From: Henry de Jongh Date: Mon, 15 Jan 2018 22:52:34 +0100 Subject: [PATCH 1/3] SurfaceEditor: We now use the first polygon that was hit so we don't accidentally select/deselect polygons behind the one we see. A very annoying bug that was fixed by removing a lot of code that apparently doesn't do anything useful. --- Scripts/Tools/SurfaceEditor.cs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Scripts/Tools/SurfaceEditor.cs b/Scripts/Tools/SurfaceEditor.cs index e4ad8094..0908c808 100755 --- a/Scripts/Tools/SurfaceEditor.cs +++ b/Scripts/Tools/SurfaceEditor.cs @@ -178,26 +178,12 @@ void OnMouseDown (SceneView sceneView, Event e) // Get all the polygons the ray hits List 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++) - { - 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]; - } + // Use the first polygon that was hit so we don't accidentally select/deselect polygons behind the one we see. + Polygon sourcePolygon = raycastHits[0]; // If a polygon has been hit - if(sourcePolygon != null) + if (sourcePolygon != null) { // Reset drag values totalDelta = Vector2.zero; From e80c744fe9315c2b9dd80a45d8dcaad7fd949383 Mon Sep 17 00:00:00 2001 From: Henry de Jongh Date: Mon, 15 Jan 2018 23:12:08 +0100 Subject: [PATCH 2/3] Fixed an ArgumentOutOfRangeException when not hitting a face. --- Scripts/Tools/SurfaceEditor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Scripts/Tools/SurfaceEditor.cs b/Scripts/Tools/SurfaceEditor.cs index 0908c808..9d295797 100755 --- a/Scripts/Tools/SurfaceEditor.cs +++ b/Scripts/Tools/SurfaceEditor.cs @@ -178,9 +178,13 @@ void OnMouseDown (SceneView sceneView, Event e) // Get all the polygons the ray hits List raycastHits = csgModel.RaycastBuiltPolygonsAll(ray).Select(hit => csgModel.GetSourcePolygon(hit.Polygon.UniqueIndex)).Where(item => item != null).ToList(); + Polygon sourcePolygon = null; // Use the first polygon that was hit so we don't accidentally select/deselect polygons behind the one we see. - Polygon sourcePolygon = raycastHits[0]; + if (raycastHits.Count > 0) + { + sourcePolygon = raycastHits[0]; + } // If a polygon has been hit if (sourcePolygon != null) From 7c46cbbe3f46b310d826817d52e5d2fe64d4bb7d Mon Sep 17 00:00:00 2001 From: Henry de Jongh Date: Thu, 18 Jan 2018 09:38:42 +0100 Subject: [PATCH 3/3] Clicking without any modifier keys cycles through faces and with modifier keys does a special action, that's either rotating on CTRL (which is actually behaving like this already) or quick select on SHIFT. Now we got every feature! --- Scripts/Tools/SurfaceEditor.cs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Scripts/Tools/SurfaceEditor.cs b/Scripts/Tools/SurfaceEditor.cs index 9d295797..813dc4a7 100755 --- a/Scripts/Tools/SurfaceEditor.cs +++ b/Scripts/Tools/SurfaceEditor.cs @@ -180,10 +180,32 @@ void OnMouseDown (SceneView sceneView, Event e) List raycastHits = csgModel.RaycastBuiltPolygonsAll(ray).Select(hit => csgModel.GetSourcePolygon(hit.Polygon.UniqueIndex)).Where(item => item != null).ToList(); Polygon sourcePolygon = null; - // Use the first polygon that was hit so we don't accidentally select/deselect polygons behind the one we see. - if (raycastHits.Count > 0) + // 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)) { - sourcePolygon = raycastHits[0]; + // Use the first polygon that was hit + if (raycastHits.Count > 0) + { + sourcePolygon = raycastHits[0]; + } + } + else + { + // 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