light: DirtTrace: add extra argument for hit face
This commit is contained in:
parent
99b1069a47
commit
0c93c5c3d0
|
|
@ -102,7 +102,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 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 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, plane_t *hitplane_out);
|
qboolean DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
vec_t light;
|
vec_t light;
|
||||||
|
|
|
||||||
|
|
@ -590,7 +590,7 @@ CheckObstructed(const lightsurf_t *surf, const vec3_t offset, const vec_t us, co
|
||||||
|
|
||||||
vec3_t hitpoint = {0};
|
vec3_t hitpoint = {0};
|
||||||
plane_t hitplane = {0};
|
plane_t hitplane = {0};
|
||||||
if (DirtTrace(surf->midpoint, testpoint, surf->modelinfo->model, hitpoint, &hitplane)) {
|
if (DirtTrace(surf->midpoint, testpoint, surf->modelinfo->model, hitpoint, &hitplane, NULL)) {
|
||||||
// make a corrected point
|
// make a corrected point
|
||||||
|
|
||||||
vec3_t tracedir;
|
vec3_t tracedir;
|
||||||
|
|
@ -1563,7 +1563,7 @@ void SetupDirt( void ) {
|
||||||
* ============
|
* ============
|
||||||
*/
|
*/
|
||||||
qboolean
|
qboolean
|
||||||
DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, plane_t *hitplane_out)
|
DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hitpoint_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
|
||||||
{
|
{
|
||||||
const modelinfo_t *const *model;
|
const modelinfo_t *const *model;
|
||||||
traceinfo_t ti = {0};
|
traceinfo_t ti = {0};
|
||||||
|
|
@ -1577,6 +1577,9 @@ DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hi
|
||||||
if (hitplane_out) {
|
if (hitplane_out) {
|
||||||
*hitplane_out = ti.hitplane;
|
*hitplane_out = ti.hitplane;
|
||||||
}
|
}
|
||||||
|
if (face_out) {
|
||||||
|
*face_out = ti.face;
|
||||||
|
}
|
||||||
return !ti.hitsky;
|
return !ti.hitsky;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1590,6 +1593,9 @@ DirtTrace(const vec3_t start, const vec3_t stop, const dmodel_t *self, vec3_t hi
|
||||||
if (hitplane_out) {
|
if (hitplane_out) {
|
||||||
*hitplane_out = ti.hitplane;
|
*hitplane_out = ti.hitplane;
|
||||||
}
|
}
|
||||||
|
if (face_out) {
|
||||||
|
*face_out = ti.face;
|
||||||
|
}
|
||||||
return !ti.hitsky;
|
return !ti.hitsky;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1655,7 +1661,7 @@ DirtForSample(const dmodel_t *model, const vec3_t origin, const vec3_t normal){
|
||||||
VectorMA( origin, dirtDepth, direction, traceEnd );
|
VectorMA( origin, dirtDepth, direction, traceEnd );
|
||||||
|
|
||||||
/* trace */
|
/* trace */
|
||||||
if (DirtTrace(origin, traceEnd, model, traceHitpoint, NULL)) {
|
if (DirtTrace(origin, traceEnd, model, traceHitpoint, NULL, NULL)) {
|
||||||
VectorSubtract( traceHitpoint, origin, displacement );
|
VectorSubtract( traceHitpoint, origin, displacement );
|
||||||
gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
|
gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
|
||||||
}
|
}
|
||||||
|
|
@ -1672,7 +1678,7 @@ DirtForSample(const dmodel_t *model, const vec3_t origin, const vec3_t normal){
|
||||||
VectorMA( origin, dirtDepth, direction, traceEnd );
|
VectorMA( origin, dirtDepth, direction, traceEnd );
|
||||||
|
|
||||||
/* trace */
|
/* trace */
|
||||||
if (DirtTrace(origin, traceEnd, model, traceHitpoint, NULL)) {
|
if (DirtTrace(origin, traceEnd, model, traceHitpoint, NULL, NULL)) {
|
||||||
VectorSubtract( traceHitpoint, origin, displacement );
|
VectorSubtract( traceHitpoint, origin, displacement );
|
||||||
gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
|
gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
|
||||||
}
|
}
|
||||||
|
|
@ -1683,7 +1689,7 @@ DirtForSample(const dmodel_t *model, const vec3_t origin, const vec3_t normal){
|
||||||
VectorMA( origin, dirtDepth, normal, traceEnd );
|
VectorMA( origin, dirtDepth, normal, traceEnd );
|
||||||
|
|
||||||
/* trace */
|
/* trace */
|
||||||
if (DirtTrace(origin, traceEnd, model, traceHitpoint, NULL)) {
|
if (DirtTrace(origin, traceEnd, model, traceHitpoint, NULL, NULL)) {
|
||||||
VectorSubtract( traceHitpoint, origin, displacement );
|
VectorSubtract( traceHitpoint, origin, displacement );
|
||||||
gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
|
gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue