From 52cb136c3469e54d3acff77c04d14374c16c4e80 Mon Sep 17 00:00:00 2001
From: Zachary Zhang <zacharyzhang7@gmail.com>
Date: Mon, 5 Aug 2024 12:36:49 -0400
Subject: fix horrible bug

---
 src/client/views/GestureOverlay.tsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'src/client/views/GestureOverlay.tsx')

diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index 8cc33baca..abb8445dc 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -149,16 +149,20 @@ export class GestureOverlay extends ObservableReactComponent<React.PropsWithChil
                         const point2 = cuspArray[i + 1];
                         const point3 = cuspArray[i + 2];
                         const triangleObject = { p1: { X: point1.X, Y: point1.Y }, p2: { X: point2.X, Y: point2.Y }, p3: { X: point3.X, Y: point3.Y } };
+                        const otherInk = DocumentView.getDocumentView(doc)?.ComponentView as InkingStroke;
+                        const { inkData: otherInkData } = otherInk?.inkScaledData() ?? { inkData: [] };
+                        const otherScreenPts = otherInkData.map(point => otherInk.ptToScreen(point));
+                        console.log(otherScreenPts);
                         console.log((DocumentView.getDocumentView(doc)?.ComponentView as InkingStroke).inkScaledData().inkData.map(point => ({ X: point.X, Y: point.Y })));
                         console.log(triangleObject);
                         if (doc.title === 'line') {
-                            if (this.doesLineIntersectTriangle((DocumentView.getDocumentView(doc)?.ComponentView as InkingStroke).inkScaledData().inkData, triangleObject)) {
+                            if (this.doesLineIntersectTriangle(otherScreenPts, triangleObject)) {
                                 docsToDelete.push(doc);
                                 hasDocInTriangle = true;
                                 cuspBooleanArray.push(true);
                             }
                         } else {
-                            if (this.isAnyPointInTriangle(triangleObject, (DocumentView.getDocumentView(doc)?.ComponentView as InkingStroke).inkScaledData().inkData)) {
+                            if (this.isAnyPointInTriangle(triangleObject, otherScreenPts)) {
                                 docsToDelete.push(doc);
                                 hasDocInTriangle = true;
                                 cuspBooleanArray.push(true);
@@ -193,10 +197,10 @@ export class GestureOverlay extends ObservableReactComponent<React.PropsWithChil
         console.log(hasObjectInFirstAndLast25);
         const trueCount = cuspBooleanArray.filter(value => value).length;
         const percentageTrues = trueCount / cuspBooleanArray.length;
-        if (percentageTrues > 0.75 || hasObjectInFirstAndLast25) {
+        if (percentageTrues > 0.65 || hasObjectInFirstAndLast25) {
             console.log('requirements are met');
         }
-        return percentageTrues > 0.75 || hasObjectInFirstAndLast25;
+        return percentageTrues > 0.65 || hasObjectInFirstAndLast25;
     }
     isRectangleOverlap(rect1: any, rect2: any): boolean {
         const noOverlap = rect1.maxX < rect2.minX || rect1.minX > rect2.maxX || rect1.maxY < rect2.minY || rect1.minY > rect2.maxY;
@@ -323,6 +327,7 @@ export class GestureOverlay extends ObservableReactComponent<React.PropsWithChil
                     this._points.length = 0;
                     this._points.push(...controlPoints);
                     this.dispatchGesture(Gestures.Stroke);
+                    const ffView = DocumentView.allViews().find(view => view.ComponentView instanceof CollectionFreeFormView);
                 }
             }
         }
-- 
cgit v1.2.3-70-g09d2

