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

Function DrawVisThickLightning

Descent3/viseffect.cpp:1376–1458  ·  view source on GitHub ↗

Draws a thick lighting bolt from one area to another Velocity.x is how many times to saturate Velocity.y is how fast the lightning moves across the v component Velocity.z is how many times the effect is tiled across the v component If Billboard_info.texture is not zero, it does autotiling

Source from the content-addressed store, hash-verified

1374// Velocity.z is how many times the effect is tiled across the v component
1375// If Billboard_info.texture is not zero, it does autotiling
1376void DrawVisThickLightning(vis_effect *vis) {
1377 // compute the corners of a rod. fills in vertbuf.
1378 g3Point top_point, bot_point;
1379 g3Point pnts[4], *pntlist[4];
1380
1381 g3_RotatePoint(&top_point, &vis->pos);
1382 g3_RotatePoint(&bot_point, &vis->end_pos);
1383
1384 if (!GetBillboardCorners(pnts, &top_point, &bot_point, vis->billboard_info.width))
1385 return;
1386
1387 vector line_norm = vis->end_pos - vis->pos;
1388 float line_mag = vm_GetMagnitudeFast(&line_norm);
1389
1390 line_norm /= line_mag;
1391
1392 if (line_mag < 1)
1393 return;
1394
1395 int texnum = vis->custom_handle;
1396 int bm_handle = GetTextureBitmap(texnum, 0, true);
1397 float tile_factor = vis->velocity.z;
1398 float alpha_norm;
1399 int i, codes_and;
1400
1401 if (vis->flags & VF_EXPAND)
1402 alpha_norm = vis->lifeleft / vis->lifetime;
1403 else
1404 alpha_norm = .7f;
1405
1406 rend_SetOverlayType(OT_NONE);
1407 rend_SetTextureType(TT_LINEAR);
1408 rend_SetLighting(LS_FLAT_GOURAUD);
1409 rend_SetAlphaType(AT_SATURATE_TEXTURE);
1410 rend_SetWrapType(WT_WRAP);
1411 rend_SetFlatColor(GR_16_TO_COLOR(vis->lighting_color));
1412 rend_SetAlphaValue(255 * alpha_norm);
1413 rend_SetZBufferWriteMask(0);
1414
1415 for (i = 0, codes_and = 0xff; i < 4; i++) {
1416 pntlist[i] = &pnts[i];
1417 }
1418
1419 if (vis->billboard_info.texture) // do autotiling
1420 {
1421 float ratio = line_mag / (float)vis->billboard_info.width;
1422 tile_factor *= ratio;
1423 }
1424
1425 pnts[0].p3_u = 0;
1426 pnts[0].p3_v = 0;
1427
1428 pnts[1].p3_u = 1;
1429 pnts[1].p3_v = 0;
1430
1431 pnts[2].p3_u = 1;
1432 pnts[2].p3_v = tile_factor;
1433

Callers 1

DrawVisEffectFunction · 0.85

Calls 14

g3_RotatePointFunction · 0.85
GetBillboardCornersFunction · 0.85
GetTextureBitmapFunction · 0.85
GR_16_TO_COLORFunction · 0.85
g3_DrawPolyFunction · 0.85
vm_GetMagnitudeFastFunction · 0.50
rend_SetOverlayTypeFunction · 0.50
rend_SetTextureTypeFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetWrapTypeFunction · 0.50
rend_SetFlatColorFunction · 0.50

Tested by

no test coverage detected