You discarded the std::min() and std::max() in the setup of the axis-aligned bounding box. Try this:
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:
Then do the test segment like 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);
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;
if (!shapes[i].TestSegment(body.GetXForm(), lambda, normal, segment, lambda[0]))
continue;