aboutsummaryrefslogtreecommitdiff
path: root/scene/2d/parallax_layer.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez2016-06-24 18:39:56 +0200
committerPedro J. Estébanez2016-06-24 18:39:56 +0200
commitfbddc0b7471e7cf62b934e5c9bbb4c05c1313e74 (patch)
tree90ff832b670489ad7f779da2e589eb520cce7e82 /scene/2d/parallax_layer.cpp
parent9e0b6057e74181635bf3732879313d3d82bcfd93 (diff)
downloadgodot-fbddc0b7471e7cf62b934e5c9bbb4c05c1313e74.tar.gz
godot-fbddc0b7471e7cf62b934e5c9bbb4c05c1313e74.tar.zst
godot-fbddc0b7471e7cf62b934e5c9bbb4c05c1313e74.zip
Diffstat (limited to 'scene/2d/parallax_layer.cpp')
-rw-r--r--scene/2d/parallax_layer.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index bf559deb0..a67ea0495 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -92,23 +92,13 @@ 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;
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 = fmod(new_ofs.x,den) - (mirroring.x > 0 ? den : 0);
}
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 = fmod(new_ofs.y,den) - (mirroring.y > 0 ? den : 0);
}