mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Rewrite the intersection tests.
The early bailout proved to be difficult to get right, so don't bother.
This commit is contained in:
parent
98c9e4f8c0
commit
56956fc370
1 changed files with 36 additions and 24 deletions
|
@ -341,17 +341,20 @@ static int
|
|||
set_test_intersect_n_n (const set_t *s1, const set_t *s2)
|
||||
{
|
||||
unsigned i, end;
|
||||
unsigned intersection = 0;
|
||||
set_test_e rval = set_equiv;
|
||||
|
||||
end = min (s1->size, s2->size) / BITS;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (s1->map[i] != s2->map[i]) {
|
||||
if (s1->map[i] & s2->map[i])
|
||||
return set_intersecting;
|
||||
else
|
||||
unsigned m1 = s1->map[i];
|
||||
unsigned m2 = s2->map[i];
|
||||
|
||||
intersection |= m1 & m2;
|
||||
if (m1 != m2)
|
||||
rval = set_intersecting;
|
||||
}
|
||||
if (rval == set_intersecting && !intersection)
|
||||
rval = set_disjoint;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -359,17 +362,20 @@ static int
|
|||
set_test_intersect_n_i (const set_t *s1, const set_t *s2)
|
||||
{
|
||||
unsigned i, end;
|
||||
unsigned intersection = 0;
|
||||
set_test_e rval = set_equiv;
|
||||
|
||||
end = min (s1->size, s2->size) / BITS;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (s1->map[i] != ~s2->map[i]) {
|
||||
if (s1->map[i] & ~s2->map[i])
|
||||
return set_intersecting;
|
||||
else
|
||||
unsigned m1 = s1->map[i];
|
||||
unsigned m2 = ~s2->map[i];
|
||||
|
||||
intersection |= m1 & m2;
|
||||
if (m1 != m2)
|
||||
rval = set_intersecting;
|
||||
}
|
||||
if (rval == set_intersecting && !intersection)
|
||||
rval = set_disjoint;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -377,17 +383,20 @@ static int
|
|||
set_test_intersect_i_n (const set_t *s1, const set_t *s2)
|
||||
{
|
||||
unsigned i, end;
|
||||
unsigned intersection = 0;
|
||||
set_test_e rval = set_equiv;
|
||||
|
||||
end = min (s1->size, s2->size) / BITS;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (~s1->map[i] != s2->map[i]) {
|
||||
if (~s1->map[i] & s2->map[i])
|
||||
return set_intersecting;
|
||||
else
|
||||
unsigned m1 = ~s1->map[i];
|
||||
unsigned m2 = s2->map[i];
|
||||
|
||||
intersection |= m1 & m2;
|
||||
if (m1 != m2)
|
||||
rval = set_intersecting;
|
||||
}
|
||||
if (rval == set_intersecting && !intersection)
|
||||
rval = set_disjoint;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -395,17 +404,20 @@ static int
|
|||
set_test_intersect_i_i (const set_t *s1, const set_t *s2)
|
||||
{
|
||||
unsigned i, end;
|
||||
unsigned intersection = 0;
|
||||
set_test_e rval = set_equiv;
|
||||
|
||||
end = min (s1->size, s2->size) / BITS;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (~s1->map[i] != ~s2->map[i]) {
|
||||
if (~s1->map[i] & ~s2->map[i])
|
||||
return set_intersecting;
|
||||
else
|
||||
unsigned m1 = ~s1->map[i];
|
||||
unsigned m2 = ~s2->map[i];
|
||||
|
||||
intersection |= m1 & m2;
|
||||
if (m1 != m2)
|
||||
rval = set_intersecting;
|
||||
}
|
||||
if (rval == set_intersecting && !intersection)
|
||||
rval = set_disjoint;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue