Browse Source

cleanup old things

Nicolas Cannasse 4 years ago
parent
commit
080bc6efb3

+ 0 - 2
hide/Ide.hx

@@ -19,7 +19,6 @@ class Ide {
 	public var database : cdb.Database;
 	public var database : cdb.Database;
 	public var shaderLoader : hide.tools.ShaderLoader;
 	public var shaderLoader : hide.tools.ShaderLoader;
 	public var fileWatcher : hide.tools.FileWatcher;
 	public var fileWatcher : hide.tools.FileWatcher;
-	public var typesCache : hide.tools.TypesCache;
 	public var isCDB = false;
 	public var isCDB = false;
 	public var isDebugger = false;
 	public var isDebugger = false;
 
 
@@ -577,7 +576,6 @@ class Ide {
 		var title = config.current.get("hide.windowTitle");
 		var title = config.current.get("hide.windowTitle");
 		window.title = title != null ? title : ((isCDB ? "CastleDB" : "HIDE") + " - " + dir);
 		window.title = title != null ? title : ((isCDB ? "CastleDB" : "HIDE") + " - " + dir);
 		shaderLoader = new hide.tools.ShaderLoader();
 		shaderLoader = new hide.tools.ShaderLoader();
-		typesCache = new hide.tools.TypesCache();
 
 
 		var localDir = sys.FileSystem.exists(resourceDir) ? resourceDir : projectDir;
 		var localDir = sys.FileSystem.exists(resourceDir) ? resourceDir : projectDir;
 		var fsconf = config.current.get("fs.config", "default");
 		var fsconf = config.current.get("fs.config", "default");

+ 0 - 113
hide/tools/Interp.hx

@@ -1,113 +0,0 @@
-package hide.tools;
-
-// make sure these classes are compiled
-import h3d.anim.SmoothTarget;
-
-class Interp extends hscript.Interp {
-
-	var ide : hide.Ide;
-
-	public function new() {
-		ide = hide.Ide.inst;
-		super();
-		// share some classes
-		variables.set("hxd", { Res : new ResourceLoader([]) });
-		variables.set("h3d", { mat : { Texture : h3d.mat.Texture } });
-		variables.set("haxe", { Json : haxe.Json });
-	}
-
-	public function shareEnum( e : Enum<Dynamic> ) {
-		for( c in e.getConstructors() )
-			variables.set(c, Reflect.field(e, c));
-	}
-
-	public function shareObject( obj : Dynamic ) {
-		for( f in Type.getInstanceFields(Type.getClass(obj)) ) {
-			var v = Reflect.field(obj, f);
-			if( Reflect.isFunction(v) )
-				variables.set(f, Reflect.makeVarArgs(function(args) return Reflect.callMethod(obj,v,args)));
-		}
-	}
-
-	override function set(o:Dynamic, f:String, v:Dynamic) : Dynamic {
-		var fset = Reflect.field(o, "hscriptSet");
-		if( fset != null )
-			return Reflect.callMethod(o, fset, [f,v]);
-		return super.set(o, f, v);
-	}
-
-	override function get(o:Dynamic, f:String) : Dynamic {
-		var fget = Reflect.field(o, "hscriptGet");
-		if( fget != null )
-			return Reflect.callMethod(o, fget, [f]);
-		return super.get(o, f);
-	}
-
-	override function fcall(o:Dynamic, f:String, args:Array<Dynamic>):Dynamic {
-		var fun = get(o, f);
-		if( !Reflect.isFunction(fun) ) {
-			if( fun == null )
-				throw o + " has no function " + f;
-			throw o + "." + f + " is not a function";
-		}
-		return call(o, fun, args);
-	}
-
-	override function cnew(cl:String, args:Array<Dynamic>):Dynamic {
-		var c = Type.resolveClass(cl);
-		if( c == null )
-			try {
-				c = resolve(cl);
-			} catch( e : hscript.Expr.Error ) {
-			}
-		if( c == null ) {
-			var s = ide.shaderLoader.load(cl);
-			if( s == null )
-				error(EUnknownVariable(cl));
-			return s;
-		}
-		return Type.createInstance(c,args);
-	}
-
-}
-
-class ResourceLoader {
-
-	var __path : Array<String>;
-
-	public function new(p) {
-		__path = p;
-	}
-
-	public function toTexture() {
-		return hide.comp.Scene.getCurrent().loadTextureDotPath(__path.join("."));
-	}
-
-	function resolvePath() {
-		var ide = hide.Ide.inst;
-		var dir = __path.copy();
-		var name = dir.pop();
-		var dir = dir.join("/");
-		for( f in sys.FileSystem.readDirectory(ide.getPath(dir)) )
-			if( f.substr(0, f.lastIndexOf(".")) == name )
-				return dir + "/" + f;
-		return null;
-	}
-
-	public function hscriptGet( field : String ) : Dynamic {
-
-		var f = Reflect.field(this,field);
-		if( f != null )
-			return Reflect.makeVarArgs(function(args) return Reflect.callMethod(this, f, args));
-
-		if( field == "entry" ) {
-			var path = resolvePath();
-			return hxd.res.Loader.currentInstance.load(path).entry;
-		}
-
-		var p = __path.copy();
-		p.push(field);
-		return new ResourceLoader(p);
-	}
-
-}

+ 0 - 148
hide/tools/MaterialScript.hx

@@ -1,148 +0,0 @@
-package hide.tools;
-/*
-
-class RendererScript extends h3d.scene.Renderer {
-
-	var callb : Dynamic;
-	var hasError = false;
-
-	public function new(callb:Dynamic) {
-		super();
-		this.callb = callb;
-	}
-
-	override function render() {
-		if( hasError ) {
-			callb();
-			return;
-		}
-		try {
-			callb();
-		} catch( e : hscript.Expr.Error ) {
-			hasError = true;
-			hide.Ide.inst.error(hscript.Printer.errorToString(e));
-		}
-	}
-
-}
-
-class Properties extends hxd.impl.Properties {
-
-	public var obj : Dynamic;
-	var interp : Interp;
-
-	public function new(interp) {
-		this.interp = interp;
-	}
-
-	public function getFields( o : Dynamic ) {
-		if( o == obj )
-			return Reflect.fields(obj).concat(Lambda.array({ iterator : interp.variables.keys }));
-		return Reflect.fields(o);
-	}
-
-	override function getField( o : Dynamic, f : String ) {
-		if( o == obj && interp.variables.exists(f) )
-			return interp.variables.get(f);
-		return @:privateAccess interp.get(o, f);
-	}
-
-	override function setField( o : Dynamic, f : String, v : Dynamic ) {
-		if( o == obj )
-			throw "TODO";
-		@:privateAccess interp.set(o, f, v);
-	}
-
-}
-
-class MaterialScript extends h3d.mat.MaterialScript {
-
-	var ide : hide.Ide;
-	public var renderer : Properties;
-
-	public function new() {
-		super(); // name will be set by script itself
-		ide = hide.Ide.inst;
-	}
-
-	function loadModule( path : String ) : Dynamic {
-		var fullPath = ide.getPath(path);
-		var script = try sys.io.File.getContent(fullPath) catch( e : Dynamic ) throw "File not found " + path;
-		var parser = new hscript.Parser();
-		parser.preprocesorValues.set("script", true);
-		var decls = try parser.parseModule(script, path) catch( e : hscript.Expr.Error ) { onError(Std.string(e) + " line " + parser.line); return null; }
-		var objs : Dynamic = {};
-		for( d in decls )
-			switch( d ) {
-			case DClass(c):
-				Reflect.setField(objs, c.name, makeClass.bind(c));
-			default:
-			}
-		return objs;
-	}
-
-	function lookupShader( shader : hxsl.Shader, ?passName : String ) {
-		var s = @:privateAccess shader.shader;
-		var scene = hide.comp.Scene.getCurrent();
-		for( m in scene.s3d.getMaterials() )
-			for( p in m.getPasses() ) {
-				if( passName != null && p.name != passName ) continue;
-				for( ss in p.getShaders() )
-					if( @:privateAccess ss.shader == s )
-						return ss;
-			}
-		return shader;
-	}
-
-	function makeClass( c : hscript.Expr.ClassDecl, ?args : Array<Dynamic> ) {
-		var interp = new Interp();
-		var makeObj = null;
-		if( c.extend != null )
-			switch( c.extend ) {
-			case CTPath(["h3d", "scene", "Renderer"], _):
-				makeObj = function() return new RendererScript(interp.variables.get("render"));
-				interp.shareEnum(hxsl.Output);
-				interp.shareEnum(h3d.impl.Driver.Feature);
-				interp.shareEnum(h3d.mat.Data.Wrap);
-				interp.shareEnum(h3d.mat.BlendMode);
-			default:
-			}
-		if( makeObj == null )
-			throw "Don't know what to do with " + c.name;
-
-		interp.variables.set("loadShader", function(name) return ide.shaderLoader.load(name));
-		interp.variables.set("lookupShader", lookupShader);
-		interp.variables.set("getS3D", function() return hide.comp.Scene.getCurrent().s3d);
-
-		var props = new Properties(interp);
-		interp.variables.set("applyProperties", props.apply);
-
-		for( f in c.fields )
-			switch( f.kind ) {
-			case KVar(v):
-				interp.variables.set(f.name, v.expr == null ? null : @:privateAccess interp.exprReturn(v.expr));
-			case KFunction(fd):
-				var ed : hscript.Expr.ExprDef = EFunction(fd.args, fd.expr, f.name, fd.ret);
-				var e = #if hscriptPos { pmin : 0, pmax : 0, origin : null, line : 0, e : ed } #else ed #end;
-				interp.variables.set(f.name, @:privateAccess interp.exprReturn(e));
-			default:
-			}
-
-
-		// share functions
-		var obj = makeObj();
-		props.obj = obj;
-		interp.shareObject(obj);
-		interp.variables.set("super", obj);
-		interp.variables.set("this", obj);
-
-		var fnew = interp.variables.get("new");
-		if( fnew != null ) Reflect.callMethod(null, fnew, args == null ? [] : args);
-
-		renderer = props;
-
-		return obj;
-	}
-
-}
-*/

+ 0 - 20
hide/tools/RendererSupport.hx

@@ -1,20 +0,0 @@
-package hide.tools;
-
-class RendererSupport {
-	
-	public function getS3D() : h3d.scene.Scene {
-		throw "TODO";
-		return null;
-	}
-	
-	public function lookupShader<T:hxsl.Shader>( current : T, ?passName : String ) : T {
-		throw "TODO";
-		return null;
-	}
-	
-	public static function get() : RendererSupport {
-		throw "TODO";
-		return null;
-	}
-		
-}

+ 0 - 285
hide/tools/TypesCache.hx

@@ -1,285 +0,0 @@
-package hide.tools;
-import hide.comp.PropsEditor;
-import hrt.prefab.Props;
-
-enum ModelKind {
-	PrefabDef;
-	Shader;
-}
-
-typedef TypeModel = {
-	var id : String;
-	var kind : ModelKind;
-	var fields : Array<PropDef>;
-	var file : TypeFile;
-}
-
-typedef TypeFile = {
-	var path : String;
-	var watch : Void -> Void;
-	var models : Array<TypeModel>;
-	var files : Array<TypeFile>;
-	var error : String;
-}
-
-class TypesCache {
-
-	var ide : hide.Ide;
-	var needRebuild = true;
-	var types : Array<TypeModel> = [];
-	var htype : Map<String, TypeModel> = new Map();
-	var hfiles : Map<String, TypeFile> = new Map();
-	var watchers = [];
-
-	public function new() {
-		ide = hide.Ide.inst;
-	}
-
-	public function getModels() {
-		if( needRebuild )
-			rebuild();
-		return types;
-	}
-
-	public function get( id : String, opt = false ) {
-		if( needRebuild )
-			rebuild();
-		var t = htype.get(id);
-		if( t == null && !opt ) throw "Missing model " + id;
-		return t;
-	}
-
-	function rebuild() {
-		var old = hfiles.copy();
-		htype = new Map();
-		hfiles = new Map();
-		types = [];
-		needRebuild = false;
-
-		var src : Array<Dynamic> = ide.currentConfig.get("haxe.classPath");
-		for( dir in src ) {
-			var path = ide.projectDir + "/" + dir;
-			if( !sys.FileSystem.exists(path) )
-				continue;
-			browseRec(path,old);
-		}
-		for( f in old ) {
-			var fnew = hfiles.get(f.path);
-			if( fnew != null && fnew.error != null ) {
-				fnew.models = [for( m in f.models ) { id : m.id, kind : m.kind, fields : [{ t : PUnsupported(fnew.error), name : "", def : null }], file : fnew }];
-				for( m in fnew.models ) {
-					types.push(m);
-					htype.set(m.id, m);
-				}
-			}
-			ide.fileWatcher.unregister(f.path, f.watch);
-		}
-	}
-
-	function browseRec( path : String, old : Map<String,TypeFile> ) {
-		var dir : TypeFile = {
-			path : path,
-			watch : null,
-			files : [],
-			models : [],
-			error : null,
-		};
-		addFile(dir);
-
-		for( f in sys.FileSystem.readDirectory(path) ) {
-			var fpath = path + "/" + f;
-			if( sys.FileSystem.isDirectory(fpath) ) {
-				dir.files.push(browseRec(fpath, old));
-				continue;
-			}
-			if( !StringTools.endsWith(f, ".hx") )
-				continue;
-			var f = old.get(fpath);
-			if( f != null ) {
-				old.remove(fpath); // reuse
-				addFile(f);
-				dir.files.push(f);
-				continue;
-			}
-			f = makeFile(fpath);
-			addFile(f);
-			dir.files.push(f);
-		}
-		return dir;
-	}
-
-	function makeFile( path : String ) {
-		var file : TypeFile = {
-			path : path,
-			watch : null,
-			files : [],
-			models : [],
-			error : null,
-		};
-		var content = sys.io.File.getContent(path);
-		var scan = content.indexOf("hxsl.Shader") >= 0 || content.indexOf("h3d.shader.ScreenShader") >= 0 || content.indexOf("@:prefab") >= 0;
-		if( !scan )
-			return file;
-		var p = new hscript.Parser();
-		try {
-			var m = p.parseModule(content, path);
-			var pack = "";
-			for( d in m )
-				switch( d ) {
-				case DPackage(p):
-					pack = p.length == 0 ? "" : p.join(".") + ".";
-				case DClass(c) if( c.extend != null && (c.extend.match(CTPath(["hxsl", "Shader"])) || c.extend.match(CTPath(["h3d", "shader", "ScreenShader"]))) ):
-					var error = null;
-					var shader = try ide.shaderLoader.loadSharedShader(pack + c.name, path) catch( e : hxsl.Ast.Error ) { error = e.toString(); null; };
-					var fields = [];
-					var fmap = new Map();
-					if( shader == null )
-						fields.push({ name : "", t : PUnsupported("Failed to load this shader"+(error == null ? "" : " ("+error+")")), def : null });
-					else {
-						for( v in shader.shader.data.vars ) {
-							if( v.kind != Param ) continue;
-							if( v.qualifiers != null && v.qualifiers.indexOf(Ignore) >= 0 ) continue;
-							var t = makeShaderType(v);
-							var fl = { name : v.name, t : t, def : defType(t) };
-							fields.push(fl);
-							fmap.set(v.name, fl);
-						}
-						for( i in shader.inits ) {
-							var fl = fmap.get(i.variable.name);
-							if( !fl.t.match(PUnsupported(_)) )
-								fl.def = i.value;
-						}
-					}
-					file.models.push({ id : pack + c.name, kind : Shader, file : file, fields : fields });
-				case DTypedef(t) if( Lambda.exists(t.meta, function(m) return m.name == ":prefab") ):
-					var fields = [];
-					switch( t.t ) {
-					case CTAnon(fl):
-						for( f in fl ) {
-							var t = makeType(f.t);
-							fields.push({ name : f.name, t : t, def : defType(t) });
-						}
-					default:
-					}
-					file.models.push({ id : pack + t.name, kind : PrefabDef, file : file, fields : fields });
-				default:
-				}
-		} catch( e : hscript.Expr.Error ) {
-			file.error = e.toString();
-		}
-		return file;
-	}
-
-	function addFile( t : TypeFile ) {
-		hfiles.set(t.path, t);
-		if( t.watch == null ) {
-			t.watch = onFileChange.bind(t);
-			ide.fileWatcher.register(t.path, t.watch, true);
-		}
-		for( m in t.models ) {
-			types.push(m);
-			htype.set(m.id, m);
-		}
-	}
-
-	function onFileChange( t : TypeFile ) {
-		hfiles.remove(t.path);
-		ide.fileWatcher.unregister(t.path, t.watch);
-		t.watch = null;
-		for( f in t.files )
-			onFileChange(f);
-		for( m in t.models ) {
-			types.remove(m);
-			htype.remove(m.id);
-		}
-		if( !needRebuild )
-			haxe.Timer.delay(function() {
-				if( !needRebuild ) return;
-				for( w in watchers.copy() )
-					w();
-			}, 200);
-		needRebuild = true;
-	}
-
-	public function watch( w : Void -> Void ) {
-		watchers.push(w);
-	}
-
-	public function unwatch( w : Void -> Void ) {
-		watchers.remove(w);
-	}
-
-	public function getModelName( m : TypeModel ) {
-		return switch( m.kind ) {
-		case Shader: "Shader " + m.id.split(".").pop();
-		case PrefabDef: m.id.split(".").pop();
-		}
-	}
-
-	public static function defType( t : PropType ) : Dynamic {
-		switch( t ) {
-		case PInt(min, _):
-			return if( min == null ) 0 else min;
-		case PFloat(min, max):
-			if( min < 0 && max > 0 )
-				return 0.;
-			return min == null ? 0 : min;
-		case PBool:
-			return false;
-		case PTexture:
-			return null;
-		case PVec(n):
-			return [for( i in 0...n ) 0.];
-		case PUnsupported(_):
-			return null;
-		case PChoice(c):
-			return c != null && c.length > 0 ? c[0] : null;
-		case PEnum(e):
-			return e.getConstructors()[0];
-		case PFile(_):
-			return null;
-		case PString(_):
-			return null;
-		}
-	}
-
-	function makeType( t : hscript.Expr.CType ) : PropType {
-		return switch( t ) {
-		case CTPath(["Int"]):
-			PInt();
-		case CTPath(["Float"]):
-			PFloat();
-		case CTPath(["Bool"]):
-			PBool;
-		case CTPath(["String"]):
-			PString();
-		default:
-			PUnsupported(new hscript.Printer().typeToString(t));
-		}
-	}
-
-	public static function makeShaderType( v : hxsl.Ast.TVar ) : PropType {
-		var min : Null<Float> = null, max : Null<Float> = null;
-		if( v.qualifiers != null )
-			for( q in v.qualifiers )
-				switch( q ) {
-				case Range(rmin, rmax): min = rmin; max = rmax;
-				default:
-				}
-		return switch( v.type ) {
-		case TInt:
-			PInt(min == null ? null : Std.int(min), max == null ? null : Std.int(max));
-		case TFloat:
-			PFloat(min != null ? min : 0.0, max != null ? max : 1.0);
-		case TBool:
-			PBool;
-		case TSampler2D:
-			PTexture;
-		case TVec(n, VFloat):
-			PVec(n);
-		default:
-			PUnsupported(hxsl.Ast.Tools.toString(v.type));
-		}
-	}
-
-}

+ 0 - 42
hrt/prefab/Scene.hx

@@ -1,42 +0,0 @@
-package hrt.prefab;
-
-class Scene extends Prefab {
-
-	override function load(obj:Dynamic) {
-	}
-
-	override function save() {
-		return {};
-	}
-
-	override function makeInstance( ctx : Context ) {
-		#if editor
-		var scene = hide.comp.Scene.getCurrent();
-		var obj = scene.loadModel(source, true);
-		var cam = @:privateAccess scene.defaultCamera;
-
-		// allow to add sub elements relative to camera target
-		var root = new h3d.scene.Object(ctx.local3d);
-		root.x = cam.target.x;
-		root.y = cam.target.y;
-		root.z = cam.target.z;
-		obj.x -= root.x;
-		obj.y -= root.y;
-		obj.z -= root.z;
-		root.addChild(obj);
-
-		ctx = ctx.clone(this);
-		ctx.local3d = root;
-		#end
-		return ctx;
-	}
-
-	#if editor
-	override function getHideProps() : HideProps {
-		return { icon : "cube", name : "Scene", fileSource : ["hsd"] };
-	}
-	#end
-
-	static var _ = Library.register("scene", Scene);
-
-}

+ 0 - 115
hrt/prefab/Settings.hx

@@ -1,115 +0,0 @@
-package hrt.prefab;
-
-class Settings extends Prefab {
-
-	var modelType : String;
-	var ignoredFields : Array<String> = [];
-	public var data : Dynamic = {};
-
-	override function save() {
-		var o = Reflect.copy(data);
-		o.modelType = modelType;
-		if( ignoredFields.length > 0 )
-			o.ignoredFields = ignoredFields;
-		return o;
-	}
-
-	override function load( o : Dynamic ) {
-		this.data = o;
-		modelType = o.modelType;
-		ignoredFields = o.ignoredFields;
-		if( ignoredFields == null ) ignoredFields = [];
-		Reflect.deleteField(o, "modelType");
-		Reflect.deleteField(o, "ignoredFields");
-	}
-
-	public function apply( to : {} ) {
-		var fields = Reflect.fields(data);
-		fields.remove("type");
-		fields.remove("children");
-		fields.remove("name");
-		for( f in fields ) {
-			var prev : Dynamic = Reflect.getProperty(to, f);
-			var value : Dynamic = Reflect.field(data, f);
-			if( prev != null && Std.is(prev, h3d.Vector) && Std.is(value, Array) ) {
-				var val : Array<Float> = value;
-				value = new h3d.Vector(value[0], value[1], value[2], value[3]);
-			}
-			Reflect.setProperty(to, f, value);
-		}
-	}
-
-	#if editor
-
-	override function getHideProps() : HideProps {
-		return { icon : "cogs", name : "Settings" };
-	}
-
-	override function edit( ctx : EditContext ) {
-		var props = ctx.properties.add(new hide.Element('
-			<dl>
-				<dt>Model</dt><dd><select><option value="">-- Choose --</option></select>
-			</dl>
-			<br/>
-		'),this);
-		var select = props.find("select");
-		var models = ctx.ide.typesCache.getModels();
-		for( m in models )
-			new hide.Element('<option>').attr("value", m.id).text(ctx.ide.typesCache.getModelName(m)).appendTo(select);
-		var modelDef = null;
-		if( modelType != null ) {
-			modelDef = ctx.ide.typesCache.get(modelType, true);
-			if( modelDef == null )
-				new hide.Element('<option>').attr("value", modelType).text("?"+modelType).appendTo(select);
-			select.val(modelType);
-		}
-		select.change(function(_) {
-			var prev = save();
-			var type = select.val();
-			load({ modelType : type });
-			ctx.rebuildProperties();
-			ctx.properties.undo.change(Custom(function(undo) {
-				if( undo )
-					load(prev);
-				else
-					load({ modelType : type });
-				ctx.rebuildProperties();
-			}));
-		});
-
-		if( modelDef == null ) {
-			ctx.properties.add(new hide.Element('$modelType was not found in source definitions'));
-			return;
-		}
-
-		var fields = Reflect.fields(data);
-		fields.remove("type");
-		fields.remove("name");
-		fields.remove("children");
-		fields.remove("modelType");
-		fields.remove("ignoredFields");
-		var changed = false;
-		for( f in modelDef.fields )
-			if( !fields.remove(f.name) ) {
-				if( f.def == null ) continue;
-				changed = true;
-				Reflect.setField(data, f.name, f.def);
-			}
-		for( f in fields ) {
-			changed = true;
-			Reflect.deleteField(data, f);
-		}
-		if( changed )
-			ctx.onChange(this, null);
-
-		ctx.properties.addProps(modelDef.fields, this.data);
-		var rebuild = ctx.rebuildProperties;
-		ctx.ide.typesCache.watch(rebuild);
-		ctx.cleanups.push(ctx.ide.typesCache.unwatch.bind(rebuild));
-	}
-
-	#end
-
-	static var _ = Library.register("settings", Settings);
-
-}

+ 24 - 1
hrt/prefab/Shader.hx

@@ -161,7 +161,7 @@ class Shader extends Prefab {
 		for(v in shaderDef.shader.data.vars) {
 		for(v in shaderDef.shader.data.vars) {
 			if(v.kind != Param)
 			if(v.kind != Param)
 				continue;
 				continue;
-			var prop = hide.tools.TypesCache.makeShaderType(v);
+			var prop = makeShaderType(v);
 			props.push({name: v.name, t: prop});
 			props.push({name: v.name, t: prop});
 		}
 		}
 		group.append(hide.comp.PropsEditor.makePropsList(props));
 		group.append(hide.comp.PropsEditor.makePropsList(props));
@@ -171,6 +171,29 @@ class Shader extends Prefab {
 		});
 		});
 	}
 	}
 
 
