浏览代码

use Std.instance instead of Std.is

ncannasse 11 年之前
父节点
当前提交
eb8139cb7c
共有 3 个文件被更改,包括 13 次插入9 次删除
  1. 5 3
      h2d/Drawable.hx
  2. 3 2
      h3d/mat/Pass.hx
  3. 5 4
      h3d/scene/Object.hx

+ 5 - 3
h2d/Drawable.hx

@@ -94,9 +94,11 @@ class Drawable extends Sprite {
 	}
 	}
 
 
 	public function getShader< T:hxsl.Shader >( stype : Class<T> ) : T {
 	public function getShader< T:hxsl.Shader >( stype : Class<T> ) : T {
-		if (shaders != null) for( s in shaders )
-			if( Std.is(s, stype) )
-				return cast s;
+		if (shaders != null) for( s in shaders ) {
+			var s = Std.instance(s, stype);
+			if( s != null )
+				return s;
+		}
 		return null;
 		return null;
 	}
 	}
 
 

+ 3 - 2
h3d/mat/Pass.hx

@@ -124,8 +124,9 @@ class Pass {
 	public function getShader< T:hxsl.Shader >(t:Class<T>) : T {
 	public function getShader< T:hxsl.Shader >(t:Class<T>) : T {
 		var s = shaders;
 		var s = shaders;
 		while( s != null ) {
 		while( s != null ) {
-			if( Std.is(s.s, t) )
-				return cast s.s;
+			var sh = Std.instance(s.s, t);
+			if( sh != null )
+				return sh;
 			s = s.next;
 			s = s.next;
 		}
 		}
 		return null;
 		return null;

+ 5 - 4
h3d/scene/Object.hx

@@ -198,13 +198,14 @@ class Object {
 	}
 	}
 
 
 	public inline function isMesh() {
 	public inline function isMesh() {
-		return Std.is(this, Mesh);
+		return Std.instance(this, Mesh) != null;
 	}
 	}
 
 
 	public function toMesh() : Mesh {
 	public function toMesh() : Mesh {
-		if( isMesh() )
-			return cast this;
-		throw (name == null ? "Object" : name) + " is not a Mesh";
+		var m = Std.instance(this, Mesh);
+		if( m != null )
+			return m;
+		throw this + " is not a Mesh";
 	}
 	}
 
 
 	// shortcut for parent.removeChild
 	// shortcut for parent.removeChild