浏览代码

BlendShapes: add optional parameter on uploadBlendshapeBytes

lviguier 1 月之前
父节点
当前提交
daa71ada51
共有 1 个文件被更改,包括 14 次插入7 次删除
  1. 14 7
      h3d/prim/Blendshape.hx

+ 14 - 7
h3d/prim/Blendshape.hx

@@ -59,19 +59,26 @@ class Blendshape {
 		}
 		}
 	}
 	}
 
 
-	public function setBlendshapeAmountByIndex(blendshapeIdx: Int, amount: Float) {
+	public function setBlendshapeAmountByIndex(blendshapeIdx: Int, amount: Float, uploadBytes : Bool = true) {
 		if (blendshapeIdx >= this.weights.length)
 		if (blendshapeIdx >= this.weights.length)
 			throw 'Blendshape at index ${blendshapeIdx} doesn\'t exist (there is only ${this.weights.length} blendshapes).';
 			throw 'Blendshape at index ${blendshapeIdx} doesn\'t exist (there is only ${this.weights.length} blendshapes).';
 
 
 		this.weights[blendshapeIdx] = amount;
 		this.weights[blendshapeIdx] = amount;
-		uploadBlendshapeBytes();
+
+		if (uploadBytes)
+			uploadBlendshapeBytes();
 	}
 	}
 
 
-	public function setBlendShapeAmountByName(name: String, amount: Float) {
-		for (s in shapes)
-			if (s.name == name)
+	public function setBlendShapeAmountByName(name: String, amount: Float, uploadBytes : Bool = true) {
+		for (s in shapes) {
+			if (s.name == name) {
 				this.weights[shapes.indexOf(s)] = amount;
 				this.weights[shapes.indexOf(s)] = amount;
-		uploadBlendshapeBytes();
+				break;
+			}
+		}
+
+		if (uploadBytes)
+			uploadBlendshapeBytes();
 	}
 	}
 
 
 	function getBlendshapeCount() {
 	function getBlendshapeCount() {
@@ -81,7 +88,7 @@ class Blendshape {
 		return shapes.length;
 		return shapes.length;
 	}
 	}
 
 
-	function uploadBlendshapeBytes() {
+	public function uploadBlendshapeBytes() {
 		if (hmdModel.buffer == null || hmdModel.buffer.isDisposed())
 		if (hmdModel.buffer == null || hmdModel.buffer.isDisposed())
 			hmdModel.alloc(Engine.getCurrent());
 			hmdModel.alloc(Engine.getCurrent());