Merge pull request #5447 from RandomShaper/parallax-layer-fix-tidy
Improve parallax mirroring algorithm
This commit is contained in:
commit
ba625a14c6
1 changed files with 4 additions and 15 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue