From f8f1cbaab7d856a70f9dc381ec07127b96f2d2e9 Mon Sep 17 00:00:00 2001 From: Snorre <snorre@altschul.dk> Date: Sat, 5 Apr 2025 17:03:51 +0200 Subject: [PATCH] stop fucking formatting my files godot --- project.godot | 4 ++ scenes/test.tscn | 1 + scripts/Mouth.cs | 71 +++++++++++++------------ scripts/XRHand.cs | 118 +++++++++++++++++++----------------------- scripts/XrOrigin3d.cs | 20 +++---- 5 files changed, 105 insertions(+), 109 deletions(-) diff --git a/project.godot b/project.godot index 1095919..ac39b67 100644 --- a/project.godot +++ b/project.godot @@ -22,6 +22,10 @@ project/assembly_name="nordic25" import/blender/enabled=false +[rendering] + +renderer/rendering_method="mobile" + [xr] openxr/enabled=true diff --git a/scenes/test.tscn b/scenes/test.tscn index e2f88d8..6b8214b 100644 --- a/scenes/test.tscn +++ b/scenes/test.tscn @@ -48,6 +48,7 @@ transform = Transform3D(1, 0, 0, 0, -0.837394, -0.546599, 0, 0.546599, -0.837394 shape = SubResource("CapsuleShape3D_74lek") [node name="Player" parent="." instance=ExtResource("2_iyx0m")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.576159) [node name="test pellet" parent="." instance=ExtResource("3_iyx0m")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00932735, 0.01, -0.0187979) diff --git a/scripts/Mouth.cs b/scripts/Mouth.cs index 3dc15dc..cf3707b 100644 --- a/scripts/Mouth.cs +++ b/scripts/Mouth.cs @@ -3,45 +3,48 @@ using Godot; public partial class Mouth : XRCamera3D { - [Export] - public float MaxEatWeight = 1.0f; + [Export] + public float MaxEatWeight = 1.0f; - [Export] - public float EatGrowthFactor = 0.1f; + [Export] + public float EatGrowthFactor = 0.1f; - [Export] - public XRHand RightHand; - [Export] - public XRHand LeftHand; + [Export] + public XRHand RightHand; + [Export] + public XRHand LeftHand; - public override void _Ready() - { - UpdateWeights(); - } + public override void _Ready() + { + UpdateWeights(); + } - public void EnterMouth(Node node) - { - try - { - RigidBody3D body = (RigidBody3D)node; - if (body.Mass > MaxEatWeight) - return; + public void EnterMouth(Node node) + { + try + { + RigidBody3D body = (RigidBody3D)node; + if (body.Mass > MaxEatWeight) + return; - UpdateWeights(body.Mass); + UpdateWeights(body.Mass); + } + catch (System.InvalidCastException) + { + // dont give a shit + } + } - } - catch (System.InvalidCastException) - { - // dont give a shit - } - } - - void UpdateWeights(float mass = 0f) - { - MaxEatWeight += (mass / MaxEatWeight) * EatGrowthFactor; - ((XROrigin3D)GetParent()).WorldScale = 1.0f / MaxEatWeight; - RightHand.Strength = MaxEatWeight; - LeftHand.Strength = MaxEatWeight; - } + void UpdateWeights(float mass = 0f) + { + GD.Print("Ate ", mass, "kg"); + MaxEatWeight += (mass / MaxEatWeight) * EatGrowthFactor; + float WorldScale = 1.0f / MaxEatWeight; + ((XROrigin3D)GetParent()).WorldScale = WorldScale; + RightHand.Strength = MaxEatWeight; + LeftHand.Strength = MaxEatWeight; + GD.Print("New MaxEatWeight: ", MaxEatWeight); + GD.Print("New WorldScale: ", WorldScale); + } } diff --git a/scripts/XRHand.cs b/scripts/XRHand.cs index 20959eb..3d80bb5 100644 --- a/scripts/XRHand.cs +++ b/scripts/XRHand.cs @@ -3,76 +3,64 @@ using System.Collections.Generic; public partial class XRHand : XRController3D { - List<Generic6DofJoint3D> joints = new(); + List<PinJoint3D> joints = new(); - [Export] - StaticBody3D body; + [Export] + StaticBody3D body; - [Export] - public float Strength = 1.0f; + [Export] + public float Strength = 1.0f; - public override void _Process(double delta) - { - if ((bool)GetInput("trigger_click")) - { - } - else if (joints.Count > 0) - { - } - } + public void OnPress(string name) + { + if (name == "select_button") + { + var query = new PhysicsShapeQueryParameters3D(); + var sphere = new SphereShape3D(); + sphere.Radius = 0.1f; + query.Shape = sphere; + query.CollideWithBodies = true; + query.CollideWithAreas = false; + query.Transform = ((Node3D)GetParent()).GlobalTransform; + var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query); + foreach (var fuckingcollider in overlaps) + { + RigidBody3D body = null; + try + { + body = (RigidBody3D)fuckingcollider["collider"]; + } + catch (System.InvalidCastException) + { + continue; + } - public void OnPress(string name) - { - if (name == "select_button") - { - var query = new PhysicsShapeQueryParameters3D(); - var sphere = new SphereShape3D(); - sphere.Radius = 0.1f; - query.Shape = sphere; - query.CollideWithBodies = true; - query.CollideWithAreas = false; - query.Transform = ((Node3D)GetParent()).GlobalTransform; - var overlaps = GetWorld3D().DirectSpaceState.IntersectShape(query); - foreach (var fuckingcollider in overlaps) - { - RigidBody3D body = null; - try - { - body = (RigidBody3D)fuckingcollider["collider"]; - } - catch (System.InvalidCastException) - { - continue; - } + if (body.Mass > Strength) + continue; - if (body.Mass > Strength) - { - continue; - } + PinJoint3D joint = new(); + joint.NodeA = GetPathTo(body); + joint.NodeB = body.GetPath(); + joints.Add(joint); + AddChild(joint); + } + } + } - Generic6DofJoint3D joint = new(); - joint.NodeA = GetPathTo(body); - joint.NodeB = body.GetPath(); - joints.Add(joint); - AddChild(joint); - } - } - } + public void OnRelease(string name) + { + if (name == "select_button") + { + foreach (var joint in joints) + joint.QueueFree(); + joints.Clear(); + } + } - public void OnRelease(string name) - { - if (name == "select_button") - { - foreach (var joint in joints) - joint.QueueFree(); - joints.Clear(); - } - } - - public void OnFloat(string name, float value) - { - // GD.Print("Float input:"); - // GD.Print(name); - // GD.Print(value); - } + public void OnFloat(string name, float value) + { + // GD.Print("Float input:"); + // GD.Print(name); + // GD.Print(value); + } } diff --git a/scripts/XrOrigin3d.cs b/scripts/XrOrigin3d.cs index acd7033..846d7a2 100644 --- a/scripts/XrOrigin3d.cs +++ b/scripts/XrOrigin3d.cs @@ -3,17 +3,17 @@ using System; public partial class XrOrigin3d : XROrigin3D { - private XRInterface _xrInterface; + private XRInterface _xrInterface; - public override void _Ready() - { - _xrInterface = XRServer.FindInterface("OpenXR"); - if (_xrInterface == null || !_xrInterface.IsInitialized()) - GD.PushError("Failed to initialize OpenXR"); + public override void _Ready() + { + _xrInterface = XRServer.FindInterface("OpenXR"); + if (_xrInterface == null || !_xrInterface.IsInitialized()) + GD.PushError("Failed to initialize OpenXR"); - GD.PushError("OpenXR Initialized successfully"); + GD.Print("OpenXR Initialized successfully"); - DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled); - GetViewport().UseXR = true; - } + DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled); + GetViewport().UseXR = true; + } }