浏览代码

blendshapes: fix multiple things (allocs, remove non-used data etc)

lviguier 1 年之前
父节点
当前提交
d9ec87537a
共有 5 个文件被更改,包括 14 次插入22 次删除
  1. 14 10
      h3d/prim/Blendshape.hx
  2. 0 9
      hxd/fmt/fbx/HMDOut.hx
  3. 0 1
      hxd/fmt/hmd/Data.hx
  4. 0 1
      hxd/fmt/hmd/Reader.hx
  5. 0 1
      hxd/fmt/hmd/Writer.hx

+ 14 - 10
h3d/prim/Blendshape.hx

@@ -24,20 +24,16 @@ class Blendshape {
 
 		for ( s in 0...shapes.length ) {
 			var s = shapes[s];
-			var size = s.vertexCount * s.vertexFormat.strideBytes;
 
+			var size = s.vertexCount * s.vertexFormat.strideBytes;
 			var vertexBytes = haxe.io.Bytes.alloc(size);
 			hmdModel.lib.resource.entry.readBytes(vertexBytes, 0, hmdModel.dataPosition + s.vertexPosition, size);
-			size = s.vertexCount << (is32 ? 2 : 1);
 
-			var indexBytes = haxe.io.Bytes.alloc(size);
-			hmdModel.lib.resource.entry.readBytes(indexBytes, 0, hmdModel.dataPosition + s.indexPosition, size);
 			size = hmdModel.data.vertexCount << 2;
-
 			var remapBytes = haxe.io.Bytes.alloc(size);
 			hmdModel.lib.resource.entry.readBytes(remapBytes, 0, hmdModel.dataPosition + s.remapPosition, size);
-			shapesBytes.push({ vertexBytes : vertexBytes, indexBytes : indexBytes, remapBytes : remapBytes});
 
+			shapesBytes.push({ vertexBytes : vertexBytes, remapBytes : remapBytes});
 			inputMapping.push(new Map());
 		}
 
@@ -54,6 +50,10 @@ class Blendshape {
 		}
 	}
 
+	public function getBlendshapePrimitive() : HMDModel {
+		return null;
+	}
+
 	public function setBlendshapeAmount(blendshapeIdx: Int, amount: Float) {
 		this.index = blendshapeIdx;
 		this.amount = amount;
@@ -61,17 +61,21 @@ class Blendshape {
 		uploadBlendshapeBytes();
 	}
 
-	public function getBlendshapeCount() {
+	public function cacheBlendshapePrimitive() {
+
+	}
+
+	private function getBlendshapeCount() {
 		if (hmdModel.lib.header.shapes == null)
 			return 0;
 
 		return hmdModel.lib.header.shapes.length;
 	}
 
-	public function uploadBlendshapeBytes() {
+	private function uploadBlendshapeBytes() {
 		var is32 = hmdModel.data.vertexCount > 0x10000;
 		var vertexFormat = hmdModel.data.vertexFormat;
-		hmdModel.buffer = new h3d.Buffer(hmdModel.data.vertexCount, vertexFormat);
+		//hmdModel.buffer = new h3d.Buffer(hmdModel.data.vertexCount, vertexFormat);
 
 		var size = hmdModel.data.vertexCount * vertexFormat.strideBytes;
 		var originalBytes = haxe.io.Bytes.alloc(size);
@@ -142,7 +146,7 @@ class Blendshape {
 			hmdModel.indexCount += n;
 		}
 
-		hmdModel.indexes = new h3d.Indexes(hmdModel.indexCount, is32);
+		//hmdModel.indexes = new h3d.Indexes(hmdModel.indexCount, is32);
 		var size = (is32 ? 4 : 2) * hmdModel.indexCount;
 		var bytes = hmdModel.lib.resource.entry.fetchBytes(hmdModel.dataPosition + hmdModel.data.indexPosition, size);
 		hmdModel.indexes.uploadBytes(bytes, 0, hmdModel.indexCount);

+ 0 - 9
hxd/fmt/fbx/HMDOut.hx

@@ -629,15 +629,6 @@ class HMDOut extends BaseLibrary {
 				}
 			}
 
-			shape.indexPosition = dataOut.length;
-			if( is32 ) {
-				for( index in shapeIndexes[i] )
-					dataOut.writeInt32(index);
-			} else {
-				for( index in shapeIndexes[i] )
-					dataOut.writeUInt16(index);
-			}
-
 			shape.remapPosition = dataOut.length;
 			for ( i in 0...remapped.length ) {
 				for (j in 0...remapped[i].length) {

+ 0 - 1
hxd/fmt/hmd/Data.hx

@@ -85,7 +85,6 @@ class BlendShape {
 	public var vertexFormat : hxd.BufferFormat;
 	public var vertexPosition : DataPosition;
 	public var indexCount : DataPosition;
-	public var indexPosition : DataPosition;
 	public var remapPosition : DataPosition;
 	public function new() {
 	}

+ 0 - 1
hxd/fmt/hmd/Reader.hx

@@ -245,7 +245,6 @@ class Reader {
 				s.vertexFormat = makeFormat();
 				s.vertexPosition = i.readInt32();
 				s.indexCount = i.readInt32();
-				s.indexPosition = i.readInt32();
 				s.remapPosition = i.readInt32();
 				d.shapes.push(s);
 			}

+ 0 - 1
hxd/fmt/hmd/Writer.hx

@@ -207,7 +207,6 @@ class Writer {
 			writeFormat(s.vertexFormat);
 			out.writeInt32(s.vertexPosition);
 			out.writeInt32(s.indexCount);
-			out.writeInt32(s.indexPosition);
 			out.writeInt32(s.remapPosition);
 		}