sklug
14-10-2006 23:25:34
There's definitely something squirrely going on with RaySceneQueries. This seems to have been introduced recently, as I don't think I was having any issues before re-syncing with CVS this week. I'm having two seperate problems. One problem happens when the start point of the ray is above the world height. All the returned intersections have a 0 y coord. I'm not grokking the code fully, but there's something odd in IntersectSegmentTerrain(). Here's a snippet:
I'm not positive of the intent here, but something is odd when you create a plane at the max height, normal to the y axis, then never use it.
The second problem is when the start point of the ray is below the max height. There seems to be issues when crossing page boundaries. That is, when the start is in one page, and the intersection is in another. As long as both are in the same page, everything works. But going from a page with positive x to negative x in world coords seems to have sticking points, where the intersection returned stays on your side of the page boundary until the intersection is WELL into the next page. It's a little hard to describe.
In any case, I started looking at these bugs, but realized I was getting very distracted from working on the decals (which are pretty close to working with LOD!), so figured I'd toss it up on the boards.
sklug
const Real maxHeight = mData2DManager->getMaxHeight ();
if (raystart.y > maxHeight)
{
// find ray to highest terrain plane intersection
// so that ray begins at a pertinent place.
Plane plane(Vector3::UNIT_Y, maxHeight); // getOption()->offset ?
const Real denom = Vector3::UNIT_Y.dotProduct(raydir);
if (Math::Abs(denom) < std::numeric_limits<Real>::epsilon())
{
// Parallel ?
*rayresult = Vector3(-1.0f, -1.0f, -1.0f);
return false;
}
const Real nom = Vector3::UNIT_Y.dotProduct(raystart);
const Real t = -(nom/denom);
raystart += raydir*t;
if (raystart.y <= mData2DManager->getInterpolatedWorldHeight(raystart.x, raystart.z))
{
*rayresult = raystart;
return true;
}
}
I'm not positive of the intent here, but something is odd when you create a plane at the max height, normal to the y axis, then never use it.
The second problem is when the start point of the ray is below the max height. There seems to be issues when crossing page boundaries. That is, when the start is in one page, and the intersection is in another. As long as both are in the same page, everything works. But going from a page with positive x to negative x in world coords seems to have sticking points, where the intersection returned stays on your side of the page boundary until the intersection is WELL into the next page. It's a little hard to describe.
In any case, I started looking at these bugs, but realized I was getting very distracted from working on the decals (which are pretty close to working with LOD!), so figured I'd toss it up on the boards.
sklug