| 282 | } |
| 283 | |
| 284 | static void xEntERMove(xEntMotion* motion, xScene* sc, F32 dt, xEntFrame* frame) |
| 285 | { |
| 286 | F32 newt = motion->t - motion->er.p; |
| 287 | |
| 288 | if (newt > 0.0f) |
| 289 | { |
| 290 | motion->t = newt; |
| 291 | } |
| 292 | |
| 293 | if (xEntERIsExtending(motion)) |
| 294 | { |
| 295 | F32 rem = motion->er.et - motion->t; |
| 296 | F32 scale = MIN(rem, dt) / motion->er.et; |
| 297 | |
| 298 | if (rem < dt) |
| 299 | { |
| 300 | xVec3Sub(&frame->dpos, &motion->er.b, &frame->mat.pos); |
| 301 | } |
| 302 | else |
| 303 | { |
| 304 | xVec3Sub(&frame->dpos, &motion->er.b, &motion->er.a); |
| 305 | xVec3SMulBy(&frame->dpos, scale); |
| 306 | } |
| 307 | |
| 308 | frame->mode = 2; |
| 309 | motion->er.state = 0; |
| 310 | } |
| 311 | else if (xEntERIsExtended(motion)) |
| 312 | { |
| 313 | motion->er.state = 1; |
| 314 | } |
| 315 | else if (xEntERIsRetracting(motion)) |
| 316 | { |
| 317 | F32 rem = motion->er.ert - motion->t; |
| 318 | F32 scale = MIN(rem, dt) / motion->er.rt; |
| 319 | |
| 320 | if (rem < dt) |
| 321 | { |
| 322 | xVec3Sub(&frame->dpos, &motion->er.a, &frame->mat.pos); |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | xVec3Sub(&frame->dpos, &motion->er.a, &motion->er.b); |
| 327 | xVec3SMulBy(&frame->dpos, scale); |
| 328 | } |
| 329 | |
| 330 | frame->mode = 2; |
| 331 | motion->er.state = 2; |
| 332 | } |
| 333 | else if (xEntERIsRetracted(motion)) |
| 334 | { |
| 335 | motion->er.state = 3; |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | static void xEntOrbitMove(xEntMotion* motion, xScene* sc, F32 dt, xEntFrame* frame) |
| 340 | { |
no test coverage detected