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); void LoadNodes (const char *file);
qboolean TestLine (lightinfo_t *l, vec3_t start, vec3_t stop); 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 LightFace (lightinfo_t *l, int surfnum);
void LightLeaf (dleaf_t *leaf); void LightLeaf (dleaf_t *leaf);

View file

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