light: augment DirtTrace with the hit plane
This commit is contained in:
parent
ddbf55ac13
commit
cf8e3fc935
|
|
@ -41,11 +41,15 @@ extern "C" {
|
|||
#define TRACE_HIT_LAVA (1 << 3)
|
||||
#define TRACE_HIT_SKY (1 << 4)
|
||||
|
||||
typedef struct {
|
||||
vec3_t normal;
|
||||
vec_t dist;
|
||||
} plane_t;
|
||||
|
||||
typedef struct traceinfo_s {
|
||||
vec3_t point;
|
||||
const bsp2_dface_t *face;
|
||||
vec3_t hitnormal;
|
||||
plane_t hitplane;
|
||||
/* returns true if sky was hit. */
|
||||
bool hitsky;
|
||||
bool hitback;
|
||||
|
|
@ -100,7 +104,7 @@ int TraceLine(const dmodel_t *model, const int traceflags,
|
|||
*/
|
||||
qboolean TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self);
|
||||
qboolean TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self);
|
||||
qboolean DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, vec3_t hitnormal_out);
|
||||
qboolean DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, plane_t *hitplane_out);
|
||||
|
||||
typedef struct {
|
||||
vec_t light;
|
||||
|
|
@ -126,11 +130,6 @@ typedef struct sun_s {
|
|||
float anglescale;
|
||||
} sun_t;
|
||||
|
||||
typedef struct {
|
||||
vec3_t normal;
|
||||
vec_t dist;
|
||||
} plane_t;
|
||||
|
||||
/* for vanilla this would be 18. some engines allow higher limits though, which will be needed if we're scaling lightmap resolution. */
|
||||
/*with extra sampling, lit+lux etc, we need at least 46mb stack space per thread. yes, that's a lot. on the plus side, it doesn't affect bsp complexity (actually, can simplify it a little)*/
|
||||
#define MAXDIMENSION (255+1)
|
||||
|
|
|
|||
|
|
@ -594,8 +594,8 @@ CheckObstructed(const lightsurf_t *surf, const vec3_t offset, const vec_t us, co
|
|||
VectorAdd(testpoint, offset, testpoint);
|
||||
|
||||
vec3_t hitpoint = {0};
|
||||
vec3_t hitnormal = {0};
|
||||
if (DirtTrace(surf->midpoint, testpoint, surf->modelinfo->model, hitpoint, hitnormal)) {
|
||||
plane_t hitplane = {0};
|
||||
if (DirtTrace(surf->midpoint, testpoint, surf->modelinfo->model, hitpoint, &hitplane)) {
|
||||
// make a corrected point
|
||||
|
||||
vec3_t tracedir;
|
||||
|
|
@ -1442,7 +1442,7 @@ void SetupDirt( void ) {
|
|||
* ============
|
||||
*/
|
||||
qboolean
|
||||
DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, vec3_t hitnormal_out)
|
||||
DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, plane_t *hitplane_out)
|
||||
{
|
||||
const modelinfo_t *const *model;
|
||||
traceinfo_t ti = {0};
|
||||
|
|
@ -1453,8 +1453,8 @@ DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hi
|
|||
if (self) {
|
||||
if (TraceFaces (&ti, self->headnode[0], start, stop)) {
|
||||
VectorCopy(ti.point, hitpoint_out);
|
||||
if (hitnormal_out) {
|
||||
VectorCopy(ti.hitnormal, hitnormal_out);
|
||||
if (hitplane_out) {
|
||||
*hitplane_out = ti.hitplane;
|
||||
}
|
||||
return !ti.hitsky;
|
||||
}
|
||||
|
|
@ -1466,8 +1466,8 @@ DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hi
|
|||
continue;
|
||||
if (TraceFaces (&ti, (*model)->model->headnode[0], start, stop)) {
|
||||
VectorCopy(ti.point, hitpoint_out);
|
||||
if (hitnormal_out) {
|
||||
VectorCopy(ti.hitnormal, hitnormal_out);
|
||||
if (hitplane_out) {
|
||||
*hitplane_out = ti.hitplane;
|
||||
}
|
||||
return !ti.hitsky;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -615,7 +615,9 @@ bool TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end
|
|||
if (fi->content == CONTENTS_SOLID || fi->content == CONTENTS_SKY) {
|
||||
ti->face = face;
|
||||
ti->hitsky = (fi->content == CONTENTS_SKY);
|
||||
VectorCopy(fi->plane.normal, ti->hitnormal);
|
||||
VectorCopy(fi->plane.normal, ti->hitplane.normal);
|
||||
ti->hitplane.dist = fi->plane.dist;
|
||||
|
||||
// check if we hit the back side
|
||||
ti->hitback = (DotProduct(ti->dir, fi->plane.normal) >= 0);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue