Kaynağa Gözat

Polygon: keep ref on cached primitives

trethaller 6 yıl önce
ebeveyn
işleme
8c182f667f
1 değiştirilmiş dosya ile 4 ekleme ve 1 silme
  1. 4 1
      hide/prefab/l3d/Polygon.hx

+ 4 - 1
hide/prefab/l3d/Polygon.hx

@@ -145,7 +145,7 @@ class Polygon extends Object3D {
 		primitive.tangents = [for(p in points) new h3d.col.Point(0., 1., 0.)];
 		primitive.uvs = [for(uv in uvs) new h3d.prim.UV(uv.x, uv.y)];
 		primitive.colors = [for(p in points) new h3d.col.Point(1,1,1)];
-
+		primitive.incref();
 		cache.set(shape, primitive);
 		return primitive;
 	}
@@ -189,7 +189,10 @@ class Polygon extends Object3D {
 			polyPrim.alloc(h3d.Engine.getCurrent());
 		}
 		#if editor
+		if(cachedPrim != null)
+			cachedPrim.decref();
 		cachedPrim = polyPrim;
+		cachedPrim.incref();
 		#end
 		return polyPrim;
 	}