Browse Source

Fix build

ShiroSmith 6 năm trước cách đây
mục cha
commit
890ce5e220

+ 3 - 0
h3d/impl/RenderContext.hx

@@ -16,4 +16,7 @@ class RenderContext {
 		textures = new h3d.impl.TextureCache(this);
 		textures = new h3d.impl.TextureCache(this);
 	}
 	}
 
 
+	public function dispose() {
+		textures.dispose();
+	}
 }
 }

+ 2 - 3
h3d/scene/pbr/Light.hx

@@ -14,10 +14,9 @@ class Light extends h3d.scene.Light {
 		if( shadows == null ) shadows = new h3d.pass.Shadows(this);
 		if( shadows == null ) shadows = new h3d.pass.Shadows(this);
 	}
 	}
 
 
-	override function dispose() {
-		super.dispose();
+	override function onRemove() {
+		super.onRemove();
 		if( shadows != null ) shadows.dispose();
 		if( shadows != null ) shadows.dispose();
-		if( primitive != null ) primitive.dispose();
 	}
 	}
 
 
 	override function sync(ctx) {
 	override function sync(ctx) {

+ 13 - 3
h3d/scene/pbr/SpotLight.hx

@@ -14,8 +14,8 @@ class SpotLight extends Light {
 	public function new(?parent) {
 	public function new(?parent) {
 		pbr = new h3d.shader.pbr.Light.SpotLight();
 		pbr = new h3d.shader.pbr.Light.SpotLight();
 		shadows = new h3d.pass.SpotShadowMap(this);
 		shadows = new h3d.pass.SpotShadowMap(this);
+		primitive = spotLightPrim();
 		super(pbr,parent);
 		super(pbr,parent);
-		generatePrim();
 		lightProj = new h3d.Camera();
 		lightProj = new h3d.Camera();
 		lightProj.screenRatio = 1.0;
 		lightProj.screenRatio = 1.0;
 		range = 10;
 		range = 10;
@@ -52,7 +52,7 @@ class SpotLight extends Light {
 		return angle = v;
 		return angle = v;
 	}
 	}
 
 
-	function generatePrim(){
+	function generatePrim() {
 		var points = new Array<h3d.col.Point>();
 		var points = new Array<h3d.col.Point>();
 
 
 		// Left
 		// Left
@@ -81,7 +81,17 @@ class SpotLight extends Light {
 
 
 		var prim = new h3d.prim.Polygon(points);
 		var prim = new h3d.prim.Polygon(points);
 		prim.addNormals();
 		prim.addNormals();
-		primitive = prim;
+		return prim;
+	}
+
+	public static function spotLightPrim() {
+		var engine = h3d.Engine.getCurrent();
+		var p : Polygon = @:privateAccess engine.resCache.get(SpotLight);
+		if( p != null )
+			return p;
+		p = generatePrim();
+		@:privateAccess engine.resCache.set(SpotLight, p);
+		return p;
 	}
 	}
 
 
 	function generateLightProj(){
 	function generateLightProj(){