From 8bbeeb49a9a0c73bc370891e51df5feb28f19525 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Thu, 25 Apr 2024 15:40:56 +0200 Subject: [PATCH] update hands and fix mini view z-fighting --- app/content/main.tscn | 4 +-- app/content/system/hands/hands.gd | 25 +++++++++++++------ app/content/system/hands/hands.tscn | 10 ++++---- app/content/system/house/mini/mini_wall.tres | 2 +- .../house/mini/mini_wall_shader.gdshader | 3 ++- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/content/main.tscn b/app/content/main.tscn index d49f6bc..baa8410 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -18,13 +18,11 @@ sky_material = ExtResource("5_wgwf8") [sub_resource type="Environment" id="Environment_7ghp0"] background_mode = 1 -background_color = Color(1, 1, 1, 0) +background_color = Color(0, 0, 0, 0) background_energy_multiplier = 0.0 sky = SubResource("Sky_vhymk") ambient_light_source = 2 ambient_light_color = Color(1, 1, 1, 1) -ambient_light_energy = 0.5 -reflected_light_source = 1 ssao_radius = 6.52 ssao_intensity = 5.68 diff --git a/app/content/system/hands/hands.gd b/app/content/system/hands/hands.gd index 33d3dae..fe208a5 100644 --- a/app/content/system/hands/hands.gd +++ b/app/content/system/hands/hands.gd @@ -17,10 +17,12 @@ const Miniature = preload ("res://content/system/house/mini/miniature.gd") @onready var humidity_button = $XRHandLeft/Palm/QuickActions/Humidity @export var ray_left: RayCast3D @export var ray_right: RayCast3D -var initiator: Initiator = Initiator.new() +var left_initiator: Initiator = Initiator.new() +var right_initiator: Initiator = Initiator.new() var touch: Touch var collide: Collide -var pointer: Pointer +var left_pointer: Pointer +var right_pointer: Pointer var press_distance = 0.03 var grip_distance = 0.03 var close_distance = 0.1 @@ -43,7 +45,7 @@ func _ready(): add_child(touch) add_child(collide) - _ready_hand(hand_right) + _ready_hand() mini_view_button.on_button_up.connect(func(): House.body.mini_view.small.value=!House.body.mini_view.small.value @@ -63,12 +65,18 @@ func _ready(): House.body.mini_view.heatmap_type.value=Miniature.HeatmapType.HUMIDITY ) -func _ready_hand(hand: OpenXRHand): - initiator.type = Initiator.Type.HAND_RIGHT if hand == hand_right else Initiator.Type.HAND_LEFT - initiator.node = ray_left.get_parent() if hand == hand_left else ray_right.get_parent() +func _ready_hand(): + left_initiator.type = Initiator.Type.HAND_LEFT + left_initiator.node = ray_left.get_parent() - pointer = Pointer.new(initiator, ray_left if hand == hand_left else ray_right) - add_child(pointer) + left_pointer = Pointer.new(left_initiator, ray_left) + add_child(left_pointer) + + right_initiator.type = Initiator.Type.HAND_RIGHT + right_initiator.node = ray_right.get_parent() + + right_pointer = Pointer.new(right_initiator, ray_right) + add_child(right_pointer) func _process(_delta): if main.camera.global_transform.basis.z.dot(palm.global_transform.basis.y) > 0.85: @@ -86,6 +94,7 @@ func _process_hand(hand: OpenXRHand): var middle_tip = hand.get_node("MiddleTip/Marker3D") var _ray = ray_left if hand == hand_left else ray_right + var initiator = left_initiator if hand == hand_left else right_initiator var distance_trigger = index_tip.global_position.distance_to(thumb_tip.global_position) var distance_grab = middle_tip.global_position.distance_to(thumb_tip.global_position) diff --git a/app/content/system/hands/hands.tscn b/app/content/system/hands/hands.tscn index 5e6bf75..517a26b 100644 --- a/app/content/system/hands/hands.tscn +++ b/app/content/system/hands/hands.tscn @@ -51,7 +51,7 @@ transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, shape = SubResource("CapsuleShape3D_dopke") [node name="ThumbTip" type="BoneAttachment3D" parent="XRHandLeft"] -transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928487, 0.0498668, 0.0560917, -0.112777) +transform = Transform3D(0.937246, 0.0284254, -0.347508, 0.0184905, 0.991216, 0.130949, 0.348178, -0.129157, 0.928488, 0.0498668, 0.0560917, -0.112777) bone_name = "Thumb_Tip_L" bone_idx = 4 use_external_skeleton = true @@ -61,7 +61,7 @@ external_skeleton = NodePath("../left_hand/Armature_001/Skeleton3D") gizmo_extents = 0.02 [node name="MiddleTip" type="BoneAttachment3D" parent="XRHandLeft"] -transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996576, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653567, 0.032112, 0.00654224, -0.171612) +transform = Transform3D(0.0812012, -0.650531, -0.755125, 0.996577, 0.064817, 0.051326, 0.0155558, -0.756708, 0.653568, 0.032112, 0.00654224, -0.171612) bone_name = "Middle_Tip_L" bone_idx = 14 use_external_skeleton = true @@ -84,7 +84,7 @@ shape = SubResource("CapsuleShape3D_dopke") transform = Transform3D(-0.707107, -8.74228e-08, -0.707107, 6.18173e-08, -1, 6.18173e-08, -0.707107, -8.29045e-24, 0.707107, 0.01, -0.04, -5.58794e-09) [node name="QuickActions" type="Node3D" parent="XRHandLeft/Palm"] -transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) +transform = Transform3D(0.5, -4.47035e-08, -4.37114e-08, 4.37114e-08, -2.18557e-08, 0.5, -4.47035e-08, -0.5, -2.18557e-08, 0.005, 0, 0.005) [node name="MiniView" parent="XRHandLeft/Palm/QuickActions" instance=ExtResource("3_te2p8")] transform = Transform3D(1, -3.55271e-15, -4.33681e-19, 3.55271e-15, 1, 3.5525e-15, -4.33681e-19, -3.55291e-15, 1, -0.0600001, 0, 0) @@ -112,7 +112,7 @@ transform = Transform3D(1, 0, 4.7579e-13, 0, 1, 0, -1.34149e-12, 1.77636e-15, 1, material_override = SubResource("StandardMaterial3D_n27ki") [node name="IndexTip" type="BoneAttachment3D" parent="XRHandRight"] -transform = Transform3D(0.19221, 0.669966, 0.717078, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345978, -0.164767, -0.0355401) +transform = Transform3D(0.19221, 0.669966, 0.717079, -0.091543, -0.715277, 0.69282, 0.977075, -0.19881, -0.0761527, -0.0345977, -0.164767, -0.0355401) bone_name = "Index_Tip_R" bone_idx = 9 use_external_skeleton = true @@ -142,7 +142,7 @@ external_skeleton = NodePath("../right_hand/Armature/Skeleton3D") gizmo_extents = 0.02 [node name="MiddleTip" type="BoneAttachment3D" parent="XRHandRight"] -transform = Transform3D(0.0812011, 0.650531, 0.755126, -0.0155557, -0.756708, 0.653568, 0.996576, -0.0648169, -0.0513262, -0.032112, -0.171612, -0.00654216) +transform = Transform3D(0.0812011, 0.650531, 0.755126, -0.0155557, -0.756709, 0.653568, 0.996576, -0.0648169, -0.0513262, -0.032112, -0.171612, -0.00654216) bone_name = "Middle_Tip_R" bone_idx = 14 use_external_skeleton = true diff --git a/app/content/system/house/mini/mini_wall.tres b/app/content/system/house/mini/mini_wall.tres index 20f7c8e..efe68d9 100644 --- a/app/content/system/house/mini/mini_wall.tres +++ b/app/content/system/house/mini/mini_wall.tres @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://bbuq4wn7e5o2q" path="res://content/system/house/mini/temp_gradient.tres" id="2_3lwi8"] [resource] -render_priority = -2 +render_priority = 0 shader = ExtResource("1_sbr3e") shader_parameter/data = PackedFloat32Array() shader_parameter/data_size = 0 diff --git a/app/content/system/house/mini/mini_wall_shader.gdshader b/app/content/system/house/mini/mini_wall_shader.gdshader index 7ae17f2..e7dd184 100644 --- a/app/content/system/house/mini/mini_wall_shader.gdshader +++ b/app/content/system/house/mini/mini_wall_shader.gdshader @@ -79,4 +79,5 @@ void fragment() { ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO, a); ROUGHNESS = roughness; SPECULAR = 0.5 * inversesqrt(ALPHA); -} + DEPTH = FRAGCOORD.z - 0.00001; +} \ No newline at end of file