MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawVisSineWave

Function DrawVisSineWave

Descent3/viseffect.cpp:1263–1328  ·  view source on GitHub ↗

Draws a lighting bolt sine wave from one area to another Velocity.x represents how many increments to take (a scalar) Velocity.y represents how "wide" the arcs are from the center of the line

Source from the content-addressed store, hash-verified

1261// Velocity.x represents how many increments to take (a scalar)
1262// Velocity.y represents how "wide" the arcs are from the center of the line
1263void DrawVisSineWave(vis_effect *vis) {
1264 vector line_norm;
1265 float line_mag;
1266 matrix mat;
1267 int num_segs;
1268
1269 vector from, to, base_from, rvec, uvec;
1270 g3Point pnt1, pnt2;
1271
1272 line_norm = vis->pos - vis->end_pos;
1273 line_mag = vm_GetMagnitudeFast(&line_norm);
1274 if (line_mag < .1)
1275 return;
1276
1277 line_norm /= line_mag;
1278
1279 float alpha_norm;
1280
1281 if (vis->flags & VF_EXPAND)
1282 alpha_norm = vis->lifeleft / vis->lifetime;
1283
1284 num_segs = vis->velocity.x * line_mag; // /2
1285 line_norm /= vis->velocity.x; // *2
1286
1287 alpha_norm = vis->lifeleft / vis->lifetime;
1288
1289 vm_VectorToMatrix(&mat, &line_norm, &vis->velocity, NULL);
1290 rvec = mat.rvec * vis->velocity.y; // /4
1291 uvec = mat.uvec * vis->velocity.y; // /4
1292
1293 // Set some states
1294
1295 rend_SetTextureType(TT_FLAT);
1296 rend_SetAlphaType(AT_SATURATE_VERTEX);
1297 rend_SetLighting(LS_NONE);
1298 rend_SetZBufferWriteMask(0);
1299 rend_SetFlatColor(GR_RGB(10, 60, 200));
1300 int cur_sin = (vis - VisEffects) * 5000;
1301
1302 cur_sin += (FrameCount * 2000);
1303
1304 base_from = vis->end_pos;
1305 from = base_from;
1306
1307 pnt1.p3_a = alpha_norm;
1308 pnt2.p3_a = alpha_norm;
1309
1310 for (int i = 0; i < num_segs; i++, base_from += line_norm) {
1311 to = base_from + line_norm + (FixSin((cur_sin) % 65536) * uvec);
1312 to += (FixCos((cur_sin) % 65536) * rvec);
1313
1314 g3_RotatePoint(&pnt1, &from);
1315 g3_RotatePoint(&pnt2, &to);
1316
1317 pnt1.p3_flags |= PF_RGBA;
1318 pnt2.p3_flags |= PF_RGBA;
1319
1320 g3_DrawSpecialLine(&pnt1, &pnt2);

Callers 1

DrawVisEffectFunction · 0.85

Calls 12

g3_RotatePointFunction · 0.85
g3_DrawSpecialLineFunction · 0.85
vm_GetMagnitudeFastFunction · 0.50
vm_VectorToMatrixFunction · 0.50
rend_SetTextureTypeFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetZBufferWriteMaskFunction · 0.50
rend_SetFlatColorFunction · 0.50
GR_RGBFunction · 0.50
FixSinFunction · 0.50
FixCosFunction · 0.50

Tested by

no test coverage detected