| 590 | } |
| 591 | |
| 592 | void NavMeshRuntime::DebugDraw() |
| 593 | { |
| 594 | ScopeLock lock(Locker); |
| 595 | const dtNavMesh* dtNavMesh = GetNavMesh(); |
| 596 | const int tilesCount = dtNavMesh ? dtNavMesh->getMaxTiles() : 0; |
| 597 | if (tilesCount == 0) |
| 598 | return; |
| 599 | Matrix worldToNavMesh, navMeshToWorld; |
| 600 | Matrix::RotationQuaternion(Properties.Rotation, worldToNavMesh); |
| 601 | Matrix::Invert(worldToNavMesh, navMeshToWorld); |
| 602 | |
| 603 | for (int tileIndex = 0; tileIndex < tilesCount; tileIndex++) |
| 604 | { |
| 605 | const dtMeshTile* tile = dtNavMesh->getTile(tileIndex); |
| 606 | if (!tile->header) |
| 607 | continue; |
| 608 | |
| 609 | #if 0 |
| 610 | // Debug draw tile bounds and owner scene name |
| 611 | BoundingBox tileBounds = *(BoundingBox*)&tile->header->bmin[0]; |
| 612 | DebugDraw::DrawWireBox(tileBounds, Color::CadetBlue); |
| 613 | // TODO: build map from tile coords to tile data to avoid this loop |
| 614 | for (const auto& e : _tiles) |
| 615 | { |
| 616 | if (e.X == tile->header->x && e.Y == tile->header->y && e.Layer == tile->header->layer) |
| 617 | { |
| 618 | if (e.NavMesh && e.NavMesh->GetScene()) |
| 619 | DebugDraw::DrawText(e.NavMesh->GetScene()->GetName(), tileBounds.Minimum + tileBounds.GetSize() * Float3(0.5f, 0.8f, 0.5f), Color::CadetBlue); |
| 620 | break; |
| 621 | } |
| 622 | } |
| 623 | #endif |
| 624 | |
| 625 | for (int i = 0; i < tile->header->polyCount; i++) |
| 626 | { |
| 627 | const dtPoly* poly = &tile->polys[i]; |
| 628 | if (poly->getType() != DT_POLYTYPE_GROUND) |
| 629 | continue; |
| 630 | |
| 631 | DrawPoly(this, navMeshToWorld, *tile, *poly); |
| 632 | } |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | #endif |
| 637 |
no test coverage detected