How do I limit raycasting?

Started by
1 comment, last by Medo Mex 10 years, 11 months ago
Lets say that I have a ray starting from point A to point B as well as a LIMITED distance.
How do I make sure that the ray is always limited to the distance?

D3DXVECTOR3 vRayFrom(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vRayTo(0.0f, 1000.0f, 5000.0f);
float limitedDistance = 50.0f; // The distance is only limited to 50.0f so the actual ray should be much shorter
Raycasting(vRayFrom, vRayTo, limitedDistance);

Advertisement

auto rayDir  = vRayTo - vRayFrom;
D3DXVec3Normalize(&rayDir, &rayDir);
auto vRayEnd = vRayFrom + rayDir * limitedDistance;

Thanks,

This topic is closed to new replies.

Advertisement