瀏覽代碼

Export-fbx: use StringBuffer instead of basic concatenation allow better performance on hl

lviguier 1 年之前
父節點
當前提交
cf76ae55cd
共有 1 個文件被更改,包括 19 次插入15 次删除
  1. 19 15
      hxd/fmt/fbx/Writer.hx

+ 19 - 15
hxd/fmt/fbx/Writer.hx

@@ -4,10 +4,10 @@ import hxd.fmt.fbx.Data;
 import hxd.fmt.hmd.Data;
 
 typedef ExportParams = {
-	forward: Int,
-	forwardSign: Int,
-	up: Int,
-	upSign: Int,
+	forward: String,
+	forwardSign: String,
+	up: String,
+	upSign: String,
 }
 
 
@@ -89,28 +89,30 @@ class Writer {
 
 			case PInts(v):
 				{
-					var res = '*${v.length} {\n';
-					res += '${getTabFormat(depth + 1)}a: ';
+					var strBuf : StringBuf = new StringBuf();
+					strBuf.add('*${v.length} {\n');
+					strBuf.add('${getTabFormat(depth + 1)}a: ');
 
 					for (idx => i in v) {
-						res += '${idx != 0 ? ',' : ''}${i}';
+						strBuf.add('${idx != 0 ? ',' : ''}${i}');
 					}
 
-					res += '\n${getTabFormat(depth)}}';
-					return res;
+					strBuf.add('\n${getTabFormat(depth)}}');
+					return strBuf.toString();
 				}
 
 			case PFloats(v):
 				{
-					var res = '*${v.length} {\n';
-					res += '${getTabFormat(depth + 1)}a: ';
+					var strBuf : StringBuf = new StringBuf();
+					strBuf.add('*${v.length} {\n');
+					strBuf.add('${getTabFormat(depth + 1)}a: ');
 
 					for (idx => i in v) {
-						res += '${idx != 0 ? ',' : ''}${i}';
+						strBuf.add('${idx != 0 ? ',' : ''}${i}');
 					}
 
-					res += '\n${getTabFormat(depth)}}';
-					return res;
+					strBuf.add('\n${getTabFormat(depth)}}');
+					return strBuf.toString();
 				}
 
 			default:
@@ -808,7 +810,9 @@ class Writer {
 				o = new h3d.scene.MultiMaterial(multiMat.primitive, multiMat.materials);
 			else {
 				var m = Std.downcast(obj, h3d.scene.Mesh);
-				if (m != null)
+				var hmd = Std.downcast(m?.primitive, h3d.prim.HMDModel);
+
+				if (hmd != null)
 					o = new h3d.scene.Mesh(m.primitive, m.material);
 			}