Hi !
I am using the iforce's raycast example but my raycast doesn't detect any collision with the bodies
This is the raycast function (copy/pasted)
I call this function right after 'world->Step(timeStep, velocityIterations, positionIterations); '
I see the line moving counter-clockwise but without modifying it's length when intersects a body
Could you tell me what's to be fixed ?
I am using the iforce's raycast example but my raycast doesn't detect any collision with the bodies
This is the raycast function (copy/pasted)
Code: Select all
void drawRay( b2Vec2 p1, b2Vec2 p2 )
{
//set up input
b2RayCastInput input;
input.p1 = p1;
input.p2 = p2;
input.maxFraction = 1;
float closestFraction = 1;
b2Vec2 intersectionNormal(0,0);
for (b2Body* b = world->GetBodyList(); b; b = b->GetNext()) {
for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) {
b2RayCastOutput output;
if ( ! f->RayCast( &output, input,0 ) )
continue;
if ( output.fraction < closestFraction ) {
closestFraction = output.fraction;
intersectionNormal = output.normal;
}
}
}
b2Vec2 intersectionPoint = p1 + closestFraction * (p2 - p1);
//draw a line
al_draw_line(p1.x,p1.y,intersectionPoint.x,intersectionPoint.y,al_map_rgb(255,0,0),1);
}I call this function right after 'world->Step(timeStep, velocityIterations, positionIterations); '
I see the line moving counter-clockwise but without modifying it's length when intersects a body
Could you tell me what's to be fixed ?