ncannasse 7 роки тому
батько
коміт
d6054bb13c
2 змінених файлів з 0 додано та 222 видалено
  1. 0 112
      h2d/CachedBitmap.hx
  2. 0 110
      h3d/pass/MRT.hx

+ 0 - 112
h2d/CachedBitmap.hx

@@ -1,112 +0,0 @@
-package h2d;
-
-class CachedBitmap extends Drawable {
-
-	public var width(default, set) : Int;
-	public var height(default, set) : Int;
-	public var freezed : Bool;
-
-	var renderDone : Bool;
-	var tile : Tile;
-
-	public function new( ?parent, width = -1, height = -1 ) {
-		super(parent);
-		this.width = width;
-		this.height = height;
-	}
-
-	function clean() {
-		if( tile != null ) {
-			tile.dispose();
-			tile = null;
-		}
-	}
-
-	override function onRemove() {
-		clean();
-		super.onRemove();
-	}
-
-	function set_width(w) {
-		clean();
-		width = w;
-		return w;
-	}
-
-	function set_height(h) {
-		clean();
-		height = h;
-		return h;
-	}
-
-	public function getTile( ?ctx : RenderContext ) {
-		if( tile == null ) {
-			var scene = ctx == null ? getScene() : ctx.scene;
-			if( scene == null ) return null;
-			var tw = width < 0 ? scene.width : width;
-			var th = height < 0 ? scene.height : height;
-			if( tw != 0 && th != 0 ){
-				var tex = new h3d.mat.Texture(tw, th, [Target]);
-				renderDone = false;
-				tile = Tile.fromTexture(tex);
-			}
-		}
-		return tile;
-	}
-
-	function syncPosRec( s : Sprite ) {
-		s.calcAbsPos();
-		s.posChanged = true;
-		for( c in s.children )
-			syncPosRec(c);
-	}
-
-	override function draw( ctx : RenderContext ) {
-		if( tile != null )
-			emitTile(ctx, tile);
-	}
-
-	override function drawRec( ctx : RenderContext ) {
-		var scene = ctx.scene;
-		if( tile != null && ((width < 0 && scene.width != tile.width) || (height < 0 && scene.height != tile.height)) )
-			clean();
-		var tile = getTile(ctx);
-		if( (!freezed || !renderDone) && tile != null ) {
-			var oldA = matA, oldB = matB, oldC = matC, oldD = matD, oldX = absX, oldY = absY;
-
-			// init matrix without transformation
-			matA = 1;
-			matB = 0;
-			matC = 0;
-			matD = 1;
-			absX = 0;
-			absY = 0;
-
-			// force full resync
-			for( c in children )
-				syncPosRec(c);
-
-			ctx.pushTarget(tile.getTexture());
-			ctx.engine.clear(0);
-			var old = ctx.globalAlpha;
-			ctx.globalAlpha = 1;
-			for( c in children )
-				c.drawRec(ctx);
-			ctx.globalAlpha = old;
-			ctx.popTarget();
-
-			// restore
-			matA = oldA;
-			matB = oldB;
-			matC = oldC;
-			matD = oldD;
-			absX = oldX;
-			absY = oldY;
-
-			renderDone = true;
-		}
-
-		draw(ctx);
-	}
-
-}

+ 0 - 110
h3d/pass/MRT.hx

@@ -1,110 +0,0 @@
-package h3d.pass;
-
-@:access(h3d.pass.MRT)
-class MRTSubPass extends Default {
-
-	var mrt : MRT;
-	var output : Int;
-	var varId : Int;
-
-	public function new( m, output ) {
-		this.mrt = m;
-		this.output = output;
-		super("mrt"+output);
-		this.varId = hxsl.Globals.allocID(mrt.outputNames[output].split(".").pop() + "Map");
-	}
-
-	override function getOutputs() {
-		return [mrt.fragmentOutputs[output]];
-	}
-
-	public function getTexture() {
-		return mrt.textures[output];
-	}
-
-	override function draw( passes ) {
-		if( ctx == null )
-			ctx = mrt.ctx;
-		var texture = mrt.getTexture(output);
-		if( passes != null ) {
-			ctx.engine.pushTarget(texture);
-			passes = super.draw(passes);
-			ctx.engine.popTarget();
-		}
-		ctx.setGlobalID(varId, texture);
-		return passes;
-	}
-
-}
-
-class MRT extends Default {
-
-	var fragmentOutputs : Array<hxsl.Output>;
-	var outputNames : Array<String>;
-	var textures : Array<h3d.mat.Texture>;
-	public var clearColors : Array<Null<Int>>;
-	public var clearSameColor : Null<Int>;
-	public var clearDepth : Null<Float>;
-
-	public function new( fragmentOutputs, ?clearSameColor, ?clearDepth, ?clearColors ) {
-		this.fragmentOutputs = fragmentOutputs;
-		this.outputNames = [for( i in 0...fragmentOutputs.length ) getOutputName(i)];
-		this.clearSameColor = clearSameColor;
-		if( clearDepth ) this.clearDepth = 1.;
-		this.clearColors = clearColors;
-		super("mrt");
-	}
-
-	function getOutputName(i:Int) {
-		function getRec(v:hxsl.Output) {
-			return switch( v ) {
-			case Value(v): v;
-			case PackFloat(v), PackNormal(v), Swiz(v,_): getRec(v);
-			case Const(v): "Const" + Std.int(v);
-			case Vec2(vl), Vec3(vl), Vec4(vl): [for( v in vl ) getRec(v)].join("+");
-			}
-		}
-		return getRec(fragmentOutputs[i]);
-	}
-
-	override function getOutputs() {
-		return fragmentOutputs;
-	}
-
-	public function getTexture( index : Int ) {
-		return textures[index];
-	}
-
-	override function draw(passes:Object) {
-		if( textures == null )
-			textures = [];
-		for( i in 0...fragmentOutputs.length )
-			textures[i] = ctx.textures.allocTarget(outputNames[i], ctx.engine.width, ctx.engine.height, true);
-		if( clearColors != null )
-			for( i in 0...fragmentOutputs.length ) {
-				var color = clearColors[i];
-				if( color != null ) {
-					ctx.engine.pushTarget(textures[i]);
-					ctx.engine.clear(color);
-					ctx.engine.popTarget();
-				}
-			}
-		ctx.engine.pushTargets(textures);
-		if( clearDepth != null || clearSameColor != null )
-			ctx.engine.clear(clearSameColor, clearDepth);
-		passes = super.draw(passes);
-		ctx.engine.popTarget();
-		return passes;
-	}
-
-	public function getSubPass( output : Int ) {
-		var s = new MRTSubPass(this, output);
-		s.setContext(ctx);
-		return s;
-	}
-
-	public function drawImmediate( passes : Object ) {
-		return super.draw(passes);
-	}
-
-}