Merge pull request #5430 from godotengine/revert-5391-parallax-layer-fix-tidy

Revert "Improve parallax mirroring algorithm"
This commit is contained in:
Rémi Verschelde 2016-06-26 18:03:33 +02:00 committed by GitHub
commit 5dbb587c0f
1 changed files with 14 additions and 4 deletions

View File

@ -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;
}
}