|
6 | 6 | #include <types.h> |
7 | 7 | #include <rwcore.h> |
8 | 8 |
|
| 9 | +#define NUM_LIGHTNING 48 |
| 10 | + |
9 | 11 | _tagLightningAdd gLightningTweakAddInfo; |
10 | 12 |
|
11 | | -static zLightning* sLightning[48]; |
| 13 | +static zLightning* sLightning[NUM_LIGHTNING]; |
12 | 14 | static xFuncPiece sLFuncX[10]; |
13 | 15 | static xFuncPiece sLFuncY[10]; |
14 | 16 | static xFuncPiece sLFuncZ[10]; |
@@ -79,6 +81,67 @@ static void lightningTweakStart(const tweak_info& t) |
79 | 81 | zLightningAdd(&gLightningTweakAddInfo); |
80 | 82 | } |
81 | 83 |
|
| 84 | +void zLightningUpdate(F32 dt) |
| 85 | +{ |
| 86 | + S32 i; |
| 87 | + for (i = 0; i < NUM_LIGHTNING; i++) |
| 88 | + { |
| 89 | + if (sLightning[i] != NULL && sLightning[i]->flags & 0x1) |
| 90 | + { |
| 91 | + UpdateLightning(sLightning[i], dt); |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + sLFuncUVOffset = 1.0f * dt + sLFuncUVOffset; |
| 96 | + if (sLFuncUVOffset > 1.0f) |
| 97 | + { |
| 98 | + sLFuncUVOffset -= 1.0f; |
| 99 | + } |
| 100 | + |
| 101 | + sLFuncJerkTime += 20.0f * dt; |
| 102 | + if (!(sLFuncJerkTime > 1.0f)) |
| 103 | + { |
| 104 | + return; |
| 105 | + } |
| 106 | + |
| 107 | + S32 picker = 9.0f * xurand(); |
| 108 | + if (picker >= 9) |
| 109 | + { |
| 110 | + picker = 8; |
| 111 | + } |
| 112 | + if (picker < 0) |
| 113 | + { |
| 114 | + picker = 0; |
| 115 | + } |
| 116 | + |
| 117 | + xVec3Init(&sLFuncVal[picker], 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f)); |
| 118 | + xVec3Init(&sLFuncSlope[picker][0], 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f)); |
| 119 | + xVec3Init(&sLFuncSlope[picker][1], 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f), 2.0f * (xurand() - 0.5f)); |
| 120 | + |
| 121 | + sLFuncEnd[picker] = 0.25f * (xurand() * 0.5f) + (picker + 1); |
| 122 | + |
| 123 | + for (S32 j = 0; j <= picker + 1; j++) |
| 124 | + { |
| 125 | + F32 prevEnd; |
| 126 | + if (picker == 0) |
| 127 | + { |
| 128 | + i = 9; |
| 129 | + prevEnd = 0.0f; |
| 130 | + } |
| 131 | + else |
| 132 | + { |
| 133 | + i = picker - 1; |
| 134 | + prevEnd = sLFuncEnd[i]; |
| 135 | + } |
| 136 | + |
| 137 | + xFuncPiece_EndPoints(&sLFuncX[j], prevEnd, sLFuncEnd[j], sLFuncVal[j].x, sLFuncVal[i].x); |
| 138 | + xFuncPiece_EndPoints(&sLFuncY[j], prevEnd, sLFuncEnd[j], sLFuncVal[j].y, sLFuncVal[i].y); |
| 139 | + xFuncPiece_EndPoints(&sLFuncZ[j], prevEnd, sLFuncEnd[j], sLFuncVal[j].z, sLFuncVal[i].z); |
| 140 | + } |
| 141 | + |
| 142 | + sLFuncJerkTime = 0.0f; |
| 143 | +} |
| 144 | + |
82 | 145 | void zLightningRender() |
83 | 146 | { |
84 | 147 | if (sLightningRaster != NULL) |
|
0 commit comments