MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / tween

Method tween

src/OpenLoco/src/Entities/EntityTweener.cpp:77–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 }
76
77 void EntityTweener::tween(float alpha)
78 {
79 const float inv = (1.0f - alpha);
80
81 for (size_t i = 0; i < _entities.size(); ++i)
82 {
83 auto* ent = _entities[i];
84 if (ent == nullptr)
85 {
86 continue;
87 }
88
89 auto& posA = _prePos[i];
90 auto& posB = _postPos[i];
91
92 if (posA == posB)
93 {
94 continue;
95 }
96
97 auto newPos = World::Pos3{ static_cast<int16_t>(std::round(posB.x * alpha + posA.x * inv)),
98 static_cast<int16_t>(std::round(posB.y * alpha + posA.y * inv)),
99 static_cast<int16_t>(std::round(posB.z * alpha + posA.z * inv)) };
100
101 if (ent->position == newPos)
102 {
103 continue;
104 }
105
106 ent->moveTo(newPos);
107 }
108 }
109
110 void EntityTweener::restore()
111 {

Callers 1

variableUpdateFunction · 0.80

Calls 2

moveToMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected