mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Fix Pick distance calculation
This commit is contained in:
parent
6531ac4083
commit
45c91d4ca7
@ -802,16 +802,21 @@ HRESULT Direct3DRMViewportImpl::Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY*
|
|||||||
ComputeFrameWorldMatrix(frame, worldMatrix);
|
ComputeFrameWorldMatrix(frame, worldMatrix);
|
||||||
D3DRMBOX worldBox = ComputeTransformedAABB(box, worldMatrix);
|
D3DRMBOX worldBox = ComputeTransformedAABB(box, worldMatrix);
|
||||||
|
|
||||||
float distance = FLT_MAX;
|
float boxDist = FLT_MAX;
|
||||||
if (RayIntersectsBox(pickRay, worldBox, distance) &&
|
|
||||||
RayIntersectsMeshTriangles(pickRay, *mesh, worldMatrix, distance)) {
|
|
||||||
auto* arr = new Direct3DRMFrameArrayImpl();
|
|
||||||
for (IDirect3DRMFrame* f : path) {
|
|
||||||
arr->AddElement(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
PickRecord rec = {visual, arr, {distance}};
|
// Check box first as an optimization
|
||||||
hits.push_back(rec);
|
if (RayIntersectsBox(pickRay, worldBox, boxDist)) {
|
||||||
|
float meshDist = FLT_MAX;
|
||||||
|
|
||||||
|
if (RayIntersectsMeshTriangles(pickRay, *mesh, worldMatrix, meshDist)) {
|
||||||
|
auto* arr = new Direct3DRMFrameArrayImpl();
|
||||||
|
for (IDirect3DRMFrame* f : path) {
|
||||||
|
arr->AddElement(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
PickRecord rec = {visual, arr, {meshDist}};
|
||||||
|
hits.push_back(rec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mesh->Release();
|
mesh->Release();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user