浏览代码

Adaptation to type switch, pass 2.

Yanrishatum 6 年之前
父节点
当前提交
64e5d6514f

+ 2 - 2
h2d/KeyFrames.hx

@@ -187,8 +187,8 @@ class KeyFrames extends Mask {
 		case AnchorPoint:
 		case AnchorPoint:
 			var bmp = Std.instance(l.spr, h2d.Bitmap);
 			var bmp = Std.instance(l.spr, h2d.Bitmap);
 			if( bmp != null ) {
 			if( bmp != null ) {
-				bmp.tile.dx = -Std.int(calcValue(0));
-				bmp.tile.dy = -Std.int(calcValue(1));
+				bmp.tile.dx = -calcValue(0);
+				bmp.tile.dy = -calcValue(1);
 			}
 			}
 		case XPosition:
 		case XPosition:
 			l.spr.x = calcValue(0);
 			l.spr.x = calcValue(0);

+ 1 - 1
h2d/Scene.hx

@@ -511,7 +511,7 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 			target = new Tile(tex,0, 0, width, height);
 			target = new Tile(tex,0, 0, width, height);
 		}
 		}
 		engine.begin();
 		engine.begin();
-		engine.setRenderZone(Std.int(target.x), Std.int(target.y), Std.int(target.width), Std.int(target.height));
+		engine.setRenderZone(Std.int(target.x), Std.int(target.y), hxd.Math.ceil(target.width), hxd.Math.ceil(target.height));
 
 
 		var tex = target.getTexture();
 		var tex = target.getTexture();
 		engine.pushTarget(tex);
 		engine.pushTarget(tex);

+ 1 - 1
h2d/filter/Ambient.hx

@@ -17,7 +17,7 @@ class Ambient extends AbstractMask {
 	inline function set_invert(v) return pass.shader.maskInvert = v;
 	inline function set_invert(v) return pass.shader.maskInvert = v;
 
 
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
-		var out = ctx.textures.allocTarget("ambientTmp", Std.int(t.width), Std.int(t.height), false);
+		var out = ctx.textures.allocTarget("ambientTmp", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		pass.apply(t.getTexture(), out, getMaskTexture(t), maskMatrix);
 		pass.apply(t.getTexture(), out, getMaskTexture(t), maskMatrix);
 		return h2d.Tile.fromTexture(out);
 		return h2d.Tile.fromTexture(out);
 	}
 	}

+ 1 - 1
h2d/filter/Bloom.hx

