Add some snug-fit tests and fix the uncovered bugs.

The tests involve the box fitting into a hole with zero slop (this would be
impossible with point clipping).
This commit is contained in:
Bill Currie 2011-11-28 19:07:00 +09:00
parent 985667ecba
commit 50b08c98fa
2 changed files with 68 additions and 7 deletions

View file

@ -97,7 +97,6 @@ check_in_leaf (hull_t *hull, trace_t *trace, clipleaf_t *leaf, plane_t *plane,
{
clipport_t *portal;
int side;
int miss = 0;
int i;
int planenum;
plane_t cutplane;
@ -107,12 +106,17 @@ check_in_leaf (hull_t *hull, trace_t *trace, clipleaf_t *leaf, plane_t *plane,
planenum = plane - hull->planes;
cutplane.type = 3; // generic plane
v_n = DotProduct (vel, plane->normal);
if (!v_n) {
//FIXME is this correct? The assumption is that if we got to a leaf
//travelliing parallel to its plane, then we have to be in the leaf
return 1;
}
for (portal = leaf->portals; portal; portal = portal->next[side]) {
side = portal->leafs[1] == leaf;
if (portal->planenum != planenum)
continue;
for (i = 0; !miss && i < portal->winding->numpoints; i++) {
for (i = 0; i < portal->winding->numpoints; i++) {
point = portal->winding->points[i];
edge = portal->edges->points[i];
// so long as the plane distance and offset are calculated using
@ -122,12 +126,15 @@ check_in_leaf (hull_t *hull, trace_t *trace, clipleaf_t *leaf, plane_t *plane,
cutplane.dist = DotProduct (cutplane.normal, point);
dist = PlaneDiff (org, &cutplane);
offset = calc_offset (trace, &cutplane);
if (v_n >= 0)
miss = dist >= offset;
else
miss = dist <= -offset;
if (v_n > 0) {
if (dist >= offset)
break;
} else {
if (dist <= -offset)
break;
}
}
if (!miss)
if (i == portal->winding->numpoints)
return 1;
}
return 0;