Skip to content

Commit

Permalink
Merge pull request #77141 from TokageItLab/optimize-tween-division
Browse files Browse the repository at this point in the history
Optimize Tween calculations by caching some divisions
  • Loading branch information
akien-mga committed May 17, 2023
2 parents b42cea1 + e09c3d8 commit 437041a
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions scene/animation/easing_equations.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace sine

Expand All @@ -104,7 +105,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace quint

Expand All @@ -130,7 +132,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace quart

Expand All @@ -157,7 +160,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace quad

Expand Down Expand Up @@ -197,7 +201,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace expo

Expand Down Expand Up @@ -264,7 +269,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace elastic

Expand Down Expand Up @@ -293,7 +299,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace cubic

Expand Down Expand Up @@ -322,7 +329,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace circ

Expand Down Expand Up @@ -356,14 +364,16 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return in(t * 2, b, c / 2, d);
}
return out(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return out(t * 2 - d, b + h, h, d);
}

static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace bounce

Expand Down Expand Up @@ -398,7 +408,8 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
if (t < d / 2) {
return out(t * 2, b, c / 2, d);
}
return in(t * 2 - d, b + c / 2, c / 2, d);
real_t h = c / 2;
return in(t * 2 - d, b + h, h, d);
}
}; // namespace back

Expand Down

0 comments on commit 437041a

Please sign in to comment.