one body see another?

You discarded the std::min() and std::max() in the setup of the axis-aligned bounding box. Try this:
Code:
aabb.lowerBound.Set( Math.min(segment.p1.x, segment.p2.x) - 1, Math.min(segment.p1.y, segment.p2.y) - 1);
aabb.upperBound.Set( Math.max(segment.p1.x, segment.p2.x) + 1, Math.max(segment.p1.y, segment.p2.y) + 1);


By the way, you're currently discarding the lambda return value from TestSegment by using an anonymous temporary array. Define lambda as an array like this:
Code:
var lambda:Array = new Array(1.0)

Then do the test segment like this:
Code:
// ray-test
if (!shapes[i].TestSegment(body.GetXForm(), lambda, normal, segment, lambda[0]))
    continue;
just wondering, are the lines used for the ground in those pictures actually made up of very long thin boxes?

I had a similar problem where TestSegment would give false results for this case. Maybe you could try the tentative 'fix' that I'm using.
I have not used testSegment but I do intend to use them extensively in the future. I'm basically operating on the assumption that they will work correctly. Sorry I can't provide any tips at the moment.

Original thread: https://box2d.org/forum/viewtopic.php?t=1045