@@ -20,7 +20,7 @@ class Bloom extends Blur {
 	inline function set_power(v) return bloom.shader.power = v;
 	inline function set_power(v) return bloom.shader.power = v;
 
 
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
-		var dst = ctx.textures.allocTarget("dest", Std.int(t.width), Std.int(t.height), false);
+		var dst = ctx.textures.allocTarget("dest", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		h3d.pass.Copy.run(t.getTexture(), dst);
 		h3d.pass.Copy.run(t.getTexture(), dst);
 		var blurred = super.draw(ctx, t);
 		var blurred = super.draw(ctx, t);
 		bloom.shader.texture = blurred.getTexture();
 		bloom.shader.texture = blurred.getTexture();

+ 1 - 1
h2d/filter/ColorMatrix.hx

@@ -16,7 +16,7 @@ class ColorMatrix extends Filter {
 	inline function set_matrix(m) return pass.matrix = m;
 	inline function set_matrix(m) return pass.matrix = m;
 
 
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
-		var tout = ctx.textures.allocTarget("colorMatrixOut", Std.int(t.width), Std.int(t.height), false);
+		var tout = ctx.textures.allocTarget("colorMatrixOut", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		pass.apply(t.getTexture(), tout);
 		pass.apply(t.getTexture(), tout);
 		return h2d.Tile.fromTexture(tout);
 		return h2d.Tile.fromTexture(tout);
 	}
 	}

+ 1 - 1
h2d/filter/Displacement.hx

@@ -28,7 +28,7 @@ class Displacement extends Filter {
 	}
 	}
 
 
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
-		var out = ctx.textures.allocTarget("displacementOutput", Std.int(t.width), Std.int(t.height), false);
+		var out = ctx.textures.allocTarget("displacementOutput", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		ctx.engine.pushTarget(out);
 		ctx.engine.pushTarget(out);
 		var s = disp.shader;
 		var s = disp.shader;
 		s.texture = t.getTexture();
 		s.texture = t.getTexture();

+ 1 - 1
h2d/filter/DropShadow.hx

@@ -21,7 +21,7 @@ class DropShadow extends Glow {
 
 
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 		setParams();
 		setParams();
-		var save = ctx.textures.allocTarget("glowSave", Std.int(t.width), Std.int(t.height), false);
+		var save = ctx.textures.allocTarget("glowSave", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		h3d.pass.Copy.run(t.getTexture(), save, None);
 		h3d.pass.Copy.run(t.getTexture(), save, None);
 		pass.apply(ctx, save);
 		pass.apply(ctx, save);
 		var dx = Math.round(Math.cos(angle) * distance);
 		var dx = Math.round(Math.cos(angle) * distance);

+ 1 - 1
h2d/filter/Glow.hx

@@ -25,7 +25,7 @@ class Glow extends Blur {
 		setParams();
 		setParams();
 		var tex = t.getTexture();
 		var tex = t.getTexture();
 		var old = tex.filter;
 		var old = tex.filter;
-		var save = ctx.textures.allocTarget("glowSave", Std.int(t.width), Std.int(t.height), false);
+		var save = ctx.textures.allocTarget("glowSave", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		h3d.pass.Copy.run(tex, save, None);
 		h3d.pass.Copy.run(tex, save, None);
 		tex.filter = Linear;
 		tex.filter = Linear;
 		pass.apply(ctx, tex);
 		pass.apply(ctx, tex);

+ 1 - 1
h2d/filter/Mask.hx

@@ -42,7 +42,7 @@ class Mask extends AbstractMask {
 		var mask = getMaskTexture(t);
 		var mask = getMaskTexture(t);
 		if( mask == null )
 		if( mask == null )
 			throw "Mask should be rendered before masked object";
 			throw "Mask should be rendered before masked object";
-		var out = ctx.textures.allocTarget("maskTmp", Std.int(t.width), Std.int(t.height), false);
+		var out = ctx.textures.allocTarget("maskTmp", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		ctx.engine.pushTarget(out);
 		ctx.engine.pushTarget(out);
 		pass.shader.texture = t.getTexture();
 		pass.shader.texture = t.getTexture();
 		pass.shader.mask = getMaskTexture(t);
 		pass.shader.mask = getMaskTexture(t);

+ 1 - 1
h2d/filter/Shader.hx

@@ -24,7 +24,7 @@ class Shader< T:h3d.shader.ScreenShader > extends Filter {
 	function get_shader() return pass.shader;
 	function get_shader() return pass.shader;
 
 
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
 	override function draw( ctx : RenderContext, t : h2d.Tile ) {
-		var out = ctx.textures.allocTarget("shaderTmp", Std.int(t.width), Std.int(t.height), false);
+		var out = ctx.textures.allocTarget("shaderTmp", hxd.Math.ceil(t.width), hxd.Math.ceil(t.height), false);
 		ctx.engine.pushTarget(out);
 		ctx.engine.pushTarget(out);
 		Reflect.setField(shader, textureParam + "__", t.getTexture());
 		Reflect.setField(shader, textureParam + "__", t.getTexture());
 		if( nearest ) t.getTexture().filter = Nearest;
 		if( nearest ) t.getTexture().filter = Nearest;

+ 2 - 2
h3d/impl/Benchmark.hx

@@ -154,7 +154,7 @@ class Benchmark extends h2d.Graphics {
 	function syncTip(s:StatsObject) {
 	function syncTip(s:StatsObject) {
 		tip.text = s.name+"( " + Std.int(s.time / 1e6) + "." + StringTools.lpad(""+(Std.int(s.time/1e4)%100),"0",2) + " ms " + s.drawCalls + " draws )";
 		tip.text = s.name+"( " + Std.int(s.time / 1e6) + "." + StringTools.lpad(""+(Std.int(s.time/1e4)%100),"0",2) + " ms " + s.drawCalls + " draws )";
 		var tw = tip.textWidth;
 		var tw = tip.textWidth;
-		var tx = s.xPos + ((s.xSize - tw) >> 1);
+		var tx = s.xPos + ((s.xSize - tw) * .5);
 		if( tx + tw > curWidth ) tx = curWidth - tw;
 		if( tx + tw > curWidth ) tx = curWidth - tw;
 		if( tx < 0 ) tx = 0;
 		if( tx < 0 ) tx = 0;
 		if( hxd.Math.abs(tip.x - tx) > 5 ) tip.x = tx;
 		if( hxd.Math.abs(tip.x - tx) > 5 ) tip.x = tx;
@@ -294,7 +294,7 @@ class Benchmark extends h2d.Graphics {
 				l.visible = true;
 				l.visible = true;
 				l.textColor = textColor;
 				l.textColor = textColor;
 				l.text = s.name;
 				l.text = s.name;
-				l.x = xPos + ((xSize - l.textWidth) >> 1);
+				l.x = xPos + ((xSize - l.textWidth) * .5);
 			}
 			}
 
 
 			s.xPos = xPos;
 			s.xPos = xPos;

+ 2 - 2
samples/Pad.hx

@@ -112,7 +112,7 @@ class PadUI extends h2d.Object {
 
 
 		buttons = new Map();
 		buttons = new Map();
 
 
-		var x = 0;
+		var x = 0.;
 		for( n in ["A","B","X","Y","LB","RB","LT","RT","back","start","dpadUp","dpadDown","dpadLeft","dpadRight"] ){
 		for( n in ["A","B","X","Y","LB","RB","LT","RT","back","start","dpadUp","dpadDown","dpadLeft","dpadRight"] ){
 			var t = new h2d.Text(fnt,this);
 			var t = new h2d.Text(fnt,this);
 			x += 20;
 			x += 20;
@@ -120,7 +120,7 @@ class PadUI extends h2d.Object {
 			t.y = 140;
 			t.y = 140;
 			t.text = n;
 			t.text = n;
 			t.alpha = 0.1;
 			t.alpha = 0.1;
-			var bg = new h2d.Bitmap(h2d.Tile.fromColor(0xFFFFFF, t.textWidth, 8), t);
+			var bg = new h2d.Bitmap(h2d.Tile.fromColor(0xFFFFFF, hxd.Math.ceil(t.textWidth), 8), t);
 			bg.y = 10;
 			bg.y = 10;
 			bg.alpha = 0;
 			bg.alpha = 0;
 			buttons.set(n, { tf : t, bg : bg });
 			buttons.set(n, { tf : t, bg : bg });