Skip to content

Commit

Permalink
Fix 3d Selection box logic
Browse files Browse the repository at this point in the history
previously if you dragged over an entity at any point it would go into the new selection. Now it resets the selection every frame to give more expected behavior
  • Loading branch information
mrhumbility committed Jul 17, 2022
1 parent 858ae3e commit 2160cc4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[folding]

node_unfolds=[NodePath("."), PackedStringArray("Axis Lock", "Linear", "Input"), NodePath("MeshInstance3D"), PackedStringArray("mesh", "Transform"), NodePath("CollisionShape3D"), PackedStringArray("shape", "Transform"), NodePath("NavigationAgent3D"), PackedStringArray("Pathfinding", "Avoidance"), NodePath("ProgressBar"), PackedStringArray("Visibility", "Layout", "Layout/Transform"), NodePath("TopOfHead"), PackedStringArray("Transform")]
resource_unfolds=["res://units/penguin.tscn::CapsuleMesh_su0u1", PackedStringArray("material"), "res://units/penguin.tscn::CapsuleShape3D_6y24a", PackedStringArray(), "res://helpers/click_pos_indicator.tscn::BoxMesh_bly7o", PackedStringArray("Resource"), "res://helpers/click_pos_indicator.tscn::StandardMaterial3D_qy3yl", PackedStringArray("Resource", "Albedo"), "res://helpers/goal_pos_indicator.tscn::BoxMesh_bly7o", PackedStringArray(), "res://helpers/goal_pos_indicator.tscn::StandardMaterial3D_qy3yl", PackedStringArray(), "res://helpers/unit_nav_debug_box.tscn::BoxMesh_s70mc", PackedStringArray()]
resource_unfolds=["res://units/penguin.tscn::CapsuleMesh_su0u1", PackedStringArray("material"), "res://units/penguin.tscn::CapsuleShape3D_6y24a", PackedStringArray(), "res://helpers/goal_pos_indicator.tscn::BoxMesh_bly7o", PackedStringArray(), "res://helpers/goal_pos_indicator.tscn::StandardMaterial3D_qy3yl", PackedStringArray(), "res://helpers/unit_nav_debug_box.tscn::BoxMesh_s70mc", PackedStringArray()]
nodes_folded=[]
44 changes: 20 additions & 24 deletions .godot/editor/script_editor_cache.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
state={
"bookmarks": [],
"breakpoints": [],
"column": 0,
"column": 28,
"folded_lines": [],
"h_scroll_position": 0,
"row": 9,
"scroll_position": 0.0,
"row": 22,
"scroll_position": 64.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
Expand All @@ -31,11 +31,11 @@ state={
state={
"bookmarks": [],
"breakpoints": [],
"column": 44,
"column": 17,
"folded_lines": [],
"h_scroll_position": 0,
"row": 6,
"scroll_position": 0.0,
"row": 4,
"scroll_position": 13.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
Expand All @@ -59,10 +59,10 @@ state={
state={
"bookmarks": [],
"breakpoints": [],
"column": 68,
"column": 48,
"folded_lines": [],
"h_scroll_position": 0,
"row": 5,
"row": 14,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
Expand All @@ -73,16 +73,12 @@ state={
state={
"bookmarks": [],
"breakpoints": [],
"column": 35,
"column": 48,
"folded_lines": [],
"h_scroll_position": 0,
"row": 11,
"scroll_position": 0.0,
"selection": true,
"selection_from_column": 35,
"selection_from_line": 11,
"selection_to_column": 68,
"selection_to_line": 11,
"row": 18,
"scroll_position": 5.0,
"selection": false,
"syntax_highlighter": "GDScript"
}

Expand All @@ -91,11 +87,11 @@ state={
state={
"bookmarks": [],
"breakpoints": [],
"column": 1,
"column": 13,
"folded_lines": [],
"h_scroll_position": 0,
"row": 148,
"scroll_position": 122.0,
"row": 156,
"scroll_position": 128.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
Expand Down Expand Up @@ -175,11 +171,11 @@ state={
state={
"bookmarks": [],
"breakpoints": [],
"column": 86,
"column": 2,
"folded_lines": [],
"h_scroll_position": 0,
"row": 64,
"scroll_position": 36.0,
"row": 79,
"scroll_position": 66.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
Expand All @@ -189,10 +185,10 @@ state={
state={
"bookmarks": [],
"breakpoints": [],
"column": 68,
"column": 14,
"folded_lines": [],
"h_scroll_position": 0,
"row": 5,
"row": 8,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
Expand Down
1 change: 1 addition & 0 deletions helpers/click_pos_indicator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func _process(delta):
if parent.moving:
visible = true
global_transform.origin = parent.dest.click_pos

else:
visible = false

Expand Down
2 changes: 1 addition & 1 deletion main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func _click_pos_line(start: Vector3, end: Vector3):
mat.albedo_color = Color(0, 1, 0, 0.5)
mat.transparency = 1
line.set_surface_override_material(0, mat)
var s = 0.015
var s = 0.025
line.mesh.size = Vector3(s, s, 1)
line.position.z += -0.5
node.add_child(line)
Expand Down
1 change: 1 addition & 0 deletions ui/selection_box_3d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func _checkNewSelection(_bbox_start, _bbox_end):

func _process(delta):
if _dragging:
selected_entities = []
_checkNewSelection(_bbox_start, _bbox_end)
for body in get_overlapping_bodies():
if &"units" in body.get_groups() and body not in selected_entities:
Expand Down
7 changes: 3 additions & 4 deletions units/penguin.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://d1ks7qehfn7tw"]
[gd_scene load_steps=7 format=3 uid="uid://d1ks7qehfn7tw"]

[ext_resource type="Script" path="res://units/penguin.gd" id="1_3hqrq"]
[ext_resource type="PackedScene" uid="uid://d3dkhdmcbd5lv" path="res://helpers/click_pos_indicator.tscn" id="2_l2bv5"]
[ext_resource type="PackedScene" uid="uid://bctbjlv10nwn8" path="res://helpers/goal_pos_indicator.tscn" id="2_unhtt"]
[ext_resource type="PackedScene" uid="uid://cksr5eenpn62i" path="res://helpers/unit_nav_debug_box.tscn" id="3_a3a84"]

Expand Down Expand Up @@ -53,12 +52,12 @@ one_shot = true
[node name="DebugNodes" type="Node3D" parent="."]
visible = false

[node name="ClickPosIndicator2" parent="DebugNodes" instance=ExtResource("2_l2bv5")]

[node name="GoalPosIndicator" parent="DebugNodes" instance=ExtResource("2_unhtt")]
visible = false
skeleton = NodePath("../..")

[node name="UnitNavDebugBox" parent="DebugNodes" instance=ExtResource("3_a3a84")]
visible = false
skeleton = NodePath("../..")

[node name="ProgressBar" type="ProgressBar" parent="."]
Expand Down

0 comments on commit 2160cc4

Please sign in to comment.