Browse Source

Fix missing #if

lviguier 1 year ago
parent
commit
c6d1a51888
4 changed files with 29 additions and 8 deletions
  1. 9 1
      h3d/impl/Benchmark.hx
  2. 10 5
      h3d/prim/ModelDatabase.hx
  3. 6 2
      hxd/fmt/fbx/Writer.hx
  4. 4 0
      hxsl/CacheFile.hx

+ 9 - 1
h3d/impl/Benchmark.hx

@@ -70,7 +70,7 @@ class Benchmark extends h2d.Graphics {
 	public var measureCpu = false;
 	public var displayTriangleCount = true;
 
-	public var measureCpuThread: sys.thread.Thread = null;
+	#if target.threaded public var measureCpuThread: sys.thread.Thread = null; #end
 
 	var tip : h2d.Text;
 	var tipCurrent : StatsObject;
@@ -165,9 +165,11 @@ class Benchmark extends h2d.Graphics {
 		}
 		else {
 			var t = s.name + "( " + Std.int(s.time / 1e6) + "." + StringTools.lpad(""+(Std.int(s.time/1e4)%100),"0",2) + " ms";
+			#if target.threaded
 			if (measureCpuThread == null) {
 				t += " " + fmt(s.drawCalls, "draws")+ fmt(s.dispatches, "dispatches");
 			}
+			#end
 			t += ")";
 
 			tip.text = t;
@@ -199,8 +201,10 @@ class Benchmark extends h2d.Graphics {
 		var changed = false;
 		while( waitFrames.length > 0 ) {
 			var q = waitFrames[0];
+			#if target.threaded
 			if( measureCpuThread == null && !q.isAvailable() )
 				break;
+			#end
 			waitFrames.shift();
 
 			// recycle previous stats
@@ -344,11 +348,13 @@ class Benchmark extends h2d.Graphics {
 		time.textColor = 0xFFFFFF;
 		var timeMs = totalTime / 1e6;
 		var totalName = measureCpu ? "cpu" : "gpu";
+		#if target.threaded
 		if (measureCpuThread != null) {
 			var n = measureCpuThread.getName();
 			if (n != null)
 				totalName = n;
 		}
+		#end
 		time.text = Std.int(timeMs) + "." + Std.int((timeMs * 10) % 10) + " " + totalName;
 
 		while( labels.length > count )
@@ -407,8 +413,10 @@ class Benchmark extends h2d.Graphics {
 		if( !enable ) return;
 		if( currentFrame != null && currentFrame.name == name )
 			return;
+		#if target.threaded
 		if( measureCpuThread != null && sys.thread.Thread.current() != measureCpuThread )
 			return;
+		#end
 		var q = allocQuery();
 		q.name = name;
 		q.drawCalls = engine.drawCalls;

+ 10 - 5
h3d/prim/ModelDatabase.hx

@@ -95,14 +95,19 @@ class ModelDatabase {
 		var fs = Std.downcast(hxd.res.Loader.currentInstance.fs, hxd.fs.LocalFileSystem);
 		if (fs == null)
 			return baseLodConfig;
-		var c = @:privateAccess fs.convert.getConfig(defaultLodConfigs, baseLodConfig, dir, function(fullObj) {
-			if (Reflect.hasField(fullObj, "lods.screenRatio"))
-				return Reflect.field(fullObj, "lods.screenRatio");
 
+		#if (sys || nodejs)
+			var c = @:privateAccess fs.convert.getConfig(defaultLodConfigs, baseLodConfig, dir, function(fullObj) {
+				if (Reflect.hasField(fullObj, "lods.screenRatio"))
+					return Reflect.field(fullObj, "lods.screenRatio");
+
+				return baseLodConfig;
+			});
+			return c;
+		#else
 			return baseLodConfig;
-		});
+		#end
 
-		return c;
 	}
 
 	public static var current = new ModelDatabase();

+ 6 - 2
hxd/fmt/fbx/Writer.hx

@@ -801,7 +801,7 @@ class Writer {
 
 		function clean( obj : h3d.scene.Object ) : h3d.scene.Object {
 			if (Std.isOfType(obj, h3d.scene.Interactive) ||
-				Std.isOfType(obj, hrt.prefab.fx.Emitter.EmitterObject) ||
+				#if hide Std.isOfType(obj, hrt.prefab.fx.Emitter.EmitterObject) || #end
 				!obj.visible)
 				return null;
 
@@ -854,7 +854,11 @@ class Writer {
 		if (destinationPath != null) {
 			var out = new haxe.io.BytesOutput();
 			new hxd.fmt.fbx.Writer(out).write(roots, params);
-			sys.io.File.saveBytes(destinationPath, out.getBytes());
+			#if js
+				hxd.File.saveBytes(destinationPath, out.getBytes());
+			#else
+				sys.io.File.saveBytes(destinationPath, out.getBytes());
+			#end
 			callb();
 		}
 	}

+ 4 - 0
hxsl/CacheFile.hx

@@ -148,10 +148,14 @@ class CacheFile extends Cache {
 
 	function resolveShader( name : String ) : hxsl.Shader {
 		if ( StringTools.endsWith(name, ".shgraph") ) {
+			#if hide
 			var shgraph : hrt.shgraph.ShaderGraph = try cast hxd.res.Loader.currentInstance.load(name).toPrefab().load() catch( e : hxd.res.NotFound ) null;
 			if (shgraph == null)
 				return null;
 			return shgraph.makeShaderInstance();
+			#else
+			return null;
+			#end
 		}
 		var cl = Type.resolveClass(name);
 		if( cl == null )