From 67736ae7d50a06d6e722314f2701101a4ff1bd86 Mon Sep 17 00:00:00 2001 From: Richard Fine Date: Thu, 1 May 2014 21:55:57 +0100 Subject: [PATCH] Include hit edge index in dtRaycastHit. This makes it simpler to investigate exactly what is blocking a ray - for example, if an agent cannot move onto a polygon due to QueryFilter flags, then this provides a way for the agent to find out which flags it needs to have and to perform a state change which alters its movement flags. --- Detour/Include/DetourNavMeshQuery.h | 3 +++ Detour/Source/DetourNavMeshQuery.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Detour/Include/DetourNavMeshQuery.h b/Detour/Include/DetourNavMeshQuery.h index c7b360d..79c6762 100644 --- a/Detour/Include/DetourNavMeshQuery.h +++ b/Detour/Include/DetourNavMeshQuery.h @@ -131,6 +131,9 @@ struct dtRaycastHit /// hitNormal The normal of the nearest wall hit. [(x, y, z)] float hitNormal[3]; + + /// The index of the edge on the final polygon where the wall was hit. + int hitEdgeIndex; /// Pointer to an array of reference ids of the visited polygons. [opt] dtPolyRef* path; diff --git a/Detour/Source/DetourNavMeshQuery.cpp b/Detour/Source/DetourNavMeshQuery.cpp index 5fbc83e..7b5cccc 100644 --- a/Detour/Source/DetourNavMeshQuery.cpp +++ b/Detour/Source/DetourNavMeshQuery.cpp @@ -2420,6 +2420,9 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons hit->pathCount = n; return status; } + + hit->hitEdgeIndex = segMax; + // Keep track of furthest t so far. if (tmax > hit->t) hit->t = tmax;