Compare commits
No commits in common. "a780ef479d4e4aa551c226a6f65caa150ac754d3" and "df46846953948f35cc8a4a3259f5f8ef33240246" have entirely different histories.
a780ef479d
...
df46846953
5 changed files with 55 additions and 83 deletions
|
|
@ -3,20 +3,19 @@
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://n56csi5ekat"
|
uid="uid://n56csi5ekat"
|
||||||
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
|
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"imported_formats": ["s3tc_bptc"],
|
"vram_texture": false
|
||||||
"vram_texture": true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://icon.svg"
|
source_file="res://icon.svg"
|
||||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"]
|
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=2
|
compress/mode=0
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/uastc_level=0
|
compress/uastc_level=0
|
||||||
|
|
@ -24,7 +23,7 @@ compress/rdo_quality_loss=0.0
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
mipmaps/generate=true
|
mipmaps/generate=false
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
|
|
@ -38,7 +37,7 @@ process/normal_map_invert_y=false
|
||||||
process/hdr_as_srgb=false
|
process/hdr_as_srgb=false
|
||||||
process/hdr_clamp_exposure=false
|
process/hdr_clamp_exposure=false
|
||||||
process/size_limit=0
|
process/size_limit=0
|
||||||
detect_3d/compress_to=0
|
detect_3d/compress_to=1
|
||||||
svg/scale=1.0
|
svg/scale=1.0
|
||||||
editor/scale_with_editor_scale=false
|
editor/scale_with_editor_scale=false
|
||||||
editor/convert_colors_with_editor_theme=false
|
editor/convert_colors_with_editor_theme=false
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
[ext_resource type="Gradient" uid="uid://b5l44rktieewe" path="res://resources/planet_gradient.tres" id="2_ygjfp"]
|
[ext_resource type="Gradient" uid="uid://b5l44rktieewe" path="res://resources/planet_gradient.tres" id="2_ygjfp"]
|
||||||
[ext_resource type="Material" uid="uid://c55st036tapeo" path="res://shaders/planet.tres" id="3_ygjfp"]
|
[ext_resource type="Material" uid="uid://c55st036tapeo" path="res://shaders/planet.tres" id="3_ygjfp"]
|
||||||
[ext_resource type="Material" uid="uid://k3teblrpopsb" path="res://shaders/map.tres" id="4_1wiy7"]
|
[ext_resource type="Material" uid="uid://k3teblrpopsb" path="res://shaders/map.tres" id="4_1wiy7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://n56csi5ekat" path="res://icon.svg" id="5_ygjfp"]
|
|
||||||
|
|
||||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_uxrcv"]
|
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_uxrcv"]
|
||||||
|
|
||||||
|
|
@ -70,7 +69,7 @@ environment = SubResource("Environment_rf2cd")
|
||||||
camera_attributes = SubResource("CameraAttributesPractical_a814b")
|
camera_attributes = SubResource("CameraAttributesPractical_a814b")
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=899426195]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=899426195]
|
||||||
transform = Transform3D(0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0)
|
transform = Transform3D(0.88874525, -0.29675773, 0.3493804, 0, 0.7621714, 0.6473753, -0.45840138, -0.5753517, 0.6773762, 0, 0, 0)
|
||||||
|
|
||||||
[node name="Icosphere" type="MeshInstance3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=793654005]
|
[node name="Icosphere" type="MeshInstance3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=793654005]
|
||||||
transform = Transform3D(0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0)
|
transform = Transform3D(0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0)
|
||||||
|
|
@ -90,13 +89,6 @@ fov = 5.0
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/StaticBody3D" unique_id=299495076]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo/StaticBody3D" unique_id=299495076]
|
||||||
shape = SubResource("SphereShape3D_rpqi1")
|
shape = SubResource("SphereShape3D_rpqi1")
|
||||||
|
|
||||||
[node name="Pointer" type="Sprite3D" parent="TabContainer/Planet/SubViewportContainer/SubViewport/ZaWarudo" unique_id=1498529325]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
transform = Transform3D(0.01, 0, 0, 0, 0.01, 0, 0, 0, 0.01, 0, 0, 0)
|
|
||||||
modulate = Color(1, 0, 0, 1)
|
|
||||||
billboard = 1
|
|
||||||
texture = ExtResource("5_ygjfp")
|
|
||||||
|
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="TabContainer/Planet" unique_id=716838825]
|
[node name="PanelContainer" type="PanelContainer" parent="TabContainer/Planet" unique_id=716838825]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,11 @@ render_mode unshaded;
|
||||||
uniform int mode = 1;
|
uniform int mode = 1;
|
||||||
uniform sampler2D gradient;
|
uniform sampler2D gradient;
|
||||||
varying vec3 world_position;
|
varying vec3 world_position;
|
||||||
varying float color;
|
varying flat float color;
|
||||||
void vertex() {
|
void vertex() {
|
||||||
// Called for every vertex the material is visible on.
|
// Called for every vertex the material is visible on.
|
||||||
world_position = VERTEX;
|
world_position = VERTEX;
|
||||||
color = COLOR.r;
|
color = COLOR.r;
|
||||||
VERTEX += VERTEX * COLOR.q * 0.1f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
|
|
|
||||||
35
src/Main.cs
35
src/Main.cs
|
|
@ -37,7 +37,6 @@ public partial class Main : Control
|
||||||
Projector.GatherPoints(_planetHelper, int.Parse(GetNode<LineEdit>("%Resolution").Text));
|
Projector.GatherPoints(_planetHelper, int.Parse(GetNode<LineEdit>("%Resolution").Text));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 _pointerPosition = Vector3.Zero;
|
|
||||||
private const float RayLength = 1000.0f;
|
private const float RayLength = 1000.0f;
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
|
|
@ -77,27 +76,26 @@ public partial class Main : Control
|
||||||
{
|
{
|
||||||
if (Input.IsActionJustPressed("mouse_secondary"))
|
if (Input.IsActionJustPressed("mouse_secondary"))
|
||||||
{
|
{
|
||||||
var from = _cameraNode.ProjectRayOrigin(_cameraNode.GetViewport().GetMousePosition());
|
var from = _cameraNode.ProjectRayOrigin(GetViewport().GetMousePosition());
|
||||||
var to = from + _cameraNode.ProjectRayNormal(_cameraNode.GetViewport().GetMousePosition()) * RayLength;
|
var to = from + _cameraNode.ProjectRayNormal(GetViewport().GetMousePosition()) * RayLength;
|
||||||
var result = World.GetWorld3D().DirectSpaceState.IntersectRay(PhysicsRayQueryParameters3D.Create(from, to));
|
var result = World.GetWorld3D().DirectSpaceState.IntersectRay(PhysicsRayQueryParameters3D.Create(from, to));
|
||||||
if (result.Count > 0)
|
if (result.Count > 0)
|
||||||
{
|
{
|
||||||
Vector3 pos = result["position"].AsVector3();
|
Vector3? pos = result["position"].AsVector3();
|
||||||
|
if (pos != null)
|
||||||
GD.Print($"Hit: '{pos}'");
|
|
||||||
var closest = _planetHelper.Octree.SearchNearest(pos)?.Id;
|
|
||||||
if (closest != null)
|
|
||||||
{
|
{
|
||||||
_vertex = _planetHelper.Vertices.Single(v => v.Id == closest);
|
GD.Print($"Hit: '{pos}'");
|
||||||
if (_planetHelper.Plates.Count > 0 && _vertex.PlateId != -1)
|
var closest = _planetHelper.Octree.SearchNearest(pos ?? Vector3.Zero)?.Id;
|
||||||
_plate = _planetHelper.Plates[_vertex.PlateId];
|
if (closest != null)
|
||||||
else
|
{
|
||||||
_plate = null;
|
_vertex = _planetHelper.Vertices.Single(v => v.Id == closest);
|
||||||
UpdateStats();
|
if (_planetHelper.Plates.Count > 0 && _vertex.PlateId != -1)
|
||||||
Vector3 vertexPos = _planetHelper.Mdt.GetVertex(_vertex.Id) * 0.01f;
|
_plate = _planetHelper.Plates[_vertex.PlateId];
|
||||||
_pointerPosition = (Vector3)vertexPos + (vertexPos * (_vertex.Height + 0.01f) * 0.1f); // vertexPos * 1.01f;
|
else
|
||||||
|
_plate = null;
|
||||||
|
UpdateStats();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +108,6 @@ public partial class Main : Control
|
||||||
_planetHelper.AutoRun = true;
|
_planetHelper.AutoRun = true;
|
||||||
}
|
}
|
||||||
_planetHelper.Process();
|
_planetHelper.Process();
|
||||||
GetNode<Node3D>("%Pointer").Position = _pointerPosition;
|
|
||||||
}
|
}
|
||||||
public void UpdateStats()
|
public void UpdateStats()
|
||||||
{
|
{
|
||||||
|
|
@ -199,6 +196,6 @@ public partial class Main : Control
|
||||||
{
|
{
|
||||||
change = new string(change.Where(c => char.IsDigit(c)).ToArray());
|
change = new string(change.Where(c => char.IsDigit(c)).ToArray());
|
||||||
_resolution = Int32.Parse(change);
|
_resolution = Int32.Parse(change);
|
||||||
_resolution = Math.Clamp(_resolution, 64, 2048);
|
_resolution = Math.Clamp(_resolution, 64, 8192);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using Godot;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using adatonic;
|
using adatonic;
|
||||||
using Node = adatonic.Node;
|
using Node = adatonic.Node;
|
||||||
using Timer = System.Timers.Timer;
|
using Timer = System.Timers.Timer;
|
||||||
|
|
@ -24,8 +23,7 @@ public class PlanetHelper
|
||||||
|
|
||||||
public int CenterVertexId = -1;
|
public int CenterVertexId = -1;
|
||||||
public float PlateExpansion { get; set; } = RandF(0.5f, 2f);
|
public float PlateExpansion { get; set; } = RandF(0.5f, 2f);
|
||||||
public Vector3 MovementAxis { get; set; } = Vector3.Zero;
|
public Vector3 Dir { get; set; } = Vector3.Zero;
|
||||||
public float MovementSpeed { get; set; } = RandF(0f, 1f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VertexData(int Id = 0, int PlateId = 0, List<int> Neighbours = null, bool StageComplete = false)
|
public class VertexData(int Id = 0, int PlateId = 0, List<int> Neighbours = null, bool StageComplete = false)
|
||||||
|
|
@ -154,7 +152,7 @@ public class PlanetHelper
|
||||||
ColorVertex(vertex.Id, color);
|
ColorVertex(vertex.Id, color);
|
||||||
PlateData plate = new PlateData(i, color, false, [vertex.Id]);
|
PlateData plate = new PlateData(i, color, false, [vertex.Id]);
|
||||||
|
|
||||||
plate.MovementAxis = GetRandomVector3();
|
plate.Dir = GetRandomTangentialVelocity(Mdt.GetVertex(vertex.Id), RandF(0f, 1f));
|
||||||
Plates.Add(plate);
|
Plates.Add(plate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,14 +172,7 @@ public class PlanetHelper
|
||||||
return verts.Except([vertexId]);
|
return verts.Except([vertexId]);
|
||||||
return verts.Where(v => Mdt.GetVertexColor(v) == Colors.Black).Except([vertexId]);
|
return verts.Where(v => Mdt.GetVertexColor(v) == Colors.Black).Except([vertexId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 GetRandomVector3()
|
|
||||||
{
|
|
||||||
Vector3 vec = Vector3.Up;
|
|
||||||
vec = vec.Rotated(Vector3.Forward, Mathf.DegToRad(RandF(0, 180f)));
|
|
||||||
vec = vec.Rotated(Vector3.Up, Mathf.DegToRad(RandF(0, 360f)));
|
|
||||||
return vec.Normalized();
|
|
||||||
}
|
|
||||||
public Vector3 GetRandomTangentialVelocity(Vector3 pointOnSphere, float speed)
|
public Vector3 GetRandomTangentialVelocity(Vector3 pointOnSphere, float speed)
|
||||||
{
|
{
|
||||||
Vector3 normal = pointOnSphere.Normalized();
|
Vector3 normal = pointOnSphere.Normalized();
|
||||||
|
|
@ -401,15 +392,12 @@ public class PlanetHelper
|
||||||
VertexData centerA = Vertices[plateA.CenterVertexId];
|
VertexData centerA = Vertices[plateA.CenterVertexId];
|
||||||
VertexData centerB = Vertices[plateB.CenterVertexId];
|
VertexData centerB = Vertices[plateB.CenterVertexId];
|
||||||
Vector3 p1, p2;
|
Vector3 p1, p2;
|
||||||
p1 = Mdt.GetVertex(vertexData.Id);
|
p1 = Mdt.GetVertex(vertexData.Id).Cross(Mdt.GetVertex(centerA.Id));
|
||||||
p2 = Mdt.GetVertex(neighbour);
|
p2 = Mdt.GetVertex(neighbour).Cross(Mdt.GetVertex(centerB.Id));
|
||||||
Vector3 vel1 = ((p1 - p1.Rotated(plateA.MovementAxis, Mathf.DegToRad(1))).Normalized()) * plateA.MovementSpeed;
|
vertexData.StrainSamples.Add(CalculateStrainMagnitude(p1, p2, plateA.Dir, plateB.Dir));
|
||||||
Vector3 vel2 = ((p2 - p2.Rotated(plateB.MovementAxis, Mathf.DegToRad(1))).Normalized()) * plateB.MovementSpeed;
|
|
||||||
vertexData.StrainSamples.Add(CalculateStrainMagnitude(p1, p2, vel1, vel2));
|
|
||||||
}
|
}
|
||||||
vertexData.StageComplete = true;
|
vertexData.StageComplete = true;
|
||||||
var majorStrain = AverageStrainList(vertexData.StrainSamples);
|
var majorStrain = AverageStrainList(vertexData.StrainSamples);
|
||||||
vertexData.StrainSamples = [majorStrain];
|
|
||||||
switch (majorStrain.Type)
|
switch (majorStrain.Type)
|
||||||
{
|
{
|
||||||
case StrainType.Compression:
|
case StrainType.Compression:
|
||||||
|
|
@ -434,41 +422,41 @@ public class PlanetHelper
|
||||||
}
|
}
|
||||||
public void SpreadStress()
|
public void SpreadStress()
|
||||||
{
|
{
|
||||||
var availableVerts = Vertices.Where(d => d.StageComplete == false && d.IsEdge && d.StrainSamples.Any()).OrderByDescending(d => Mathf.Abs(d.StrainSamples.Max(s => s.Magnitude))).Take(500).ToList();
|
var availableVerts = Vertices.Where(d => d.StageComplete == false && d.IsEdge && d.StrainSamples.Any()).OrderBy(d => Mathf.Abs(d.StrainSamples.Max(s => s.Magnitude))).Take(2500).ToList();
|
||||||
foreach (VertexData vertexData in availableVerts)
|
foreach (VertexData vertexData in availableVerts)
|
||||||
{
|
{
|
||||||
var neighbours = GetNeighboringVertices(vertexData.Id, false).ToList();
|
var neighbours = GetNeighboringVertices(vertexData.Id, false).ToList();
|
||||||
var majorStrain = AverageStrainList(vertexData.StrainSamples);
|
var majorStrain = AverageStrainList(vertexData.StrainSamples);
|
||||||
List<StrainAnalysis> localStrains = [];
|
|
||||||
foreach (int neighbour in neighbours)
|
|
||||||
{
|
|
||||||
localStrains.AddRange(Vertices[neighbour].StrainSamples);
|
|
||||||
}
|
|
||||||
localStrains.AddRange(vertexData.StrainSamples);
|
|
||||||
var averageStrain = AverageStrainList(localStrains);
|
|
||||||
averageStrain.Magnitude *= 0.9f;
|
|
||||||
averageStrain.NormalRate *= 0.9f;
|
|
||||||
averageStrain.ShearRate *= 0.9f;
|
|
||||||
foreach (int neighbour in neighbours)
|
foreach (int neighbour in neighbours)
|
||||||
{
|
{
|
||||||
VertexData neighbourVert = Vertices[neighbour];
|
VertexData neighbourVert = Vertices[neighbour];
|
||||||
neighbourVert.IsEdge = true;
|
neighbourVert.IsEdge = true;
|
||||||
neighbourVert.StrainSamples.Add(averageStrain);
|
|
||||||
|
var newStrain = new StrainAnalysis();
|
||||||
|
newStrain.Magnitude = majorStrain.Magnitude * 0.9f;
|
||||||
|
newStrain.Type = majorStrain.Type;
|
||||||
|
newStrain.NormalRate = majorStrain.NormalRate * 0.9f;
|
||||||
|
newStrain.ShearRate = majorStrain.ShearRate * 0.9f;
|
||||||
|
neighbourVert.StrainSamples.Add(newStrain);
|
||||||
|
var newAverage = AverageStrainList(neighbourVert.StrainSamples);;
|
||||||
switch (majorStrain.Type)
|
switch (majorStrain.Type)
|
||||||
{
|
{
|
||||||
case StrainType.Compression:
|
case StrainType.Compression:
|
||||||
ColorVertex(neighbourVert.Id, Colors.Red * averageStrain.Magnitude);
|
ColorVertex(neighbourVert.Id, Colors.Red * newAverage.Magnitude);
|
||||||
break;
|
break;
|
||||||
case StrainType.Shear:
|
case StrainType.Shear:
|
||||||
ColorVertex(neighbourVert.Id, Colors.Yellow * averageStrain.Magnitude);
|
ColorVertex(neighbourVert.Id, Colors.Yellow * newAverage.Magnitude);
|
||||||
break;
|
break;
|
||||||
case StrainType.Tension:
|
case StrainType.Tension:
|
||||||
ColorVertex(neighbourVert.Id, Colors.Blue * averageStrain.Magnitude);
|
ColorVertex(neighbourVert.Id, Colors.Blue * newAverage.Magnitude);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vertexData.StrainSamples = [AverageStrainList(vertexData.StrainSamples)];
|
|
||||||
vertexData.StageComplete = true;
|
if (neighbours.All(n => Vertices[n].IsEdge))
|
||||||
|
{
|
||||||
|
vertexData.StageComplete = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!availableVerts.Any())
|
if (!availableVerts.Any())
|
||||||
|
|
@ -643,11 +631,10 @@ public class PlanetHelper
|
||||||
|
|
||||||
double bestDiff = double.MaxValue;
|
double bestDiff = double.MaxValue;
|
||||||
int bestMask = 0;
|
int bestMask = 0;
|
||||||
object lobject = new();
|
|
||||||
int combinations = 1 << n;
|
int combinations = 1 << n;
|
||||||
var combs = Enumerable.Range(0, combinations / 4).Select(value => value * 4).ToList();
|
|
||||||
combinations = combs.Count;
|
for (int mask = 0; mask < combinations; mask++)
|
||||||
Parallel.ForEach(combs, mask =>
|
|
||||||
{
|
{
|
||||||
int oceanArea = 0;
|
int oceanArea = 0;
|
||||||
|
|
||||||
|
|
@ -658,15 +645,13 @@ public class PlanetHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
double diff = Math.Abs(oceanArea - targetOcean);
|
double diff = Math.Abs(oceanArea - targetOcean);
|
||||||
lock (lobject)
|
|
||||||
|
if (diff < bestDiff)
|
||||||
{
|
{
|
||||||
if (diff < bestDiff)
|
bestDiff = diff;
|
||||||
{
|
bestMask = mask;
|
||||||
bestDiff = diff;
|
|
||||||
bestMask = mask;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue