فهرست منبع

multiLine fix

Royi Bernthal 7 سال پیش
والد
کامیت
6d47b7c6b6
2فایلهای تغییر یافته به همراه20 افزوده شده و 6 حذف شده
  1. 14 4
      gui/src/2D/controls/multiLine.ts
  2. 6 2
      gui/src/2D/multiLinePoint.ts

+ 14 - 4
gui/src/2D/controls/multiLine.ts

@@ -62,7 +62,7 @@ export class MultiLine extends Control {
 
     /** Function called when a point is updated */
     public onPointUpdate = (): void => {
-        this._markAsDirty();
+        if (this.isVisible) this._markAsDirty();
     }
 
     /**
@@ -127,6 +127,18 @@ export class MultiLine extends Control {
         this._points.splice(index, 1);
     }
 
+    public reset(): void {
+        while (this._points.length > 0) {
+            this.remove(this._points.length - 1);
+        }
+    }
+
+    public resetLinks(): void {
+        this._points.forEach(point => {
+            if (point != null) point.resetLinks();
+        });
+    }
+
     /** Gets or sets line width */
     public get lineWidth(): number {
         return this._lineWidth;
@@ -239,9 +251,7 @@ export class MultiLine extends Control {
     }
 
     public dispose(): void {
-        while (this._points.length > 0) {
-            this.remove(this._points.length - 1);
-        }
+        this.reset();
 
         super.dispose();
     }

+ 6 - 2
gui/src/2D/multiLinePoint.ts

@@ -114,6 +114,11 @@ export class MultiLinePoint {
         this._multiLine._markAsDirty();
     }
 
+    public resetLinks(): void {
+        this.mesh = null;
+        this.control = null;
+    }
+
     /** 
      * Gets a translation vector
      * @returns the translation vector
@@ -143,8 +148,7 @@ export class MultiLinePoint {
 
     /** Release associated resources */
     public dispose(): void {
-        this.control = null;
-        this.mesh = null;
+        this.resetLinks();
     }
 
 }