Skip to content

Commit

Permalink
Merge pull request #194 from TheDuckCow/193-imit-most-errors-and-warn…
Browse files Browse the repository at this point in the history
…ings

4.x Reducing console errors on adding RoadPoint via menu or click
  • Loading branch information
TheDuckCow authored Sep 29, 2024
2 parents 43093ca + 1ebc8d9 commit 1b88b6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions addons/road-generator/nodes/road_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@ func on_point_update(point:RoadPoint, low_poly:bool) -> void:
return
# Update warnings for this or connected containers
if point.is_on_edge():
var prior = point.get_prior_rp()
var next = point.get_next_rp()
#var prior = point.get_prior_rp()
#var next = point.get_next_rp()
# TODO: Need to trigger transform updates on these nodes,
# without triggering emit_transform etc, these turn into infinite loops or godot crashes
#if is_instance_valid(prior) and prior.container != self:
Expand Down
14 changes: 7 additions & 7 deletions addons/road-generator/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func _handle_gui_add_mode(camera: Camera3D, event: InputEvent) -> int:
point = null
target = null

if point and target:
if is_instance_valid(point) and is_instance_valid(target):
_overlay_hovering_from = camera.unproject_position(target.global_transform.origin)
_overlay_rp_hovering = point
_overlay_hovering_pos = camera.unproject_position(point.global_transform.origin)
Expand Down Expand Up @@ -1053,8 +1053,6 @@ func _add_next_rp_on_click_do(pos: Vector3, nrm: Vector3, selection: Node, paren

# Update rotation along the initially picked axis.
elif selection is RoadContainer:
parent.add_child(next_rp)
next_rp.set_owner(get_tree().get_edited_scene_root())
next_rp.name = "RP_001" # TODO: define this in some central area.
var _lanes:Array[RoadPoint.LaneDir] = [
RoadPoint.LaneDir.REVERSE,
Expand All @@ -1064,6 +1062,8 @@ func _add_next_rp_on_click_do(pos: Vector3, nrm: Vector3, selection: Node, paren
]
next_rp.traffic_dir = _lanes
next_rp.auto_lanes = true
parent.add_child(next_rp)
next_rp.set_owner(get_tree().get_edited_scene_root())

# Make the road visible halfway above the ground by the gutter height amount.
if nrm == Vector3.ZERO:
Expand Down Expand Up @@ -1492,6 +1492,8 @@ func _create_roadpoint_pressed() -> void:
else:
undo_redo.add_do_method(self, "_create_roadpoint_do", t_container)
undo_redo.add_undo_method(self, "_create_roadpoint_undo", t_container)
undo_redo.add_do_method(t_container, "update_edges")
undo_redo.add_undo_method(t_container, "update_edges")
undo_redo.commit_action()


Expand Down Expand Up @@ -1519,8 +1521,6 @@ func _create_roadpoint_do(t_container: RoadContainer):
first_road_point.add_road_point(second_road_point, RoadPoint.PointInit.NEXT)
set_selection(second_road_point)

t_container.update_edges() # Since we updated a roadpoint name after adding.


func _create_roadpoint_undo(t_container: RoadContainer):
# Make a likely bad assumption that the last child of the RoadContainer is
Expand Down Expand Up @@ -1551,6 +1551,8 @@ func _create_2x2_road_pressed() -> void:
undo_redo.create_action("Add 2x2 road segment")
undo_redo.add_do_method(self, "_create_2x2_road_do", t_container, false)
undo_redo.add_undo_method(self, "_create_2x2_road_undo", t_container, false)
undo_redo.add_do_method(t_container, "update_edges")
undo_redo.add_undo_method(t_container, "update_edges")
undo_redo.commit_action()


Expand Down Expand Up @@ -1584,8 +1586,6 @@ func _create_2x2_road_do(t_container: RoadContainer, single_point: bool):
else:
set_selection(first_road_point)

t_container.update_edges() # Since we updated a roadpoint name after adding.


func _create_2x2_road_undo(selected_node: RoadContainer, single_point: bool) -> void:
# Make a likely bad assumption that the last two children are the ones to
Expand Down

0 comments on commit 1b88b6f

Please sign in to comment.