MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CG_AddMarks

Function CG_AddMarks

code/cgame/cg_marks.cpp:233–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231#define MARK_FADE_TIME 1000
232
233void CG_AddMarks( void ) {
234 int j;
235 markPoly_t *mp, *next;
236 int t;
237 int fade;
238
239 if ( !cg_addMarks.integer ) {
240 return;
241 }
242
243 mp = cg_activeMarkPolys.nextMark;
244 for ( ; mp != &cg_activeMarkPolys ; mp = next ) {
245 // grab next now, so if the local entity is freed we
246 // still have it
247 next = mp->nextMark;
248
249 // see if it is time to completely remove it
250 if ( cg.time > mp->time + MARK_TOTAL_TIME ) {
251 CG_FreeMarkPoly( mp );
252 continue;
253 }
254
255 // fade all marks out with time
256 t = mp->time + MARK_TOTAL_TIME - cg.time;
257 if ( t < MARK_FADE_TIME ) {
258 fade = 255 * t / MARK_FADE_TIME;
259 if ( mp->alphaFade ) {
260 for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
261 mp->verts[j].modulate[3] = fade;
262 }
263 }
264 else
265 {
266 float f = (float)t / MARK_FADE_TIME;
267 for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
268 mp->verts[j].modulate[0] = mp->color[0] * f;
269 mp->verts[j].modulate[1] = mp->color[1] * f;
270 mp->verts[j].modulate[2] = mp->color[2] * f;
271 }
272 }
273 }
274 else
275 {
276 for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
277 mp->verts[j].modulate[0] = mp->color[0];
278 mp->verts[j].modulate[1] = mp->color[1];
279 mp->verts[j].modulate[2] = mp->color[2];
280 }
281 }
282
283
284 cgi_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );
285 }
286}
287

Callers 1

CG_DrawActiveFrameFunction · 0.70

Calls 2

CG_FreeMarkPolyFunction · 0.70
cgi_R_AddPolyToSceneFunction · 0.70

Tested by

no test coverage detected