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

Function DrawLightningSegment

Descent3/terrainrender.cpp:1438–1475  ·  view source on GitHub ↗

Draws a segment of lightning that is always facing you Vectors are in world coords

Source from the content-addressed store, hash-verified

1436// Draws a segment of lightning that is always facing you
1437// Vectors are in world coords
1438void DrawLightningSegment(vector *from, vector *to) {
1439 vector src_vecs[2], world_vecs[6];
1440 g3Point rot_src_pnts[2], world_points[6], *pntlist[6];
1441 static float alphas[] = {0.3f, 1.0f, 0.3f, 0.3f, 1.0f, 0.3f};
1442 src_vecs[0] = *from;
1443 src_vecs[1] = *to;
1444
1445 g3_RotatePoint(&rot_src_pnts[0], &src_vecs[0]);
1446 g3_RotatePoint(&rot_src_pnts[1], &src_vecs[1]);
1447 if (rot_src_pnts[0].p3_codes & rot_src_pnts[1].p3_codes)
1448 return; // Don't draw because both points are off screen
1449 vector rvec = Viewer_object->orient.rvec * 10;
1450
1451 // Put all points so that they face the viewer
1452 world_vecs[0] = src_vecs[0] - rvec;
1453 world_vecs[1] = src_vecs[0];
1454 world_vecs[2] = src_vecs[0] + rvec;
1455 world_vecs[3] = src_vecs[1] + rvec;
1456 world_vecs[4] = src_vecs[1];
1457 world_vecs[5] = src_vecs[1] - rvec;
1458 for (int i = 0; i < 6; i++) {
1459 g3_RotatePoint(&world_points[i], &world_vecs[i]);
1460 world_points[i].p3_flags |= PF_RGBA;
1461 world_points[i].p3_r = .2f;
1462 world_points[i].p3_g = .4f;
1463 world_points[i].p3_b = 1.0f;
1464 world_points[i].p3_a = alphas[i];
1465 pntlist[i] = &world_points[i];
1466 }
1467 rend_SetTextureType(TT_FLAT);
1468 rend_SetLighting(LS_GOURAUD);
1469 rend_SetAlphaType(AT_SATURATE_VERTEX);
1470 rend_SetColorModel(CM_RGB);
1471 g3_ProjectPoint(&world_points[1]);
1472 g3_ProjectPoint(&world_points[4]);
1473 rend_DrawSpecialLine(&world_points[1], &world_points[4]);
1474 g3_DrawPoly(6, pntlist, 0);
1475}
1476#define PUSH_LIGHTNING_TREE(f, l, sp) \
1477 { \
1478 froms[si] = f; \

Callers 1

DrawLightningFunction · 0.85

Calls 8

g3_RotatePointFunction · 0.85
g3_ProjectPointFunction · 0.85
g3_DrawPolyFunction · 0.85
rend_SetTextureTypeFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetColorModelFunction · 0.50
rend_DrawSpecialLineFunction · 0.50

Tested by

no test coverage detected