From 73d7e5e1c28b0c863aeb47ce63ce6eff07cb6c85 Mon Sep 17 00:00:00 2001
From: Delta Echo <echoair@t-online.de>
Date: Sat, 29 Feb 2020 11:39:26 +0100
Subject: [PATCH] Fix bug about body width

---
 Shaders/model-ALS-wingflex.vert | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/Shaders/model-ALS-wingflex.vert b/Shaders/model-ALS-wingflex.vert
index a8d06d94c..b23502f12 100644
--- a/Shaders/model-ALS-wingflex.vert
+++ b/Shaders/model-ALS-wingflex.vert
@@ -64,13 +64,14 @@ void	rotationMatrixH(in float sinRz, in float cosRz, out mat4 rotmat)
 
 vec2 calc_deflection(float y){
 	float distance;
-	if(y < body_width && y > -body_width){
+	float bwh = body_width/2;
+	if(y < bwh && y > -bwh){
 		//this part does not move
 		distance = 0;
-	}else if(y > body_width){
-		distance = y - (body_width/2);
-	}else if(y < -body_width){
-		distance = y - ((-1*body_width)/2);
+	}else if(y > bwh){
+		distance = y - bwh;
+	}else if(y < -bwh){
+		distance = y + bwh;
 	}
 	float max_dist = (wing_span-body_width)/2;
 	float deflection = wingflex_z * (distance*distance)/(max_dist*max_dist);