Ralith / sieve-tree

6 stars 1 forks source link

Some intersections are missed #8

Closed grovesNL closed 6 days ago

grovesNL commented 6 days ago

I haven't dug into this much yet but certain intersections can be missed:

let mut t = SieveTree::<2, 2, Bounds<2>>::new();
let b1 = Bounds {
    min: [30., 30.,],
    max: [31., 31.],
};
let b2 = Bounds {
    min: [50., 50.,],
    max: [51., 51.],
};
t.insert(b1, b1);
t.insert(b2, b2);
assert_eq!(
    t.intersections(Bounds {
        min: [0.0, 0.0],
        max: [100., 100.]
    })
    .count(),
    2
);

fails with a count of 0 instead of the expected 2.

I guess it depends on where the inserted bounds end up in the tree, because I didn't notice any clear pattern with the values. Changing b2's max like this:

let b2 = Bounds {
    min: [50., 50.,],
    max: [61., 61.],
};

results in a count of 1 instead of 0.

Changing both b1 and b2 to some other values:

let b1 = Bounds {
    min: [30., 30.,],
    max: [41., 41.],
};
let b2 = Bounds {
    min: [50., 50.,],
    max: [61., 61.],
};

results in the expected count of 2.

Changing b2 to be an even bigger range makes it fail again though (count of 1 again):

let b1 = Bounds {
    min: [30., 30.,],
    max: [41., 41.],
};
let b2 = Bounds {
    min: [50., 50.,],
    max: [71., 71.],
};
Ralith commented 6 days ago

This was a really dumb bug. Fixed in 7e5d64979ea5964fcfd7b3fa1629ec2f5ee6c736.