Cube  Diff

Differences From Artifact [3bb65afc34]:

To Artifact [2af1475366]:


95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139
140
141

142
143
144
145
146
147
148
				if (SOLID(s))
					return;
				x += stepx;
				y += stepy;
				l -= stepl;
				stepl -= 25;
			}
		};

	} else // the old (white) light code, here for the few people with old
	       // video cards that don't support overbright
	{
		loopi(steps)
		{
			sqr *s = S(x >> PRECBITS, y >> PRECBITS);
			int light = l >> PRECBITS;
			if (light > s->r)
				s->r = s->g = s->b = (uchar)light;
			if (SOLID(s))
				return;
			x += stepx;
			y += stepy;
			l -= stepl;
		}
	};

}

void
calclightsource(persistent_entity &l)
{
	int reach = l.attr1;
	int sx = l.x - reach;
	int ex = l.x + reach;
	int sy = l.y - reach;
	int ey = l.y + reach;

	rndreset();

	const float s = 0.8f;

	for (float sx2 = (float)sx; sx2 <= ex; sx2 += s * 2) {
		lightray(sx2, (float)sy, l);
		lightray(sx2, (float)ey, l);
	};

	for (float sy2 = sy + s; sy2 <= ey - s; sy2 += s * 2) {
		lightray((float)sx, sy2, l);
		lightray((float)ex, sy2, l);
	};


	rndtime();
}

void
postlightarea(block &a) // median filter, smooths out random noise in light and
                        // makes it more mipable







<
>















<
>


















<
>



<
>







95
96
97
98
99
100
101

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140

141
142
143
144
145
146
147
148
				if (SOLID(s))
					return;
				x += stepx;
				y += stepy;
				l -= stepl;
				stepl -= 25;
			}

		}
	} else // the old (white) light code, here for the few people with old
	       // video cards that don't support overbright
	{
		loopi(steps)
		{
			sqr *s = S(x >> PRECBITS, y >> PRECBITS);
			int light = l >> PRECBITS;
			if (light > s->r)
				s->r = s->g = s->b = (uchar)light;
			if (SOLID(s))
				return;
			x += stepx;
			y += stepy;
			l -= stepl;
		}

	}
}

void
calclightsource(persistent_entity &l)
{
	int reach = l.attr1;
	int sx = l.x - reach;
	int ex = l.x + reach;
	int sy = l.y - reach;
	int ey = l.y + reach;

	rndreset();

	const float s = 0.8f;

	for (float sx2 = (float)sx; sx2 <= ex; sx2 += s * 2) {
		lightray(sx2, (float)sy, l);
		lightray(sx2, (float)ey, l);

	}
	for (float sy2 = sy + s; sy2 <= ey - s; sy2 += s * 2) {
		lightray((float)sx, sy2, l);
		lightray((float)ex, sy2, l);

	}

	rndtime();
}

void
postlightarea(block &a) // median filter, smooths out random noise in light and
                        // makes it more mipable
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
	loopv(ents)
	{
		entity &e = ents[i];
		if (e.type == LIGHT)
			calclightsource(e);
	}

	block b = {1, 1, ssize - 2, ssize - 2};
	postlightarea(b);
	setvar(@"fullbright", 0);
}

VARP(dynlight, 0, 16, 32);

vector<block *> dlights;







|







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
	loopv(ents)
	{
		entity &e = ents[i];
		if (e.type == LIGHT)
			calclightsource(e);
	}

	block b = { 1, 1, ssize - 2, ssize - 2 };
	postlightarea(b);
	setvar(@"fullbright", 0);
}

VARP(dynlight, 0, 16, 32);

vector<block *> dlights;
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
		reach = reach / 2;
	if (!reach)
		return;
	if (v.x < 0 || v.y < 0 || v.x > ssize || v.y > ssize)
		return;

	int creach = reach + 16; // dependant on lightray random offsets!
	block b = {(int)v.x - creach, (int)v.y - creach, creach * 2 + 1,
	    creach * 2 + 1};

	if (b.x < 1)
		b.x = 1;
	if (b.y < 1)
		b.y = 1;
	if (b.xs + b.x > ssize - 2)
		b.xs = ssize - 2 - b.x;
	if (b.ys + b.y > ssize - 2)
		b.ys = ssize - 2 - b.y;

	dlights.add(blockcopy(b)); // backup area before rendering in dynlight

	persistent_entity l = {(short)v.x, (short)v.y, (short)v.z, (short)reach,
	    LIGHT, (uchar)strength, 0, 0};
	calclightsource(l);
	postlightarea(b);
}

// utility functions also used by editing code

block *







|
|












|
|







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
		reach = reach / 2;
	if (!reach)
		return;
	if (v.x < 0 || v.y < 0 || v.x > ssize || v.y > ssize)
		return;

	int creach = reach + 16; // dependant on lightray random offsets!
	block b = { (int)v.x - creach, (int)v.y - creach, creach * 2 + 1,
		creach * 2 + 1 };

	if (b.x < 1)
		b.x = 1;
	if (b.y < 1)
		b.y = 1;
	if (b.xs + b.x > ssize - 2)
		b.xs = ssize - 2 - b.x;
	if (b.ys + b.y > ssize - 2)
		b.ys = ssize - 2 - b.y;

	dlights.add(blockcopy(b)); // backup area before rendering in dynlight

	persistent_entity l = { (short)v.x, (short)v.y, (short)v.z,
		(short)reach, LIGHT, (uchar)strength, 0, 0 };
	calclightsource(l);
	postlightarea(b);
}

// utility functions also used by editing code

block *