Browse Source

fix webgl_gpgpu_birds_gltf cohesion 0 error

gonnavis 4 năm trước cách đây
mục cha
commit
334f2cf76e
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      examples/webgl_gpgpu_birds_gltf.html

+ 3 - 2
examples/webgl_gpgpu_birds_gltf.html

@@ -179,8 +179,9 @@
 
 							// Attraction / Cohesion - move closer
 							float threshDelta = 1.0 - alignmentThresh;
-							threshDelta = max( threshDelta, 1e-6 );
-							float adjustedPercent = ( percent - alignmentThresh ) / threshDelta;
+							float adjustedPercent;
+							if( threshDelta == 0. ) adjustedPercent = 1.;
+							else adjustedPercent = ( percent - alignmentThresh ) / threshDelta;
 
 							f = ( 0.5 - ( cos( adjustedPercent * PI_2 ) * -0.5 + 0.5 ) ) * delta;