Sfoglia il codice sorgente

Trails: fix null on remove and re-add

trethaller 2 anni fa
parent
commit
cab96885f8
1 ha cambiato i file con 7 aggiunte e 4 eliminazioni
  1. 7 4
      hrt/prefab/l3d/Trails.hx

+ 7 - 4
hrt/prefab/l3d/Trails.hx

@@ -150,11 +150,7 @@ class TrailObj extends h3d.scene.Mesh {
         }
         trailsPool = trails[0];
 
-        if (dprim != null)
-            dprim.alloc(null);
-
         reset();
-
     }
 
     var maxNumPoints : Int = 0;
@@ -213,9 +209,16 @@ class TrailObj extends h3d.scene.Mesh {
     }
 
     override function onRemove() {
+        super.onRemove();
         dprim.dispose();
     }
 
+    override function onAdd() {
+        super.onAdd();
+        dprim.alloc(null);
+    }
+
+
     public function reset() {
         for (t in trails) {
             var p = t.firstPoint;