Basically I'm raycasting to an object and bouncing another ray off of the intersection point (in a certain direction). This is done recursively because I want it to keep bouncing between objects until no more objects are hit. "createRay" is called and it all works correctly for the first ray, it is then called recursively for the ray that bounces off. The raycast from here just passes straight through all objects for some reason.
I've got an image to illustrate what I mean:

Heres the code I'm using for the callback:
class RayCastClosestCallback : public b2RayCastCallback
{
public:
RayCastClosestCallback()
{
m_hit = false;
}
float32 ReportFixture( b2Fixture* fixture, const b2Vec2& point,
const b2Vec2& normal, float32 fraction)
{
m_bodySource = fixture->GetBody();
m_hit = true;
m_point = point;
m_normal = normal;
return fraction;
}
bool m_hit;
b2Vec2 m_point;
b2Vec2 m_normal;
b2Body* m_bodySource;
};
and this is the code I'm using to create the ray:
void createRay( b2Vec2 p1, b2Vec2 p2)
{
RayCastClosestCallback rayCastCallback;
world->RayCast(&rayCastCallback, p1, p2);
b2Body *closestBody;
if(rayCastCallback.m_hit) {
NSLog(@"Hit");
closestBody = rayCastCallback.m_bodySource;
float hitx = rayCastCallback.m_point.x;
float hity = rayCastCallback.m_point.y;
[pointArray addObject:[NSValue valueWithCGPoint:CGPointMake(p1.x, p1.y)]];
[pointArray addObject:[NSValue valueWithCGPoint:CGPointMake(hitx * 32, hity * 32)]];
createRay(b2Vec2(hitx * 32, hity * 32), b2Vec2(p1.x + 30, p1.y));
}
else{
NSLog(@"No hit");
[pointArray addObject:[NSValue valueWithCGPoint:CGPointMake(p1.x, p1.y)]];
[pointArray addObject:[NSValue valueWithCGPoint:CGPointMake(p2.x, p2.y)]];
}
}
If anyone could help me pinpoint the error then I would be eternally grateful, I'm really stumped!