@@ -71,10 +71,11 @@ void Waves3D::update(float time)
7171 {
7272 for (j = 0 ; j < _gridSize.height + 1 ; ++j)
7373 {
74- Vec3 v = getOriginalVertex (Vec2 (i ,j));
74+ Vec2 pos ((float )i, (float )j);
75+ Vec3 v = getOriginalVertex (pos);
7576 v.z += (sinf ((float )M_PI * time * _waves * 2 + (v.y +v.x ) * 0 .01f ) * _amplitude * _amplitudeRate);
7677 // CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
77- setVertex (Vec2 (i, j) , v);
78+ setVertex (pos , v);
7879 }
7980 }
8081}
@@ -347,7 +348,8 @@ void Lens3D::update(float /*time*/)
347348 {
348349 for (j = 0 ; j < _gridSize.height + 1 ; ++j)
349350 {
350- Vec3 v = getOriginalVertex (Vec2 (i, j));
351+ Vec2 pos ((float )i, (float )j);
352+ Vec3 v = getOriginalVertex (pos);
351353 Vec2 vect = _position - Vec2 (v.x , v.y );
352354 float r = vect.getLength ();
353355
@@ -371,7 +373,7 @@ void Lens3D::update(float /*time*/)
371373 }
372374 }
373375
374- setVertex (Vec2 (i, j) , v);
376+ setVertex (pos , v);
375377 }
376378 }
377379
@@ -439,7 +441,8 @@ void Ripple3D::update(float time)
439441 {
440442 for (j = 0 ; j < (_gridSize.height +1 ); ++j)
441443 {
442- Vec3 v = getOriginalVertex (Vec2 (i, j));
444+ Vec2 pos ((float )i, (float )j);
445+ Vec3 v = getOriginalVertex (pos);
443446 Vec2 vect = _position - Vec2 (v.x ,v.y );
444447 float r = vect.getLength ();
445448
@@ -450,7 +453,7 @@ void Ripple3D::update(float time)
450453 v.z += (sinf ( time*(float )M_PI * _waves * 2 + r * 0 .1f ) * _amplitude * _amplitudeRate * rate);
451454 }
452455
453- setVertex (Vec2 (i, j) , v);
456+ setVertex (pos , v);
454457 }
455458 }
456459}
@@ -506,15 +509,16 @@ void Shaky3D::update(float /*time*/)
506509 {
507510 for (j = 0 ; j < (_gridSize.height +1 ); ++j)
508511 {
509- Vec3 v = getOriginalVertex (Vec2 (i ,j));
512+ Vec2 pos ((float )i, (float )j);
513+ Vec3 v = getOriginalVertex (pos);
510514 v.x += (rand () % (_randrange*2 )) - _randrange;
511515 v.y += (rand () % (_randrange*2 )) - _randrange;
512516 if (_shakeZ)
513517 {
514518 v.z += (rand () % (_randrange*2 )) - _randrange;
515519 }
516520
517- setVertex (Vec2 (i, j) , v);
521+ setVertex (pos , v);
518522 }
519523 }
520524}
@@ -571,10 +575,11 @@ void Liquid::update(float time)
571575 {
572576 for (j = 1 ; j < _gridSize.height ; ++j)
573577 {
574- Vec3 v = getOriginalVertex (Vec2 (i, j));
578+ Vec2 pos ((float )i, (float )j);
579+ Vec3 v = getOriginalVertex (pos);
575580 v.x = (v.x + (sinf (time * (float )M_PI * _waves * 2 + v.x * .01f ) * _amplitude * _amplitudeRate));
576581 v.y = (v.y + (sinf (time * (float )M_PI * _waves * 2 + v.y * .01f ) * _amplitude * _amplitudeRate));
577- setVertex (Vec2 (i, j) , v);
582+ setVertex (pos , v);
578583 }
579584 }
580585}
@@ -633,7 +638,8 @@ void Waves::update(float time)
633638 {
634639 for (j = 0 ; j < _gridSize.height + 1 ; ++j)
635640 {
636- Vec3 v = getOriginalVertex (Vec2 (i, j));
641+ Vec2 pos ((float )i, (float )j);
642+ Vec3 v = getOriginalVertex (pos);
637643
638644 if (_vertical)
639645 {
@@ -645,7 +651,7 @@ void Waves::update(float time)
645651 v.y = (v.y + (sinf (time * (float )M_PI * _waves * 2 + v.x * .01f ) * _amplitude * _amplitudeRate));
646652 }
647653
648- setVertex (Vec2 (i, j) , v);
654+ setVertex (pos , v);
649655 }
650656 }
651657}
@@ -709,7 +715,8 @@ void Twirl::update(float time)
709715 {
710716 for (j = 0 ; j < (_gridSize.height +1 ); ++j)
711717 {
712- Vec3 v = getOriginalVertex (Vec2 (i ,j));
718+ Vec2 pos ((float )i, (float )j);
719+ Vec3 v = getOriginalVertex (pos);
713720
714721 Vec2 avg (i-(_gridSize.width /2 .0f ), j-(_gridSize.height /2 .0f ));
715722 float r = avg.getLength ();
@@ -724,7 +731,7 @@ void Twirl::update(float time)
724731 v.x = c.x + d.x ;
725732 v.y = c.y + d.y ;
726733
727- setVertex (Vec2 (i ,j) , v);
734+ setVertex (pos , v);
728735 }
729736 }
730737}
0 commit comments