mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-25 05:21:58 +00:00
Some optimizations, use memset instead of for loop with *bl++=0.
Uses almost 1% less CPU for me :-)
This commit is contained in:
parent
ea7e76fab7
commit
19c37bbcb3
1 changed files with 4 additions and 14 deletions
|
@ -235,29 +235,19 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
|
||||||
|
|
||||||
// set to full bright if no light data
|
// set to full bright if no light data
|
||||||
if (!cl.worldmodel->lightdata) {
|
if (!cl.worldmodel->lightdata) {
|
||||||
bl = blocklights;
|
memset (&blocklights[0], 255, size * 3 * sizeof (unsigned int));
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
*bl++ = 255 << 8;
|
|
||||||
*bl++ = 255 << 8;
|
|
||||||
*bl++ = 255 << 8;
|
|
||||||
}
|
|
||||||
goto store;
|
goto store;
|
||||||
}
|
}
|
||||||
// clear to no light
|
// clear to no light
|
||||||
bl = blocklights;
|
|
||||||
for (i = 0; i < size; i++) {
|
memset (&blocklights[0], 0, size * 3 * sizeof (unsigned int));
|
||||||
*bl++ = 0;
|
|
||||||
*bl++ = 0;
|
|
||||||
*bl++ = 0;
|
|
||||||
}
|
|
||||||
bl = blocklights;
|
|
||||||
|
|
||||||
// add all the lightmaps
|
// add all the lightmaps
|
||||||
if (lightmap) {
|
if (lightmap) {
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) {
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) {
|
||||||
scale = d_lightstylevalue[surf->styles[maps]];
|
scale = d_lightstylevalue[surf->styles[maps]];
|
||||||
surf->cached_light[maps] = scale; // 8.8 fraction
|
surf->cached_light[maps] = scale; // 8.8 fraction
|
||||||
bl = blocklights;
|
bl=blocklights;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
*bl++ += *lightmap++ * scale;
|
*bl++ += *lightmap++ * scale;
|
||||||
*bl++ += *lightmap++ * scale;
|
*bl++ += *lightmap++ * scale;
|
||||||
|
|
Loading…
Reference in a new issue