You are doing something wrong.
When I stand in canyon, and move camera into canyon I get these results:
p0 {x=306.86395 y=1466.9313 z=50.000000 }
p1 {x=588.41559 y=-508.20447 z=-114.88428 }
Newton detects that Ray hits something, and my dist becomes 0.63704562f.
When I stand on one of big triangles, and move camera below terrain surface, I get these results:
p0 {x=-149.54211 y=1549.9939 z=50.000000 }
p1 {x=-2045.9237 y=1316.7340 z=-566.03864 }
In this case Newton doesn't detect Ray hit, and dist remains 2.
I can even draw both of these lines
- Code: Select all
//Vertex structure
struct D3DVERTEX {
Vector3 p;
DWORD color;
D3DVERTEX(Vector3 v, DWORD c){
p = v;
color = c;
}
};
//Drawing
vector<D3DVERTEX> vec;
device->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
vec.push_back(D3DVERTEX(Vector3(306.86395, 1466.9313, 50.000000), 0xFFFF0000));
vec.push_back(D3DVERTEX(Vector3(588.41559, -508.20447, -114.88428), 0xFFFF0000));
device->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vec[0], sizeof(D3DVERTEX));
vec.clear();
vec.push_back(D3DVERTEX(Vector3(-149.54211, 1549.9939, 50.000000), 0xFFFF0000));
vec.push_back(D3DVERTEX(Vector3(-2045.9237, 1316.7340, -566.03864), 0xFFFF0000));
device->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vec[0], sizeof(D3DVERTEX));
vec.clear();
In screenshot it's very well visible, that both rays go through terrain:
http://dl.dropbox.com/u/2637453/nwtn/Two%20Rays.PNGBut only left one gets detected as it hit something.