From: Holger Z. <hz...@us...> - 2004-07-13 11:10:05
|
Update of /cvsroot/jake2/jake2/src/jake2/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15525/src/jake2/client Modified Files: CL_fx.java Log Message: small optimizations Index: CL_fx.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/client/CL_fx.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CL_fx.java 8 Jul 2004 20:56:50 -0000 1.4 --- CL_fx.java 13 Jul 2004 11:09:55 -0000 1.5 *************** *** 46,54 **** float radius; float die; // stop lighting after this time ! float decay; // drop this each second float minlight; // don't add when contributing less void clear() { ! radius = ! decay = die = minlight = color[0] = color[1] = color[2] = origin[0] = origin[1] = origin[2] = key = 0; } } --- 46,53 ---- float radius; float die; // stop lighting after this time ! //float decay; // drop this each second float minlight; // don't add when contributing less void clear() { ! radius = minlight = color[0] = color[1] = color[2] = 0; } } *************** *** 101,122 **** */ static void RunLightStyles() { ! int ofs; ! int i; ! clightstyle_t[] ls; ! ofs = cl.time / 100; if (ofs == lastofs) return; lastofs = ofs; ! ls = cl_lightstyle; ! for (i = 0; i < ls.length; i++) { ! if (ls[i].length == 0) { ! ls[i].value[0] = ls[i].value[1] = ls[i].value[2] = 1.0f; continue; } if (ls.length == 1) ! ls[i].value[0] = ls[i].value[1] = ls[i].value[2] = ls[i].map[0]; else ! ls[i].value[0] = ls[i].value[1] = ls[i].value[2] = ls[i].map[ofs % ls[i].length]; } } --- 100,120 ---- */ static void RunLightStyles() { ! clightstyle_t ls; ! int ofs = cl.time / 100; if (ofs == lastofs) return; lastofs = ofs; ! ! for (int i = 0; i < cl_lightstyle.length; i++) { ! ls = cl_lightstyle[i]; ! if (ls.length == 0) { ! ls.value[0] = ls.value[1] = ls.value[2] = 1.0f; continue; } if (ls.length == 1) ! ls.value[0] = ls.value[1] = ls.value[2] = ls.map[0]; else ! ls.value[0] = ls.value[1] = ls.value[2] = ls.map[ofs % ls.length]; } } *************** *** 144,153 **** */ static void AddLightStyles() { ! int i; ! clightstyle_t[] ls; ! ls = cl_lightstyle; ! for (i = 0; i < ls.length; i++) ! V.AddLightStyle(i, ls[i].value[0], ls[i].value[1], ls[i].value[2]); } --- 142,151 ---- */ static void AddLightStyles() { ! clightstyle_t ls; ! for (int i = 0; i < cl_lightstyle.length; i++) { ! ls = cl_lightstyle[i]; ! V.AddLightStyle(i, ls.value[0], ls.value[1], ls.value[2]); ! } } *************** *** 186,200 **** static cdlight_t AllocDlight(int key) { int i; ! cdlight_t[] dl; // first look for an exact key match ! if (key != 0) { ! dl = cl_dlights; for (i = 0; i < MAX_DLIGHTS; i++) { ! if (dl[i].key == key) { //memset (dl, 0, sizeof(*dl)); ! dl[i].clear(); ! dl[i].key = key; ! return dl[i]; } } --- 184,198 ---- static cdlight_t AllocDlight(int key) { int i; ! cdlight_t dl; // first look for an exact key match ! if (key != 0) { for (i = 0; i < MAX_DLIGHTS; i++) { ! dl = cl_dlights[i]; ! if (dl.key == key) { //memset (dl, 0, sizeof(*dl)); ! dl.clear(); ! dl.key = key; ! return dl; } } *************** *** 202,212 **** // then look for anything else - dl = cl_dlights; for (i = 0; i < MAX_DLIGHTS; i++) { ! if (dl[i].die < cl.time) { //memset (dl, 0, sizeof(*dl)); ! dl[i].clear(); ! dl[i].key = key; ! return dl[i]; } } --- 200,210 ---- // then look for anything else for (i = 0; i < MAX_DLIGHTS; i++) { ! dl = cl_dlights[i]; ! if (dl.die < cl.time) { //memset (dl, 0, sizeof(*dl)); ! dl.clear(); ! dl.key = key; ! return dl; } } *************** *** 214,220 **** //dl = &cl_dlights[0]; //memset (dl, 0, sizeof(*dl)); ! dl[0].clear(); ! dl[0].key = key; ! return dl[0]; } --- 212,219 ---- //dl = &cl_dlights[0]; //memset (dl, 0, sizeof(*dl)); ! dl = cl_dlights[0]; ! dl.clear(); ! dl.key = key; ! return dl; } *************** *** 242,259 **** */ static void RunDLights() { ! cdlight_t[] dl; - dl = cl_dlights; for (int i = 0; i < MAX_DLIGHTS; i++) { ! if (dl[i].radius == 0.0f) continue; ! if (dl[i].die < cl.time) { ! dl[i].radius = 0; return; } ! dl[i].radius -= cls.frametime * dl[i].decay; ! if (dl[i].radius < 0) ! dl[i].radius = 0; } } --- 241,258 ---- */ static void RunDLights() { ! cdlight_t dl; for (int i = 0; i < MAX_DLIGHTS; i++) { ! dl = cl_dlights[i]; ! if (dl.radius == 0.0f) continue; ! if (dl.die < cl.time) { ! dl.radius = 0.0f; return; } ! //dl[i].radius -= cls.frametime * dl[i].decay; ! //if (dl[i].radius < 0) ! // dl[i].radius = 0; } } *************** *** 954,982 **** */ static void AddDLights() { ! int i; ! ! cdlight_t[] dl = cl_dlights; // ===== // PGM if (vidref_val == VIDREF_GL) { ! for (i = 0; i < MAX_DLIGHTS; i++) { ! if (dl[i].radius == 0.0f) continue; ! V.AddLight(dl[i].origin, dl[i].radius, dl[i].color[0], dl[i].color[1], dl[i].color[2]); } } else { ! for (i = 0; i < MAX_DLIGHTS; i++) { ! if (dl[i].radius == 0.0f) continue; // negative light in software. only black allowed ! if ((dl[i].color[0] < 0) || (dl[i].color[1] < 0) || (dl[i].color[2] < 0)) { ! dl[i].radius = - (dl[i].radius); ! dl[i].color[0] = 1; ! dl[i].color[1] = 1; ! dl[i].color[2] = 1; } ! V.AddLight(dl[i].origin, dl[i].radius, dl[i].color[0], dl[i].color[1], dl[i].color[2]); } } --- 953,981 ---- */ static void AddDLights() { ! cdlight_t dl; // ===== // PGM if (vidref_val == VIDREF_GL) { ! for (int i = 0; i < MAX_DLIGHTS; i++) { ! dl = cl_dlights[i]; ! if (dl.radius == 0.0f) continue; ! V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); } } else { ! for (int i = 0; i < MAX_DLIGHTS; i++) { ! dl = cl_dlights[i]; ! if (dl.radius == 0.0f) continue; // negative light in software. only black allowed ! if ((dl.color[0] < 0) || (dl.color[1] < 0) || (dl.color[2] < 0)) { ! dl.radius = - (dl.radius); ! dl.color[0] = 1; ! dl.color[1] = 1; ! dl.color[2] = 1; } ! V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); } } *************** *** 1508,1515 **** float[] move = new float[3]; float[] vec = new float[3]; - float len; - int j; cparticle_t p; - float dec; float orgscale; float velscale; --- 1507,1511 ---- *************** *** 1517,1523 **** VectorCopy(start, move); VectorSubtract(end, start, vec); ! len = VectorNormalize(vec); ! dec = 0.5f; VectorScale(vec, dec, vec); --- 1513,1519 ---- VectorCopy(start, move); VectorSubtract(end, start, vec); ! float len = VectorNormalize(vec); ! float dec = 0.5f; VectorScale(vec, dec, vec); *************** *** 1553,1557 **** p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); p.color = 0xe8 + (rand() & 7); ! for (j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; --- 1549,1553 ---- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); p.color = 0xe8 + (rand() & 7); ! for (int j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; *************** *** 1563,1567 **** p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); p.color = 0xdb + (rand() & 7); ! for (j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; --- 1559,1563 ---- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); p.color = 0xdb + (rand() & 7); ! for (int j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; *************** *** 1573,1577 **** p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); p.color = 4 + (rand() & 7); ! for (j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; --- 1569,1573 ---- p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); p.color = 4 + (rand() & 7); ! for (int j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; |