light: add a EdgePlanes_PointInside() function to bsputils.{hh,cc}
This commit is contained in:
parent
c035907ff8
commit
be3c84ec98
|
|
@ -217,3 +217,15 @@ Face_MakeInwardFacingEdgePlanes(const bsp2_t *bsp, const bsp2_dface_t *face, pla
|
|||
dest->dist = DotProduct(dest->normal, v0);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
EdgePlanes_PointInside(const bsp2_dface_t *face, const plane_t *edgeplanes, const vec3_t point)
|
||||
{
|
||||
for (int i=0; i<face->numedges; i++) {
|
||||
vec_t planedist = DotProduct(point, edgeplanes[i].normal) - edgeplanes[i].dist;
|
||||
if (planedist < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,5 +37,6 @@ const dmodel_t *BSP_DModelForModelString(const bsp2_t *bsp, const std::string &s
|
|||
vec_t Plane_Dist(const vec3_t point, const dplane_t *plane);
|
||||
bool Light_PointInSolid(const bsp2_t *bsp, const vec3_t point );
|
||||
void Face_MakeInwardFacingEdgePlanes(const bsp2_t *bsp, const bsp2_dface_t *face, plane_t *out);
|
||||
bool EdgePlanes_PointInside(const bsp2_dface_t *face, const plane_t *edgeplanes, const vec3_t point);
|
||||
|
||||
#endif /* __COMMON_BSPUTILS_HH__ */
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ typedef struct faceinfo_s {
|
|||
plane_t plane;
|
||||
|
||||
const char *texturename;
|
||||
const bsp2_dface_t *face;
|
||||
} faceinfo_t;
|
||||
|
||||
static tnode_t *tnodes;
|
||||
|
|
@ -187,6 +188,7 @@ static inline bool SphereCullPoint(const faceinfo_t *info, const vec3_t point)
|
|||
static void
|
||||
MakeFaceInfo(const bsp2_t *bsp, const bsp2_dface_t *face, faceinfo_t *info)
|
||||
{
|
||||
info->face = face;
|
||||
info->numedges = face->numedges;
|
||||
info->edgeplanes = (plane_t *) calloc(face->numedges, sizeof(plane_t));
|
||||
|
||||
|
|
@ -337,16 +339,7 @@ SampleTexture(const bsp2_dface_t *face, const bsp2_t *bsp, const vec3_t point)
|
|||
static inline qboolean
|
||||
TestHitFace(const faceinfo_t *fi, const vec3_t point)
|
||||
{
|
||||
for (int i=0; i<fi->numedges; i++)
|
||||
{
|
||||
/* faces toward the center of the face */
|
||||
const plane_t *edgeplane = &fi->edgeplanes[i];
|
||||
|
||||
vec_t dist = DotProduct(point, edgeplane->normal) - edgeplane->dist;
|
||||
if (dist < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return EdgePlanes_PointInside(fi->face, fi->edgeplanes, point);
|
||||
}
|
||||
|
||||
static inline bsp2_dface_t *
|
||||
|
|
|
|||
Loading…
Reference in New Issue