| 163 | } |
| 164 | |
| 165 | UpdateResult CompAnimUpdate(const ComponentsUpdateParams& params, ComponentsUpdateResult& update_result) |
| 166 | { |
| 167 | DM_PROFILE("Update"); |
| 168 | |
| 169 | /* |
| 170 | * The update is divided into three passes. |
| 171 | * |
| 172 | * The first pass updates the delay and starts animations. Newly started |
| 173 | * animations should automatically cancel others of the same property, |
| 174 | * which is why this is done in a separate pass. Otherwise an ongoing |
| 175 | * animation could have already animated the property and it would then |
| 176 | * have an incorrect value when read by the newly started animation to |
| 177 | * retrieve the from-value. |
| 178 | * |
| 179 | * The second pass advances and evaluates the animations. |
| 180 | * |
| 181 | * The third pass prunes stopped animations and call callbacks. |
| 182 | * |
| 183 | * The reason for this is to give consistent animation evaluation, independent of ordering. |
| 184 | */ |
| 185 | UpdateResult result = UPDATE_RESULT_OK; |
| 186 | AnimWorld* world = (AnimWorld*)params.m_World; |
| 187 | world->m_InUpdate = 1; |
| 188 | uint32_t size = world->m_Animations.Size(); |
| 189 | bool transforms_updated = false; |
| 190 | |
| 191 | DM_PROPERTY_ADD_U32(rmtp_ComponentsAnim, size); |
| 192 | |
| 193 | uint32_t i = 0; |
| 194 | for (i = 0; i < size; ++i) |
| 195 | { |
| 196 | Animation& anim = world->m_Animations[i]; |
| 197 | if (!anim.m_Playing) |
| 198 | continue; |
| 199 | float dt = params.m_UpdateContext->m_DT; |
| 200 | // Check delay |
| 201 | if (anim.m_Delay > dt) |
| 202 | { |
| 203 | continue; |
| 204 | } |
| 205 | if (anim.m_FirstUpdate) |
| 206 | { |
| 207 | anim.m_FirstUpdate = 0; |
| 208 | // Update from-value |
| 209 | if (!anim.m_Composite) |
| 210 | { |
| 211 | if (anim.m_Value != 0x0) |
| 212 | anim.m_From = *anim.m_Value; |
| 213 | else |
| 214 | { |
| 215 | PropertyDesc desc; |
| 216 | PropertyOptions property_opt; |
| 217 | AddPropertyOptionsIndex(&property_opt, 0); |
| 218 | |
| 219 | GetProperty(anim.m_Instance, anim.m_ComponentId, anim.m_PropertyId, property_opt, desc); |
| 220 | anim.m_From = (float)desc.m_Variant.m_Number; |
| 221 | } |
| 222 | } |
nothing calls this directly
no test coverage detected