Original Post
I have set up 2 objects using the same meshinstance through a different owning object. As a result of code section 1, a name appears on the mouse when the object is hovered over... I hover my mouse over object 1, nothing. Over object 2, it shows up as object 1. Object 1 appears where it is intended, so does object 2. I move object 1 by any vector, it moves as expected. Transforms are functioning on the individual objects and applying as to be expected. What is odd is that when a tracepoint is put in for the intersect, both object 1 and 2 are returned. Now i can expect this to a degree because its the same meshinstance... but... on vista this behavior is being exhibited, on XP it is not... on XP the selection and hover functions both behave as expected and no issue occurs when clicking, the tracepoint also only returns one value... the code is identical. Code below: Leads to.... I cant see any reason for it... i'm scratching my head and would appreciate any help! [Edited by - Kalten on April 14, 2009 4:50:12 PM]
mouseOverObject = -1;
float bestDist = 100000.0f;
RAY ray = mouse.GetRay();
for (int i=0; i<(int)g_object.size(); i++)
{
float dist = -1.0f;
if(g_object.GetSelectable() == true)
{
d3ddev->SetTransform(D3DTS_WORLD, &g_object.GetWM());
dist = g_object.IntersectMesh(ray.org, ray.dir);
if(dist >= 0.0f && dist < bestDist)
{
mouseOverObject = i;
bestDist = dist;
}
}
}
float MESHINSTANCE::IntersectMesh(D3DXVECTOR3 rayOrg, D3DXVECTOR3 rayDir)
{
if(m_pMesh == NULL || m_pMesh->mesh == NULL) return -1.0f;
BOOL hit;
float dist;
D3DXIntersect(m_pMesh->mesh, &rayOrg, &rayDir, &hit, NULL, NULL, NULL, &dist, NULL, NULL);
if(hit) return dist;
else return -1.0f;
}