I need to use this method in order to prevent my code from making an unwanted reference to a Vec2 object. This is because the rayCast callback function uses the same point variable.
I looked at the documentation but I couldn't find it (I could only find it on libGDX https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html#cpy--)
class RayCastClosestCallback implements RayCastCallback {
boolean m_hit;
Vec2 m_point;
Vec2 m_normal;
float m_fraction;
void reset(){
m_hit = false;
m_point = new Vec2();
m_normal = new Vec2();
m_fraction = 1;
}
float reportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction) {
/*
public float reportFixture() - triggers when collision with ray occurs
returns distance of collision
*/
m_hit = true;
m_point = point.cpy(); // this returns an error : "The function "cpy()" does not exist"
m_normal = normal;
m_fraction = fraction;
return 1;//fraction;
}
}