+	function makeShaderType( v : hxsl.Ast.TVar ) : hrt.prefab.Props.PropType {
+		var min : Null<Float> = null, max : Null<Float> = null;
+		if( v.qualifiers != null )
+			for( q in v.qualifiers )
+				switch( q ) {
+				case Range(rmin, rmax): min = rmin; max = rmax;
+				default:
+				}
+		return switch( v.type ) {
+		case TInt:
+			PInt(min == null ? null : Std.int(min), max == null ? null : Std.int(max));
+		case TFloat:
+			PFloat(min != null ? min : 0.0, max != null ? max : 1.0);
+		case TBool:
+			PBool;
+		case TSampler2D:
+			PTexture;
+		case TVec(n, VFloat):
+			PVec(n);
+		default:
+			PUnsupported(hxsl.Ast.Tools.toString(v.type));
+		}
+	}
 	override function getHideProps() : HideProps {
 	override function getHideProps() : HideProps {
 		return { icon : "cog", name : "Shader", fileSource : ["hx"], allowParent : function(p) return p.to(Object2D) != null || p.to(Object3D) != null || p.to(Material) != null  };
 		return { icon : "cog", name : "Shader", fileSource : ["hx"], allowParent : function(p) return p.to(Object2D) != null || p.to(Object3D) != null || p.to(Material) != null  };
 	}
 	}

