Skip to content

Commit

Permalink
Remove 2 debug prints and fix UnitPlacementUtils
Browse files Browse the repository at this point in the history
 - Because of the now more detailed NavMesh, the structure placement sometimes bugged out in areas with small navigation triangles because the default tolerance of the .is_equal_approx function was to small.
  • Loading branch information
kbendler authored and Scony committed Jan 14, 2024
1 parent b7b05d0 commit a7193af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion source/match/Match.gd
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,4 @@ func _on_unit_died(unit):
navigation.update_terrain()

func _on_resource_depleted():
print("die")
navigation.update_terrain()
1 change: 0 additions & 1 deletion source/match/Navigation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func rebake(map):

func update_terrain():
terrain.rebake(true)
print("update_terrain")

func _clear_static_obstacles():
for static_obstacle in _static_obstacles:
Expand Down
8 changes: 5 additions & 3 deletions source/match/utils/UnitPlacementUtils.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
enum { VALID, COLLIDES_WITH_AGENT, NOT_NAVIGABLE }

const epsilon = 0.05 # Custom approximation variable check for terrain


static func find_valid_position_radially(
starting_position: Vector3, radius: float, navigation_map_rid: RID, scene_tree
Expand Down Expand Up @@ -79,14 +81,14 @@ static func validate_agent_placement_position(position, radius, existing_units,
position + Vector3(x, 0, z).normalized() * radius
)
for point_expected_to_be_navigable in points_expected_to_be_navigable:
if not (point_expected_to_be_navigable * Vector3(1, 0, 1)).is_equal_approx(
if not (point_expected_to_be_navigable * Vector3(1, 0, 1)).distance_to(
(
NavigationServer3D.map_get_closest_point(
navigation_map_rid, point_expected_to_be_navigable
)
* Vector3(1, 0, 1)
)
):
)
) < epsilon :
return NOT_NAVIGABLE
return VALID

Expand Down

0 comments on commit a7193af

Please sign in to comment.