Tighten spatial GPS road classification
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1241,13 +1241,18 @@ bool TryLookupGpsSpatialEdgeClass(void* aCurrentState, void* aNeighborState, cha
|
||||
const auto midpointMapY = (current.z + neighbor.z) * 0.5f;
|
||||
|
||||
// Search states are (world X, height, world Y); route producer query vectors use (X, Y, Z, W).
|
||||
const auto midpointClass = LookupGpsSpatialRoadClass(midpointX, midpointMapY);
|
||||
if (midpointClass != '.')
|
||||
{
|
||||
aCode = midpointClass;
|
||||
return true;
|
||||
}
|
||||
|
||||
aCode = '.';
|
||||
const std::array candidates = {
|
||||
LookupGpsSpatialRoadClass(midpointX, midpointMapY),
|
||||
LookupGpsSpatialRoadClass(current.x, current.z),
|
||||
LookupGpsSpatialRoadClass(neighbor.x, neighbor.z),
|
||||
};
|
||||
|
||||
aCode = '.';
|
||||
for (const auto candidate : candidates)
|
||||
{
|
||||
if (GpsSpatialRoadClassRank(candidate) > GpsSpatialRoadClassRank(aCode))
|
||||
@@ -1958,6 +1963,32 @@ void AppendGpsRouteProducerQuerySummary(std::ostringstream& aLine, void* aQuery)
|
||||
AppendUint32Field(aLine, "query_flagsa8", aQuery, 0xA8);
|
||||
}
|
||||
|
||||
bool ShouldLogGpsRouteProducerStats(void* aQuery)
|
||||
{
|
||||
if (!aQuery)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector4Value start{};
|
||||
Vector4Value end{};
|
||||
if (!TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aQuery) + 0x00), start) ||
|
||||
!TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(aQuery) + 0x10), end))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float radius = 0.0f;
|
||||
TryReadFloatField(aQuery, 0x78, radius);
|
||||
const auto* routeContext = ReadPointerField(aQuery, 0x98);
|
||||
const auto deltaX = end.x - start.x;
|
||||
const auto deltaY = end.y - start.y;
|
||||
const auto deltaZ = end.z - start.z;
|
||||
const auto distanceSquared = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
||||
|
||||
return distanceSquared >= 4.0f || radius != 0.0f || routeContext != nullptr;
|
||||
}
|
||||
|
||||
void AppendVector3ListCandidate(std::ostringstream& aLine, const char* aPrefix, void* aObject, uintptr_t aDataOffset,
|
||||
uintptr_t aCountOffset, uintptr_t aStride)
|
||||
{
|
||||
@@ -4413,7 +4444,8 @@ int32_t DetourGpsRouteProducer(void* aGraph, void* aQuery, void* aOutResult)
|
||||
{
|
||||
std::lock_guard lock(gGpsCostLogMutex);
|
||||
callCount = gGpsRouteProducerLogCount++;
|
||||
shouldLog = (kEnableGpsLocalSearchTraceHooks || kEnableGpsSpatialEdgeWeightPatchStats) && callCount < kMaxCalls;
|
||||
shouldLog = kEnableGpsLocalSearchTraceHooks ||
|
||||
(kEnableGpsSpatialEdgeWeightPatchStats && callCount < kMaxCalls && ShouldLogGpsRouteProducerStats(aQuery));
|
||||
}
|
||||
|
||||
if (shouldLog)
|
||||
|
||||
Reference in New Issue
Block a user