Ver código fonte

Update Light

ShiroSmith 6 anos atrás
pai
commit
7db16b8989
2 arquivos alterados com 23 adições e 6 exclusões
  1. 16 3
      hide/prefab/ContextShared.hx
  2. 7 3
      hide/prefab/Light.hx

+ 16 - 3
hide/prefab/ContextShared.hx

@@ -71,6 +71,7 @@ class ContextShared extends hxd.prefab.ContextShared {
 		path.ext = "dat";
 		var datDir = path.toString();
 		var instanceDir = datDir + "/" + p;
+
 		if(!sys.FileSystem.isDirectory( hide.Ide.inst.getPath(datDir)))
 			sys.FileSystem.createDirectory( hide.Ide.inst.getPath(datDir));
 		if(!sys.FileSystem.isDirectory( hide.Ide.inst.getPath(instanceDir)))
@@ -80,12 +81,24 @@ class ContextShared extends hxd.prefab.ContextShared {
 		path.dir = instanceDir;
 		path.file = file;
 		path.ext = ext;
-
 		var file = hide.Ide.inst.getPath(path.toString());
-		if( bytes == null )
+
+		if( bytes == null ){
 			try sys.FileSystem.deleteFile(file) catch( e : Dynamic ) {};
-		else
+			var p = hide.Ide.inst.getPath(instanceDir);
+			if(sys.FileSystem.isDirectory(p)){
+				var dir = sys.FileSystem.readDirectory(p);
+				if(dir.length == 0) sys.FileSystem.deleteDirectory(p);
+			}
+			var p = hide.Ide.inst.getPath(datDir);
+			if(sys.FileSystem.isDirectory(p)){
+				var dir = sys.FileSystem.readDirectory(p);
+				if(dir.length == 0) sys.FileSystem.deleteDirectory(p);
+			}
+			return;
+		}else{
 			sys.io.File.saveBytes(file, bytes);
+		}
 	}
 
 	#end

+ 7 - 3
hide/prefab/Light.hx

@@ -144,8 +144,10 @@ class Light extends Object3D {
 	function loadBaked( ctx : Context ) {
 		var light = Std.instance(ctx.local3d, h3d.scene.pbr.Light);
 		if(light == null) return;
-		var res = ctx.shared.loadPrefabDat("shadowMap", "bake", name);
-		if(res != null) light.shadows.loadStaticData(res.entry.getBytes());
+		if(light.shadows.mode == Static || light.shadows.mode == Mixed){
+			var res = ctx.shared.loadPrefabDat("shadowMap", "bake", name);
+			if(res != null) light.shadows.loadStaticData(res.entry.getBytes());
+		}
 	}
 
 	override function updateInstance( ctx : Context, ?propName : String ) {
@@ -321,10 +323,12 @@ class Light extends Object3D {
 			if( debugSpot != null ) debugSpot.visible = isSelected || ctx.shared.editorDisplay;
 			sel.name = "__selection";
 		}
+
 		// no "Mixed" in editor (prevent double shadowing)
 		if( light.shadows.mode == Mixed ) light.shadows.mode = Static;
+
 		// when selected, force Dynamic mode (realtime preview)
-		if( isSelected && shadows.mode != None ) light.shadows.mode = Dynamic;
+		//if( isSelected && shadows.mode != None ) light.shadows.mode = Dynamic;
 
 		#end
 	}