Went back to not using a special dummy BugMarker, because it turned out to be less versatile.

This commit is contained in:
Jamie Greunbaum 2024-05-16 17:57:05 -04:00
parent 0ed55dd461
commit bf014d0e38
8 changed files with 37 additions and 25 deletions

View File

@ -3,7 +3,7 @@
shader_type spatial;
render_mode blend_mix,depth_test_disabled,cull_disabled,unshaded;
uniform vec3 colour : source_color = vec3(1.0f, 0.0f, 0.0f);
uniform vec3 colour : source_color = vec3(1.0f);
uniform sampler2D msdf_icon : filter_linear_mipmap,hint_default_black;
uniform float shape_thickness : hint_range(0.0f,1.0f,0.01) = 0.95f;
uniform vec3 line_colour : source_color = vec3(0.0f);

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,4 @@
class_name BugMarker
extends Node3D
enum BugStatus { NEUTRAL, UNRESOLVED, IN_PROGRESS, RESOLVED }
@ -17,13 +18,19 @@ var __billboard_material : ShaderMaterial
func _ready() -> void:
if __arrow and __billboard:
__arrow_material = __arrow.mesh.surface_get_material(0) as ShaderMaterial
__billboard_material = __billboard.mesh.surface_get_material(0) as ShaderMaterial
set_info_enabled(enable_info)
__set_marker_status(marker_status)
func set_rotation_to_normal(_normal:Vector3) -> void:
global_transform.basis.y = _normal
global_transform.basis.x = global_transform.basis.z.cross(_normal)
global_transform.basis = global_transform.basis.orthonormalized()
func set_info_enabled(_enable:bool):
if __info_collider:
__info_collider.collision_layer = 0xFFFFFFFF if _enable else 0x00000000

View File

@ -14,8 +14,3 @@ func _process(_delta:float) -> void:
position = Vector3(0.0, 0.0, 0.0)
elif follow_node:
global_position = follow_node.global_position
func set_rotation_to_normal(_normal:Vector3) -> void:
global_transform.basis.y = _normal
global_transform.basis.x = global_transform.basis.z.cross(_normal)
global_transform.basis = global_transform.basis.orthonormalized()

View File

@ -4,6 +4,9 @@ extends CharacterBody3D
## A controllable bot that marks the location of a bug, and allows writing a bug
## report for it.
## Scene to use as the bug marker.
@export_file("*.scn","*.tscn") var bug_marker : String
## Distance from camera to allow placing bug markers.
@export_range(0.0, 100.0, 0.01, "or_greater", "suffix:m") var ray_length : float = 10.0
@ -57,7 +60,7 @@ extends CharacterBody3D
#region Onready
@onready var __laser_beam : Node3D = $LaserBeamRoot as Node3D
@onready var __bug_marker_dummy : Node3D = $BugMarkerDummy as Node3D
@onready var __bug_marker_dummy : BugMarker = $LaserBeamRoot/LaserGlare/BugMarkerDummy as BugMarker
@onready var __movement_speed_change_timer : Timer = $MovementSpeedChangeTimer as Timer
@onready var __exit_placement_timer : Timer = $ExitPlacementTimer as Timer
@onready var __camera : Camera3D = $CollisionShape3D/Camera3D
@ -261,7 +264,7 @@ func __calculate_movement() -> void:
func __calculate_button_presses() -> void:
if Input.is_action_just_pressed(&"bugbot_place_marker") and __raycast_collision:
print("Marker placed at ", __raycast_collision["position"])
__place_marker(__raycast_collision["position"], __raycast_collision["normal"])
if Input.is_action_just_released(&"bugbot_exit_placement"):
__exit_placement_timer.stop()
@ -286,7 +289,16 @@ func __raycast_to_world():
else:
__laser_beam.visible = false
func __place_marker(_position:Vector3, _normal:Vector3):
var marker : BugMarker = (load(bug_marker) as PackedScene).instantiate() as BugMarker
get_tree().get_root().add_child(marker)
marker.global_position = _position
marker.set_rotation_to_normal(_normal)
marker.marker_status = BugMarker.BugStatus.UNRESOLVED
func __place_dummy_marker():
if __bug_marker_dummy:
if __raycast_collision:
__bug_marker_dummy.set_rotation_to_normal(__raycast_collision["normal"])
__bug_marker_dummy.visible = true

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=41 format=3 uid="uid://dvgain3s4xa4r"]
[gd_scene load_steps=40 format=3 uid="uid://dvgain3s4xa4r"]
[ext_resource type="Script" path="res://addons/Bugbot/Scenes/bugbot_player.gd" id="1_kdrpa"]
[ext_resource type="InputEventKey" uid="uid://di5q6d4wt12et" path="res://addons/Bugbot/Inputs/Keyboard/move_forward.res" id="2_jfhdw"]
@ -34,7 +34,6 @@
[ext_resource type="InputEventJoypadButton" uid="uid://bc2q8kry856bq" path="res://addons/Bugbot/Inputs/Joystick/place_marker.res" id="32_q7vmk"]
[ext_resource type="InputEventJoypadButton" uid="uid://8tu5a8nlxgsj" path="res://addons/Bugbot/Inputs/Joystick/exit_placement.res" id="33_lwr38"]
[ext_resource type="PackedScene" uid="uid://crr6cjploetps" path="res://addons/Bugbot/Scenes/bug_marker.tscn" id="34_jyjbc"]
[ext_resource type="Script" path="res://addons/Bugbot/Scenes/bug_marker_dummy.gd" id="35_ibing"]
[ext_resource type="Material" uid="uid://c8b630nfapp8l" path="res://addons/Bugbot/Materials/laser_glow.material" id="35_xqv41"]
[ext_resource type="Material" uid="uid://dewbda2gd8bgv" path="res://addons/Bugbot/Materials/laser_glare.material" id="36_e4bro"]
@ -60,6 +59,7 @@ motion_mode = 1
platform_on_leave = 2
platform_floor_layers = 0
script = ExtResource("1_kdrpa")
bug_marker = "res://addons/Bugbot/Scenes/bug_marker.tscn"
keyboard_move_forward = ExtResource("2_jfhdw")
keyboard_move_backward = ExtResource("3_0y0pl")
keyboard_move_left = ExtResource("4_wdhjx")
@ -93,11 +93,6 @@ joypad_movement_speed_down = ExtResource("31_t01c7")
joypad_place_marker = ExtResource("32_q7vmk")
joypad_exit_placement = ExtResource("33_lwr38")
[node name="BugMarkerDummy" type="Node3D" parent="." node_paths=PackedStringArray("follow_node")]
script = ExtResource("35_ibing")
bug_marker = ExtResource("34_jyjbc")
follow_node = NodePath("../LaserBeamRoot/LaserGlare")
[node name="LaserBeamRoot" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.5, -0.5, 0)
@ -114,6 +109,9 @@ gi_mode = 0
mesh = SubResource("QuadMesh_kvipo")
skeleton = NodePath("../..")
[node name="BugMarkerDummy" parent="LaserBeamRoot/LaserGlare" instance=ExtResource("34_jyjbc")]
enable_info = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_6gwao")
debug_color = Color(0.5, 0.7, 1, 1)