+ 5 - 8
hrt/prefab/pbr/Anisotropy.hx

@@ -1,10 +1,7 @@
 package hrt.prefab.pbr;
 package hrt.prefab.pbr;
 
 
 import h3d.pass.Default;
 import h3d.pass.Default;
-import hrt.shader.AnisotropicFoward.FlatValue;
-import hrt.shader.AnisotropicFoward.NoiseTexture;
-import hrt.shader.AnisotropicFoward.FrequencyValue;
-import hrt.shader.AnisotropicFoward;
+import hrt.shader.AnisotropicForward;
 
 
 enum abstract AnisotropyMode(String) {
 enum abstract AnisotropyMode(String) {
 	var Flat;
 	var Flat;
@@ -78,7 +75,7 @@ class Anisotropy extends Prefab {
 
 
 	function refreshShaders( ctx : Context ) {
 	function refreshShaders( ctx : Context ) {
 		var fv = new FlatValue();
 		var fv = new FlatValue();
-		var as = new AnisotropicFoward();
+		var as = new AnisotropicForward();
 		var nt = new NoiseTexture();
 		var nt = new NoiseTexture();
 		var ff = new FrequencyValue();
 		var ff = new FrequencyValue();
 
 
@@ -91,7 +88,7 @@ class Anisotropy extends Prefab {
 			m.mainPass.removeShader(m.mainPass.getShader(NoiseTexture));
 			m.mainPass.removeShader(m.mainPass.getShader(NoiseTexture));
 			m.mainPass.removeShader(m.mainPass.getShader(FlatValue));
 			m.mainPass.removeShader(m.mainPass.getShader(FlatValue));
 			m.mainPass.removeShader(m.mainPass.getShader(FrequencyValue));
 			m.mainPass.removeShader(m.mainPass.getShader(FrequencyValue));
-			m.mainPass.removeShader(m.mainPass.getShader(AnisotropicFoward));
+			m.mainPass.removeShader(m.mainPass.getShader(AnisotropicForward));
 		}
 		}
 
 
 		for( m in mat ) {
 		for( m in mat ) {
@@ -116,7 +113,7 @@ class Anisotropy extends Prefab {
 
 
 	override function updateInstance( ctx : Context, ?propName : String ) {
 	override function updateInstance( ctx : Context, ?propName : String ) {
 		for( m in getMaterials(ctx) ) {
 		for( m in getMaterials(ctx) ) {
-			
+
 			var fv = m.mainPass.getShader(FlatValue);
 			var fv = m.mainPass.getShader(FlatValue);
 			if( fv != null ) {
 			if( fv != null ) {
 				fv.intensity = intensity;
 				fv.intensity = intensity;
@@ -145,7 +142,7 @@ class Anisotropy extends Prefab {
 
 
 	#if editor
 	#if editor
 	override function getHideProps() : HideProps {
 	override function getHideProps() : HideProps {
-		return { 	icon : "cube", 
+		return { 	icon : "cube",
 					name : "Anisotropy",
 					name : "Anisotropy",
 					allowParent : function(p) return p.to(Material) != null  };
 					allowParent : function(p) return p.to(Material) != null  };
 	}
 	}

+ 2 - 2
hrt/shader/AnisotropicFoward.hx → hrt/shader/AnisotropicForward.hx

@@ -8,7 +8,7 @@ class FrequencyValue extends hxsl.Shader {
 		@param var noiseFrequency : Float;
 		@param var noiseFrequency : Float;
 
 
 		@param var dirVector : Vec3;
 		@param var dirVector : Vec3;
-		
+
 		var calculatedUV : Vec2;
 		var calculatedUV : Vec2;
 		var anisotropy : Float;
 		var anisotropy : Float;
 		var direction : Vec3;
 		var direction : Vec3;
@@ -60,7 +60,7 @@ class NoiseTexture extends hxsl.Shader {
 	}
 	}
 }
 }
 
 
-class AnisotropicFoward extends h3d.shader.pbr.DefaultForward {
+class AnisotropicForward extends h3d.shader.pbr.DefaultForward {
 	static var SRC = {
 	static var SRC = {
 
 
 		@global var global : {
 		@global var global : {