Browse Source

BlendShapes: add optional parameter on uploadBlendshapeBytes

lviguier 1 month ago
parent
commit
daa71ada51
1 changed files with 14 additions and 7 deletions
  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)
 			throw 'Blendshape at index ${blendshapeIdx} doesn\'t exist (there is only ${this.weights.length} blendshapes).';
 
 		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;
-		uploadBlendshapeBytes();
+				break;
+			}
+		}
+
+		if (uploadBytes)
+			uploadBlendshapeBytes();
 	}
 
 	function getBlendshapeCount() {
@@ -81,7 +88,7 @@ class Blendshape {
 		return shapes.length;
 	}
 
-	function uploadBlendshapeBytes() {
+	public function uploadBlendshapeBytes() {
 		if (hmdModel.buffer == null || hmdModel.buffer.isDisposed())
 			hmdModel.alloc(Engine.getCurrent());