Implement sky tracing.

Again, this is from Jardrup's light tool. Sun data is not yet parsed, nor
are any sun lighting calculations done.
This commit is contained in:
Bill Currie 2013-01-02 16:48:13 +09:00
parent 7cd1894a6d
commit 4f0a1df3c1
2 changed files with 20 additions and 3 deletions

View File

@ -96,6 +96,7 @@ extern float minlights[MAX_MAP_FACES];
void LoadNodes (const char *file);
qboolean TestLine (lightinfo_t *l, vec3_t start, vec3_t stop);
qboolean TestSky (lightinfo_t *l, vec3_t start, vec3_t stop);
void LightFace (lightinfo_t *l, int surfnum);
void LightLeaf (dleaf_t *leaf);

View File

@ -142,8 +142,8 @@ MakeTnodes (dmodel_t *bm)
#define TESTLINESTATE_EMPTY 1
#define TESTLINESTATE_SOLID 2
qboolean
TestLine (lightinfo_t *l, vec3_t start, vec3_t end)
static qboolean
TestLineOrSky (lightinfo_t *l, vec3_t start, vec3_t end, qboolean sky_test)
{
vec_t front, back;
vec3_t frontpt, backpt;
@ -161,6 +161,8 @@ TestLine (lightinfo_t *l, vec3_t start, vec3_t end)
while (1) {
while (node < 0) {
if (sky_test && node == CONTENTS_SKY)
return true;
if (node != CONTENTS_SOLID)
empty = 1;
else if (empty) {
@ -171,7 +173,7 @@ TestLine (lightinfo_t *l, vec3_t start, vec3_t end)
// pop up the stack for a back side
if (tstack-- == tracestack)
return true;
return !sky_test;
// set the hit point for this plane
VectorCopy (backpt, frontpt);
@ -219,3 +221,17 @@ TestLine (lightinfo_t *l, vec3_t start, vec3_t end)
node = tnode->children[side];
}
}
qboolean
TestLine (lightinfo_t *l, vec3_t start, vec3_t stop)
{
return TestLineOrSky (l, start, stop, false);
}
qboolean
TestSky (lightinfo_t *l, vec3_t start, vec3_t dir)
{
vec3_t stop;
VectorAdd (dir, start, stop);
return TestLineOrSky (l, start, stop, true);
}