if SERVER
then
local nav_visualize
= CreateConVar(
"nav_visualize",
"0",
0,
"Visualize navmesh" )
local LastNavmeshViz
= 0
hook.
Add(
"Think",
"navmesh_visualize",
function()
if (
!nav_visualize:
GetBool() )
then return end
if (
CurTime()
- LastNavmeshViz
< 0.1 )
then return end
local time
= math.
min(
CurTime()
- LastNavmeshViz
+ 0.02,
1 )
LastNavmeshViz
= CurTime()
for id, navArea
in pairs(
navmesh.
GetAllNavAreas() )
do
local color
= Color(
255,
255,
255,
40 + (
1-navArea:
GetLightIntensity() )
* 200 )
color:
SetBrightness(
navArea:
GetLightIntensity() )
local ignoreDepth
= nav_visualize:
GetInt()
> 1 && Entity(
1):
GetPos():
Distance(
navArea:
GetCenter())
< 1000
local corner1
= navArea:
GetCorner(
0 )
+ Vector(
0,
0,
1 )
local corner2
= navArea:
GetCorner(
1 )
+ Vector(
0,
0,
1 )
local corner3
= navArea:
GetCorner(
2 )
+ Vector(
0,
0,
1 )
local corner4
= navArea:
GetCorner(
3 )
+ Vector(
0,
0,
1 )
debugoverlay.
Triangle( corner3, corner2, corner1, time, color, ignoreDepth )
debugoverlay.
Triangle( corner1, corner4, corner3, time, color, ignoreDepth )
end
end)
end