summaryrefslogtreecommitdiff
path: root/scene/2d/parallax_layer.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2016-06-26 18:03:15 +0200
committerGitHub <noreply@github.com>2016-06-26 18:03:15 +0200
commit0be12898a7ed2d4130b1bda2dc2677ff17018925 (patch)
tree70edc358dcfd1b72a07f967239fc85d2d644b03a /scene/2d/parallax_layer.cpp
parent130b83bc527b90448a36f8d6357183d29c837cd5 (diff)
Revert "Improve parallax mirroring algorithm"
Diffstat (limited to 'scene/2d/parallax_layer.cpp')
-rw-r--r--scene/2d/parallax_layer.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index a67ea04959..bf559deb09 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -92,13 +92,23 @@ 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) {
- double den = mirroring.x*p_scale;
- new_ofs.x = fmod(new_ofs.x,den) - (mirroring.x > 0 ? den : 0);
+
+ 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;
+ }
}
if (mirroring.y) {
- double den = mirroring.y*p_scale;
- new_ofs.y = fmod(new_ofs.y,den) - (mirroring.y > 0 ? den : 0);
+
+ 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;
+ }
}