light: make DirtTrace return a hittype_t
This commit is contained in:
parent
197c898976
commit
f4a363b416
|
|
@ -39,6 +39,12 @@
|
|||
#define ON_EPSILON 0.1
|
||||
#define ANGLE_EPSILON 0.001
|
||||
|
||||
enum class hittype_t {
|
||||
NONE,
|
||||
SOLID,
|
||||
SKY
|
||||
};
|
||||
|
||||
/*
|
||||
* Convenience functions TestLight and TestSky will test against all shadow
|
||||
* casting bmodels and self-shadow the model 'self' if self != NULL. Returns
|
||||
|
|
@ -46,12 +52,12 @@
|
|||
*/
|
||||
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 dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
|
||||
hittype_t DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
|
||||
|
||||
void Embree_TraceInit(const bsp2_t *bsp);
|
||||
qboolean Embree_TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self);
|
||||
qboolean Embree_TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self);
|
||||
qboolean Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
|
||||
hittype_t Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
|
||||
|
||||
int
|
||||
SampleTexture(const bsp2_dface_t *face, const bsp2_t *bsp, const vec3_t point);
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ CheckObstructed(const lightsurf_t *surf, const vec3_t offset, const vec_t us, co
|
|||
|
||||
// trace from surf->midpoint to testpoint
|
||||
vec_t hitdist = 0;
|
||||
if (DirtTrace(surf->midpoint, dirn, dist, selfshadow, &hitdist, &hitplane, NULL)) {
|
||||
if (hittype_t::SOLID == DirtTrace(surf->midpoint, dirn, dist, selfshadow, &hitdist, &hitplane, NULL)) {
|
||||
// make a corrected point
|
||||
VectorMA(surf->midpoint, qmax(0.0f, hitdist - 0.25f), dirn, corrected);
|
||||
return true;
|
||||
|
|
@ -1897,7 +1897,7 @@ DirtForSample(const dmodel_t *model, const vec3_t origin, const vec3_t normal){
|
|||
direction[ 2 ] = myRt[ 2 ] * temp[ 0 ] + myUp[ 2 ] * temp[ 1 ] + normal[ 2 ] * temp[ 2 ];
|
||||
|
||||
/* trace */
|
||||
if (DirtTrace(origin, direction, dirtDepth.floatValue(), model, &traceHitdist, NULL, NULL)) {
|
||||
if (hittype_t::SOLID == DirtTrace(origin, direction, dirtDepth.floatValue(), model, &traceHitdist, NULL, NULL)) {
|
||||
gatherDirt += 1.0f - ooDepth * traceHitdist;
|
||||
}
|
||||
}
|
||||
|
|
@ -1910,14 +1910,14 @@ DirtForSample(const dmodel_t *model, const vec3_t origin, const vec3_t normal){
|
|||
direction[ 2 ] = myRt[ 2 ] * dirtVectors[ i ][ 0 ] + myUp[ 2 ] * dirtVectors[ i ][ 1 ] + normal[ 2 ] * dirtVectors[ i ][ 2 ];
|
||||
|
||||
/* trace */
|
||||
if (DirtTrace(origin, direction, dirtDepth.floatValue(), model, &traceHitdist, NULL, NULL)) {
|
||||
if (hittype_t::SOLID == DirtTrace(origin, direction, dirtDepth.floatValue(), model, &traceHitdist, NULL, NULL)) {
|
||||
gatherDirt += 1.0f - ooDepth * traceHitdist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* trace */
|
||||
if (DirtTrace(origin, direction, dirtDepth.floatValue(), model, &traceHitdist, NULL, NULL)) {
|
||||
if (hittype_t::SOLID == DirtTrace(origin, direction, dirtDepth.floatValue(), model, &traceHitdist, NULL, NULL)) {
|
||||
gatherDirt += 1.0f - ooDepth * traceHitdist;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ BSP_TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self)
|
|||
* or if it started in the void.
|
||||
* ============
|
||||
*/
|
||||
qboolean
|
||||
hittype_t
|
||||
BSP_DirtTrace(const vec3_t start, const vec3_t dirn, const vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
|
||||
{
|
||||
vec3_t stop;
|
||||
|
|
@ -666,7 +666,7 @@ BSP_DirtTrace(const vec3_t start, const vec3_t dirn, const vec_t dist, const dmo
|
|||
if (face_out) {
|
||||
*face_out = ti.face;
|
||||
}
|
||||
return !ti.hitsky;
|
||||
return ti.hitsky ? hittype_t::SKY : hittype_t::SOLID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -687,11 +687,11 @@ BSP_DirtTrace(const vec3_t start, const vec3_t dirn, const vec_t dist, const dmo
|
|||
if (face_out) {
|
||||
*face_out = ti.face;
|
||||
}
|
||||
return !ti.hitsky;
|
||||
return ti.hitsky ? hittype_t::SKY : hittype_t::SOLID;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return hittype_t::NONE;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -809,7 +809,7 @@ qboolean TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self)
|
|||
}
|
||||
|
||||
|
||||
qboolean DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
|
||||
hittype_t DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
|
||||
{
|
||||
#ifdef HAVE_EMBREE
|
||||
if (rtbackend == backend_embree) {
|
||||
|
|
|
|||
|
|
@ -291,14 +291,13 @@ qboolean Embree_TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *s
|
|||
}
|
||||
|
||||
//public
|
||||
qboolean Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
|
||||
hittype_t Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
|
||||
{
|
||||
RTCRay ray = SetupRay(start, dirn, dist, self);
|
||||
rtcIntersect(scene, ray);
|
||||
|
||||
if (ray.geomID == RTC_INVALID_GEOMETRY_ID
|
||||
|| ray.geomID == skygeom.geomID)
|
||||
return false;
|
||||
if (ray.geomID == RTC_INVALID_GEOMETRY_ID)
|
||||
return hittype_t::NONE;
|
||||
|
||||
if (hitdist_out) {
|
||||
*hitdist_out = ray.tfar;
|
||||
|
|
@ -319,5 +318,9 @@ qboolean Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, con
|
|||
*face_out = si.triToFace.at(ray.primID);
|
||||
}
|
||||
|
||||
return true;
|
||||
if (ray.geomID == skygeom.geomID) {
|
||||
return hittype_t::SKY;
|
||||
} else {
|
||||
return hittype_t::SOLID;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue