Преглед на файлове

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 {
-		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;
 	}
 

+ 3 - 2
h3d/mat/Pass.hx

@@ -124,8 +124,9 @@ class Pass {
 	public function getShader< T:hxsl.Shader >(t:Class<T>) : T {
 		var s = shaders;
 		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;
 		}
 		return null;

+ 5 - 4
h3d/scene/Object.hx

@@ -198,13 +198,14 @@ class Object {
 	}
 
 	public inline function isMesh() {
-		return Std.is(this, Mesh);
+		return Std.instance(this, Mesh) != null;
 	}
 
 	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