| 139 | } |
| 140 | |
| 141 | void EntityTweener::Tween(float alpha) |
| 142 | { |
| 143 | const float inv = (1.0f - alpha); |
| 144 | for (size_t i = 0; i < Entities.size(); ++i) |
| 145 | { |
| 146 | auto* ent = Entities[i]; |
| 147 | if (ent == nullptr) |
| 148 | continue; |
| 149 | |
| 150 | auto& posA = PrePos[i]; |
| 151 | auto& posB = PostPos[i]; |
| 152 | |
| 153 | if (posA == posB) |
| 154 | continue; |
| 155 | |
| 156 | ent->moveTo( |
| 157 | { static_cast<int32_t>(std::round(posB.x * alpha + posA.x * inv)), |
| 158 | static_cast<int32_t>(std::round(posB.y * alpha + posA.y * inv)), |
| 159 | static_cast<int32_t>(std::round(posB.z * alpha + posA.z * inv)) }); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | void EntityTweener::Restore() |
| 164 | { |
no test coverage detected