Made planet shader 3d, added sprite to selected point, fixed collision stress calculation

This commit is contained in:
Aada 2026-03-03 13:38:25 +02:00
parent 930ed42150
commit a780ef479d
5 changed files with 82 additions and 54 deletions

View file

@ -37,6 +37,7 @@ public partial class Main : Control
Projector.GatherPoints(_planetHelper, int.Parse(GetNode<LineEdit>("%Resolution").Text));
}
Vector3 _pointerPosition = Vector3.Zero;
private const float RayLength = 1000.0f;
public override void _Input(InputEvent @event)
{
@ -76,26 +77,27 @@ public partial class Main : Control
{
if (Input.IsActionJustPressed("mouse_secondary"))
{
var from = _cameraNode.ProjectRayOrigin(GetViewport().GetMousePosition());
var to = from + _cameraNode.ProjectRayNormal(GetViewport().GetMousePosition()) * RayLength;
var from = _cameraNode.ProjectRayOrigin(_cameraNode.GetViewport().GetMousePosition());
var to = from + _cameraNode.ProjectRayNormal(_cameraNode.GetViewport().GetMousePosition()) * RayLength;
var result = World.GetWorld3D().DirectSpaceState.IntersectRay(PhysicsRayQueryParameters3D.Create(from, to));
if (result.Count > 0)
{
Vector3? pos = result["position"].AsVector3();
if (pos != null)
Vector3 pos = result["position"].AsVector3();
GD.Print($"Hit: '{pos}'");
var closest = _planetHelper.Octree.SearchNearest(pos)?.Id;
if (closest != null)
{
GD.Print($"Hit: '{pos}'");
var closest = _planetHelper.Octree.SearchNearest(pos ?? Vector3.Zero)?.Id;
if (closest != null)
{
_vertex = _planetHelper.Vertices.Single(v => v.Id == closest);
if (_planetHelper.Plates.Count > 0 && _vertex.PlateId != -1)
_plate = _planetHelper.Plates[_vertex.PlateId];
else
_plate = null;
UpdateStats();
}
_vertex = _planetHelper.Vertices.Single(v => v.Id == closest);
if (_planetHelper.Plates.Count > 0 && _vertex.PlateId != -1)
_plate = _planetHelper.Plates[_vertex.PlateId];
else
_plate = null;
UpdateStats();
Vector3 vertexPos = _planetHelper.Mdt.GetVertex(_vertex.Id) * 0.01f;
_pointerPosition = (Vector3)vertexPos + (vertexPos * (_vertex.Height + 0.01f) * 0.1f); // vertexPos * 1.01f;
}
}
}
@ -108,6 +110,7 @@ public partial class Main : Control
_planetHelper.AutoRun = true;
}
_planetHelper.Process();
GetNode<Node3D>("%Pointer").Position = _pointerPosition;
}
public void UpdateStats()
{