瀏覽代碼

Merge master

ncannasse 11 年之前
父節點
當前提交
4997dad9ba
共有 3 個文件被更改,包括 29 次插入4 次删除
  1. 1 1
      h2d/Console.hx
  2. 3 1
      h3d/fbx/Library.hx
  3. 25 2
      hxd/res/Image.hx

+ 1 - 1
h2d/Console.hx

@@ -93,7 +93,7 @@ class Console extends h2d.Sprite {
 	function showHelp( ?command : String ) {
 		var all;
 		if( command == null ) {
-			all = Lambda.array( { iterator : commands.keys } );
+			all = Lambda.array( { iterator : function() return commands.keys() } );
 			all.sort(Reflect.compare);
 			all.remove("help");
 			all.push("help");

+ 3 - 1
h3d/fbx/Library.hx

@@ -101,6 +101,8 @@ class Library {
 	**/
 	public var unskinnedJointsAsObjects : Bool;
 
+	public var allowVertexColor : Bool = true;
+
 	public function new() {
 		root = { name : "Root", props : [], childs : [] };
 		keepJoints = new Map();
@@ -872,7 +874,7 @@ class Library {
 						continue;
 					}
 					var mat = textureLoader(tex.get("FileName").props[0].toString(),mat);
-					if( vcolor )
+					if( vcolor && allowVertexColor )
 						mat.hasVertexColor = true;
 					tmats.push(mat);
 					lastAdded = tmats.length;

+ 25 - 2
hxd/res/Image.hx

@@ -2,6 +2,12 @@ package hxd.res;
 
 class Image extends Resource {
 	
+	/**
+		Specify if we will automatically convert non-power-of-two textures to power-of-two.
+	**/
+	public static var ALLOW_NPOT = #if flash11_8 true #else false #end;
+	public static var DEFAULT_FILTER : h3d.mat.Data.Filter = Linear;
+	
 	var tex : h3d.mat.Texture;
 	var inf : { width : Int, height : Int, isPNG : Bool };
 	
@@ -89,6 +95,8 @@ class Image extends Resource {
 				// immediately loading the PNG is faster than going through loadBitmap
 				tex.alloc();
 				var pixels = getPixels();
+				if( pixels.width != tex.width || pixels.height != tex.height )
+					pixels.makeSquare();
 				tex.uploadPixels(pixels);
 				pixels.dispose();
 				tex.realloc = loadTexture;
@@ -101,7 +109,13 @@ class Image extends Resource {
 			// use native decoding
 			entry.loadBitmap(function(bmp) {
 				tex.alloc();
-				tex.uploadBitmap(bmp);
+				if( bmp.width != tex.width || bmp.height != tex.height ) {
+					var pixels = bmp.getPixels();
+					pixels.makeSquare();
+					tex.uploadPixels(pixels);
+					pixels.dispose();
+				} else
+					tex.uploadBitmap(bmp);
 				bmp.dispose();
 				tex.realloc = loadTexture;
 			});
@@ -112,7 +126,16 @@ class Image extends Resource {
 		if( tex != null )
 			return tex;
 		getSize();
-		tex = new h3d.mat.Texture(inf.width, inf.height, [NoAlloc]);
+		var width = inf.width, height = inf.height;
+		if( !ALLOW_NPOT ) {
+			var tw = 1, th = 1;
+			while( tw < width ) tw <<= 1;
+			while( th < height ) th <<= 1;
+			width = tw;
+			height = th;
+		}
+		tex = new h3d.mat.Texture(width, height, [NoAlloc]);
+		tex.filter = DEFAULT_FILTER;
 		tex.setName(entry.path);
 		loadTexture();
 		return tex;