Bladeren bron

remove all offsets (the old scene offset was causing most of the glitches)

ncannasse 11 jaren geleden
bovenliggende
commit
81450c8bff
3 gewijzigde bestanden met toevoegingen van 12 en 32 verwijderingen
  1. 0 9
      h2d/Scene.hx
  2. 10 20
      h2d/Tile.hx
  3. 2 3
      h2d/TileGroup.hx

+ 0 - 9
h2d/Scene.hx

@@ -393,15 +393,6 @@ class Scene extends Layers implements h3d.IDrawable {
 		absX = absX * w - 1;
 		absY = absY * h + 1;
 
-		// half pixel align !
-		var engine = h3d.Engine.getCurrent();
-		absX += 1 / engine.width;
-		#if flash
-		absY -= 1 / engine.height;
-		#else
-		absY += 1 / engine.height;
-		#end
-
 		matA *= w;
 		matB *= h;
 		matC *= w;

+ 10 - 20
h2d/Tile.hx

@@ -3,16 +3,6 @@ package h2d;
 @:allow(h2d)
 class Tile {
 
-	#if flash
-	static inline var EPSILON_POS = 0.;
-	static inline var EPSILON_SIZE_U = 0.;
-	static inline var EPSILON_SIZE_V = 0.;
-	#else
-	static inline var EPSILON_POS = 0;
-	static inline var EPSILON_SIZE_U = 0;
-	static inline var EPSILON_SIZE_V = 0.0001;
-	#end
-
 	var innerTex : h3d.mat.Texture;
 
 	var u : Float;
@@ -49,10 +39,10 @@ class Tile {
 	function setTexture(tex) {
 		this.innerTex = tex;
 		if( tex != null ) {
-			this.u = (x + EPSILON_POS) / tex.width;
-			this.v = (y + EPSILON_POS) / tex.height;
-			this.u2 = (x + width - EPSILON_SIZE_U) / tex.width;
-			this.v2 = (y + height - EPSILON_SIZE_V) / tex.height;
+			this.u = x / tex.width;
+			this.v = y / tex.height;
+			this.u2 = (x + width) / tex.width;
+			this.v2 = (y + height) / tex.height;
 		}
 	}
 
@@ -83,10 +73,10 @@ class Tile {
 		this.y = y;
 		var tex = innerTex;
 		if( tex != null ) {
-			u = (x + EPSILON_POS) / tex.width;
-			v = (y + EPSILON_POS) / tex.height;
-			u2 = (width + x - EPSILON_SIZE_U) / tex.width;
-			v2 = (height + y - EPSILON_SIZE_V) / tex.height;
+			u = x / tex.width;
+			v = y / tex.height;
+			u2 = (x + width) / tex.width;
+			v2 = (y + height) / tex.height;
 		}
 	}
 
@@ -95,8 +85,8 @@ class Tile {
 		this.height = h;
 		var tex = innerTex;
 		if( tex != null ) {
-			u2 = (w + x - EPSILON_SIZE_U) / tex.width;
-			v2 = (h + y - EPSILON_SIZE_V) / tex.height;
+			u2 = (x + w) / tex.width;
+			v2 = (y + h) / tex.height;
 		}
 	}
 

+ 2 - 3
h2d/TileGroup.hx

@@ -35,9 +35,8 @@ private class TileLayerContent extends h3d.prim.Primitive {
 	}
 
 	public function add( x : Int, y : Int, r : Float, g : Float, b : Float, a : Float, t : Tile ) {
-		// +0.001 required for directx9 (only ?)
-		var sx = x + t.dx + 0.001;
-		var sy = y + t.dy + 0.001;
+		var sx = x + t.dx;
+		var sy = y + t.dy;
 		tmp.push(sx);
 		tmp.push(sy);
 		tmp.push(t.u);