Quellcode durchsuchen

[ts] Fixed memory leak in Triangulator. Added coin example to WebGL test

badlogic vor 8 Jahren
Ursprung
Commit
fdf6aba634

+ 7 - 0
spine-ts/build/spine-all.js

@@ -5460,6 +5460,10 @@ var spine;
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
 					}
+					else {
+						this.polygonPool.free(polygon);
+						this.polygonIndicesPool.free(polygonIndices);
+					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
 					polygon.push(x1);
@@ -5528,6 +5532,9 @@ var spine;
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i];
+					convexPolygonsIndices.splice(i, 1);
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 			return convexPolygons;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 7 - 0
spine-ts/build/spine-canvas.js

@@ -5460,6 +5460,10 @@ var spine;
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
 					}
+					else {
+						this.polygonPool.free(polygon);
+						this.polygonIndicesPool.free(polygonIndices);
+					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
 					polygon.push(x1);
@@ -5528,6 +5532,9 @@ var spine;
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i];
+					convexPolygonsIndices.splice(i, 1);
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 			return convexPolygons;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
spine-ts/build/spine-canvas.js.map


+ 7 - 0
spine-ts/build/spine-core.js

@@ -5460,6 +5460,10 @@ var spine;
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
 					}
+					else {
+						this.polygonPool.free(polygon);
+						this.polygonIndicesPool.free(polygonIndices);
+					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
 					polygon.push(x1);
@@ -5528,6 +5532,9 @@ var spine;
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i];
+					convexPolygonsIndices.splice(i, 1);
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 			return convexPolygons;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
spine-ts/build/spine-core.js.map


+ 7 - 0
spine-ts/build/spine-threejs.js

@@ -5460,6 +5460,10 @@ var spine;
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
 					}
+					else {
+						this.polygonPool.free(polygon);
+						this.polygonIndicesPool.free(polygonIndices);
+					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
 					polygon.push(x1);
@@ -5528,6 +5532,9 @@ var spine;
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i];
+					convexPolygonsIndices.splice(i, 1);
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 			return convexPolygons;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
spine-ts/build/spine-threejs.js.map


+ 7 - 0
spine-ts/build/spine-webgl.js

@@ -5460,6 +5460,10 @@ var spine;
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
 					}
+					else {
+						this.polygonPool.free(polygon);
+						this.polygonIndicesPool.free(polygonIndices);
+					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
 					polygon.push(x1);
@@ -5528,6 +5532,9 @@ var spine;
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i];
+					convexPolygonsIndices.splice(i, 1);
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 			return convexPolygons;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
spine-ts/build/spine-webgl.js.map


+ 7 - 0
spine-ts/build/spine-widget.js

@@ -5460,6 +5460,10 @@ var spine;
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
 					}
+					else {
+						this.polygonPool.free(polygon);
+						this.polygonIndicesPool.free(polygonIndices);
+					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
 					polygon.push(x1);
@@ -5528,6 +5532,9 @@ var spine;
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i];
+					convexPolygonsIndices.splice(i, 1);
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 			return convexPolygons;

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
spine-ts/build/spine-widget.js.map


+ 6 - 0
spine-ts/core/src/Triangulator.ts

@@ -164,6 +164,9 @@ module spine {
 					if (polygon.length > 0) {
 						convexPolygons.push(polygon);
 						convexPolygonsIndices.push(polygonIndices);
+					} else {
+						this.polygonPool.free(polygon)
+						this.polygonIndicesPool.free(polygonIndices);
 					}
 					polygon = this.polygonPool.obtain();
 					polygon.length = 0;
@@ -238,6 +241,9 @@ module spine {
 				if (polygon.length == 0) {
 					convexPolygons.splice(i, 1);
 					this.polygonPool.free(polygon);
+					polygonIndices = convexPolygonsIndices[i]
+					convexPolygonsIndices.splice(i, 1)
+					this.polygonIndicesPool.free(polygonIndices);
 				}
 			}
 

+ 4 - 0
spine-ts/webgl/example/index.html

@@ -79,6 +79,9 @@ function init () {
 	assetManager.loadText("assets/stretchyman.json");
 	assetManager.loadText("assets/stretchyman.atlas");
 	assetManager.loadTexture("assets/stretchyman.png");
+	assetManager.loadText("assets/coin.json");
+	assetManager.loadText("assets/coin.atlas");
+	assetManager.loadTexture("assets/coin.png");
 	requestAnimationFrame(load);
 }
 
@@ -91,6 +94,7 @@ function load () {
 		skeletons["goblins"] = loadSkeleton("goblins-mesh", "walk", false, "goblin");
 		skeletons["vine"] = loadSkeleton("vine", "animation", false);
 		skeletons["stretchyman"] = loadSkeleton("stretchyman", "sneak", false);
+		skeletons["coin"] = loadSkeleton("coin", "rotate", false);
 		setupUI();
 		requestAnimationFrame(render);
 	} else {

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.