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;
|
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).
|
// 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 = {
|
const std::array candidates = {
|
||||||
LookupGpsSpatialRoadClass(midpointX, midpointMapY),
|
|
||||||
LookupGpsSpatialRoadClass(current.x, current.z),
|
LookupGpsSpatialRoadClass(current.x, current.z),
|
||||||
LookupGpsSpatialRoadClass(neighbor.x, neighbor.z),
|
LookupGpsSpatialRoadClass(neighbor.x, neighbor.z),
|
||||||
};
|
};
|
||||||
|
|
||||||
aCode = '.';
|
|
||||||
for (const auto candidate : candidates)
|
for (const auto candidate : candidates)
|
||||||
{
|
{
|
||||||
if (GpsSpatialRoadClassRank(candidate) > GpsSpatialRoadClassRank(aCode))
|
if (GpsSpatialRoadClassRank(candidate) > GpsSpatialRoadClassRank(aCode))
|
||||||
@@ -1958,6 +1963,32 @@ void AppendGpsRouteProducerQuerySummary(std::ostringstream& aLine, void* aQuery)
|
|||||||
AppendUint32Field(aLine, "query_flagsa8", aQuery, 0xA8);
|
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,
|
void AppendVector3ListCandidate(std::ostringstream& aLine, const char* aPrefix, void* aObject, uintptr_t aDataOffset,
|
||||||
uintptr_t aCountOffset, uintptr_t aStride)
|
uintptr_t aCountOffset, uintptr_t aStride)
|
||||||
{
|
{
|
||||||
@@ -4413,7 +4444,8 @@ int32_t DetourGpsRouteProducer(void* aGraph, void* aQuery, void* aOutResult)
|
|||||||
{
|
{
|
||||||
std::lock_guard lock(gGpsCostLogMutex);
|
std::lock_guard lock(gGpsCostLogMutex);
|
||||||
callCount = gGpsRouteProducerLogCount++;
|
callCount = gGpsRouteProducerLogCount++;
|
||||||
shouldLog = (kEnableGpsLocalSearchTraceHooks || kEnableGpsSpatialEdgeWeightPatchStats) && callCount < kMaxCalls;
|
shouldLog = kEnableGpsLocalSearchTraceHooks ||
|
||||||
|
(kEnableGpsSpatialEdgeWeightPatchStats && callCount < kMaxCalls && ShouldLogGpsRouteProducerStats(aQuery));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldLog)
|
if (shouldLog)
|
||||||
|
|||||||
@@ -300,8 +300,8 @@ def main() -> int:
|
|||||||
type=Path,
|
type=Path,
|
||||||
default=Path("red4ext/EdgeWeightGPS/src/GeneratedSpatialRoadGrid.hpp"),
|
default=Path("red4ext/EdgeWeightGPS/src/GeneratedSpatialRoadGrid.hpp"),
|
||||||
)
|
)
|
||||||
parser.add_argument("--cell-size", type=float, default=32.0)
|
parser.add_argument("--cell-size", type=float, default=16.0)
|
||||||
parser.add_argument("--inflate-cells", type=int, default=1)
|
parser.add_argument("--inflate-cells", type=int, default=0)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
lanes = load_lanes(args.traffic_json)
|
lanes = load_lanes(args.traffic_json)
|
||||||
|
|||||||
Reference in New Issue
Block a user