diff options
| author | Pedro J. Estébanez | 2016-06-27 10:32:14 +0200 |
|---|---|---|
| committer | Pedro J. Estébanez | 2016-06-27 10:40:33 +0200 |
| commit | 6ce47d9b51f6f540a8d3b6aece32ec0efdf2a37f (patch) | |
| tree | 24b5d0bd777713a5350622242441c56337e1a4ca /scene/2d/parallax_layer.cpp | |
| parent | 2c59f778850dc4450481680e859efd66660c9119 (diff) | |
| download | godot-6ce47d9b51f6f540a8d3b6aece32ec0efdf2a37f.tar.gz godot-6ce47d9b51f6f540a8d3b6aece32ec0efdf2a37f.tar.zst godot-6ce47d9b51f6f540a8d3b6aece32ec0efdf2a37f.zip | |
Diffstat (limited to 'scene/2d/parallax_layer.cpp')
| -rw-r--r-- | scene/2d/parallax_layer.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index e9378b1d0..05136de5d 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -123,26 +123,15 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2& p_offset,float p_sca Point2 new_ofs = ((orig_offset+p_offset)*motion_scale)*p_scale+motion_offset; if (mirroring.x) { - - while( new_ofs.x>=0) { - new_ofs.x -= mirroring.x*p_scale; - } - while(new_ofs.x < -mirroring.x*p_scale) { - new_ofs.x += mirroring.x*p_scale; - } + double den = mirroring.x*p_scale; + new_ofs.x -= den*ceil(new_ofs.x/den); } if (mirroring.y) { - - while( new_ofs.y>=0) { - new_ofs.y -= mirroring.y*p_scale; - } - while(new_ofs.y < -mirroring.y*p_scale) { - new_ofs.y += mirroring.y*p_scale; - } + double den = mirroring.y*p_scale; + new_ofs.y -= den*ceil(new_ofs.y/den); } - set_pos(new_ofs); set_scale(Vector2(1,1)*p_scale); |
