How to do individual ray casting hit test

Hi,

In my game I perform ray casting. My callback class is displayed below. I have setup a Ray class that I instantize for each ray I want to cast. When I want to check for a hit I check the m_hit property like if (rayHitCallback.m_hit == true).

The problem is that all my Ray instances seem to react to this instead of just the one particular ray that had any contact. How would I setup ray casting so that I can treat the callback results individually instead of "globally"?

Thank you

Code:
#ifndef RAY_CAST_H
#define RAY_CAST_H

#include "Box2D.h"
#include "Entity.h"
#import "Player.h"

//
// This class captures the closest hit shape.
//

class RayCastCallback : public b2RayCastCallback{
   
public:RayCastCallback(){
   
   m_fixture = NULL;
   m_hit = false;
   
}
   b2Fixture* m_fixture;
    b2Vec2 m_point;
    b2Vec2 m_normal;
    float32 m_fraction;
   bool m_hit;
   
    float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction){

        m_fixture = fixture;
        m_point = point;
        m_normal = normal;
        m_fraction = fraction;
   m_hit = true;

        return fraction;
    }
};

#endif
Create a separate instance of your ray cast callback class for each ray that you cast.
Ah, of course that makes sense. Thanks Erin.

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