Skip to content

NavigationServer2D.bake_from_source_geometry_data handles obstructions improperly #85550

Description

@spikeyarmaku

Godot version

v4.2.stable.official [46dc277]

System information

Godot v4.2.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated Radeon RX Vega (Advanced Micro Devices, Inc.; 31.0.21905.1001) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

I want to create a navmesh from code. The setup is this:

  • A rectangle of size 100x100, starting at (0, 0), marking a traversable area
  • Another rectangle of the same size, starting at (-20, -20), marking an obstacle

Both rectangles have the same winding.

Expected result: an L-shaped traversable area
Actual result: an empty navmesh

This is the code that is responsible for creating the navmesh:

func _ready():
    var rect1 = [Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100)]
    var rect2 = [Vector2(-20, -20), Vector2(80, -20), Vector2(80, 80), Vector2(-20, 80)]
    var src = NavigationMeshSourceGeometryData2D.new()
    var navpoly = NavigationPolygon.new()

    src.add_traversable_outline(rect1)
    src.add_obstruction_outline(rect2)
    NavigationServer2D.bake_from_source_geometry_data(navpoly, src)

    $NavigationRegion2D.navigation_polygon = navpoly

Steps to reproduce

  • Open the attached project
  • Enable Debug -> Visible navigation
  • Run the project

There is a Line2D surrounding the area where the navmesh should appear.

Minimal reproduction project

polygon2d_bug.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions