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

Function DrawVisLightningBolt

Descent3/viseffect.cpp:1182–1258  ·  view source on GitHub ↗

Draws a lighting bolt from one area to another Velocity.x is how much randomness goes into drawing Velocity.y is the scalar that effects how many segments to draw

Source from the content-addressed store, hash-verified

1180// Velocity.x is how much randomness goes into drawing
1181// Velocity.y is the scalar that effects how many segments to draw
1182void DrawVisLightningBolt(vis_effect *vis) {
1183 vector line_norm;
1184 float line_mag;
1185 int num_segs;
1186 float lightning_mag;
1187
1188 g3Point pnt1, pnt2;
1189
1190 line_norm = vis->pos - vis->end_pos;
1191 line_mag = vm_GetMagnitudeFast(&line_norm);
1192
1193 line_norm /= line_mag;
1194
1195 if (line_mag < 1)
1196 return;
1197
1198 float alpha_norm;
1199
1200 if (vis->flags & VF_EXPAND) {
1201 num_segs = line_mag * vis->velocity.y;
1202 lightning_mag = vis->velocity.x;
1203
1204 alpha_norm = vis->lifeleft / vis->lifetime;
1205 } else {
1206 num_segs = line_mag * vis->velocity.y;
1207 lightning_mag = vis->velocity.x;
1208
1209 alpha_norm = .7f;
1210
1211 // Make it powerup up based on distance
1212 if (line_mag > 30 && (vis->flags & VF_NO_Z_ADJUST)) {
1213 float scalar = 1.0 - ((line_mag - 30) / 150.0);
1214 if (scalar < 0)
1215 return;
1216
1217 alpha_norm *= scalar;
1218 }
1219 }
1220
1221 if (num_segs < 2)
1222 return;
1223
1224 // Set some states
1225
1226 rend_SetTextureType(TT_FLAT);
1227 rend_SetAlphaType(AT_SATURATE_VERTEX);
1228 rend_SetLighting(LS_NONE);
1229 rend_SetZBufferWriteMask(0);
1230
1231 if (vis->id == GRAY_LIGHTNING_BOLT_INDEX) {
1232 // get the color from the struct
1233 rend_SetFlatColor(GR_16_TO_COLOR(vis->lighting_color));
1234 } else {
1235 rend_SetFlatColor(GR_RGB(10, 60, 200));
1236 }
1237
1238 pnt1.p3_a = alpha_norm;
1239 pnt2.p3_a = alpha_norm;

Callers 1

DrawVisEffectFunction · 0.85

Calls 11

GR_16_TO_COLORFunction · 0.85
g3_RotatePointFunction · 0.85
g3_DrawSpecialLineFunction · 0.85
vm_GetMagnitudeFastFunction · 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

Tested by

no test coverage detected