| 422 | } |
| 423 | |
| 424 | static void UpdateLightning(zLightning* l, F32 dt) |
| 425 | { |
| 426 | if (!(l->flags & 0x10)) |
| 427 | { |
| 428 | l->time_left -= dt; |
| 429 | } |
| 430 | |
| 431 | if (l->time_left <= 0.0f) |
| 432 | { |
| 433 | if (l->flags & 0x100) |
| 434 | { |
| 435 | l->time_left = 0.0f; |
| 436 | l->flags &= ~0x40; |
| 437 | } |
| 438 | else |
| 439 | { |
| 440 | l->flags &= ~0x1; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | if (l->type != LYT_TYPE_FUNC) |
| 445 | { |
| 446 | |
| 447 | |
| 448 | if (l->type == LYT_TYPE_LINE || l->type == LYT_TYPE_ZEUS) |
| 449 | { |
| 450 | S32 i; |
| 451 | F32 full = l->legacy.rand_radius * dt; |
| 452 | F32 half = 0.5f * full; |
| 453 | |
| 454 | for (i = 1; i < l->legacy.total_points - 1; i++) |
| 455 | { |
| 456 | l->legacy.point[i].x = (full * xurand() + -half) + l->legacy.base_point[i].x; |
| 457 | l->legacy.point[i].y = (full * xurand() + -half) + l->legacy.base_point[i].y; |
| 458 | l->legacy.point[i].z = (full * xurand() + -half) + l->legacy.base_point[i].z; |
| 459 | |
| 460 | if (l->flags & 0x20) |
| 461 | { |
| 462 | // TODO: Fix float op order and grouping |
| 463 | F32 sc1 = ((F32)i / (F32)l->legacy.total_points); |
| 464 | sc1 = (4.0f * sc1 + -4.0f * sc1 * sc1) * l->legacy.arc_height; |
| 465 | |
| 466 | xVec3AddScaled(&l->legacy.point[i], &l->legacy.arc_normal, sc1); |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | else if (l->type == LYT_TYPE_ROTATING) |
| 471 | { |
| 472 | xVec3 dir; |
| 473 | xVec3Sub(&dir, &l->legacy.base_point[l->legacy.total_points - 1], &l->legacy.base_point[0]); |
| 474 | xVec3Normalize(&dir, &dir); |
| 475 | |
| 476 | F32 full = l->legacy.rand_radius * dt; |
| 477 | F32 half = 0.5f * full; |
| 478 | |
| 479 | for (S32 i = 1; i < l->legacy.total_points - 1; i++) |
| 480 | { |
| 481 | xMat3x3 mat3; |
no test coverage detected