fixed singleton initialization
This commit is contained in:
parent
893c10904a
commit
fd15fe1e33
5 changed files with 55 additions and 19 deletions
|
@ -1,8 +1,8 @@
|
||||||
namespace Oriels;
|
namespace Oriels;
|
||||||
|
|
||||||
public class Mono {
|
public class Mono {
|
||||||
private static readonly Lazy<Mono> lazy = new Lazy<Mono>(() => new Mono());
|
private static readonly Lazy<Oriels.Mono> lazy = new Lazy<Oriels.Mono>(() => new Oriels.Mono());
|
||||||
public static Mono inst { get { return lazy.Value; } }
|
public static Oriels.Mono inst { get { return lazy.Value; } }
|
||||||
|
|
||||||
public PullRequest.Noise noise = new PullRequest.Noise(939949595);
|
public PullRequest.Noise noise = new PullRequest.Noise(939949595);
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ public class Mono {
|
||||||
public Mono() {
|
public Mono() {
|
||||||
Renderer.SetClip(0.02f, 1000f);
|
Renderer.SetClip(0.02f, 1000f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init() {
|
||||||
spaceMono.Init();
|
spaceMono.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ public static class PullRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
int position;
|
int position;
|
||||||
public float value {
|
public float uvalue {
|
||||||
get {
|
get {
|
||||||
float v = RNG(position, seed) / (float)CAP;
|
float v = RNG(position, seed) / (float)CAP;
|
||||||
position++;
|
position++;
|
||||||
|
@ -119,8 +119,14 @@ public static class PullRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float D1(int position) {
|
public float value { // not ideal *loss of precision*
|
||||||
return RNG(position, seed) / (float)CAP;
|
get {
|
||||||
|
return uvalue * 2 - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float D1(int pos) {
|
||||||
|
return RNG(pos, seed) / (float)CAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float D2(int x, int y) {
|
public float D2(int x, int y) {
|
||||||
|
@ -136,8 +142,8 @@ public static class PullRequest {
|
||||||
return RNG(x + (PRIME1 * y) + (PRIME2 * z), seed) / (float)CAP;
|
return RNG(x + (PRIME1 * y) + (PRIME2 * z), seed) / (float)CAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint RNG(int position, uint seed) {
|
public uint RNG(int pos, uint seed) {
|
||||||
uint mangled = (uint)position;
|
uint mangled = (uint)pos;
|
||||||
mangled *= BIT_NOISE1;
|
mangled *= BIT_NOISE1;
|
||||||
mangled += seed;
|
mangled += seed;
|
||||||
mangled ^= mangled >> 8;
|
mangled ^= mangled >> 8;
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Space;
|
namespace Space;
|
||||||
public class Mono {
|
public class Mono {
|
||||||
|
Node[] nodes = new Node[18];
|
||||||
Vec3 playerPos;
|
Vec3 playerPos;
|
||||||
List<Vec3> enemies = new List<Vec3>();
|
List<Vec3> enemies = new List<Vec3>();
|
||||||
float spawnTime;
|
float spawnTime;
|
||||||
|
@ -26,12 +26,25 @@ public class Mono {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init() {
|
public void Init() {
|
||||||
|
Oriels.PullRequest.Noise noise = Oriels.Mono.inst.noise;
|
||||||
|
|
||||||
|
// place nodes around a 10x4x10 cube
|
||||||
|
for (int i = 0; i < nodes.Length; i++) {
|
||||||
|
nodes[i] = new Node(
|
||||||
|
new Vec3(
|
||||||
|
noise.value * 5f,
|
||||||
|
noise.value * 2f,
|
||||||
|
noise.value * 5f
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
meshCube = Mesh.Cube;
|
meshCube = Mesh.Cube;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Frame() {
|
public void Frame() {
|
||||||
Rig rig = Oriels.Mono.inst.rig;
|
Oriels.Rig rig = Oriels.Mono.inst.rig;
|
||||||
Oriel oriel = Oriels.Mono.inst.oriel;
|
Oriels.Oriel oriel = Oriels.Mono.inst.oriel;
|
||||||
|
|
||||||
Matrix simMatrix = Matrix.TRS(
|
Matrix simMatrix = Matrix.TRS(
|
||||||
new Vec3(0, 0, 0), //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),
|
new Vec3(0, 0, 0), //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),
|
||||||
|
@ -65,8 +78,14 @@ public class Mono {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// RENDER
|
// RENDER
|
||||||
|
for (int i = 0; i < nodes.Length; i++) {
|
||||||
|
meshCube.Draw(oriel.matOriel,
|
||||||
|
Matrix.TRS(nodes[i].pos, Quat.Identity, Vec3.One * 1f) * simMatrix * oriel.matrix.Inverse,
|
||||||
|
Color.White
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
meshCube.Draw(oriel.matOriel,
|
meshCube.Draw(oriel.matOriel,
|
||||||
Matrix.TRS(cursor, Quat.Identity, Vec3.One * 0.02f),
|
Matrix.TRS(cursor, Quat.Identity, Vec3.One * 0.02f),
|
||||||
new Color(1f, 1f, 1f)
|
new Color(1f, 1f, 1f)
|
||||||
|
@ -153,3 +172,11 @@ public class Mono {
|
||||||
float moveP = 8f;
|
float moveP = 8f;
|
||||||
float moveI = 0.2f;
|
float moveI = 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Node {
|
||||||
|
public Vec3 pos;
|
||||||
|
|
||||||
|
public Node(Vec3 pos) {
|
||||||
|
this.pos = pos;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
namespace Oriels;
|
||||||
using StereoKit;
|
|
||||||
|
|
||||||
public abstract class SpatialCursor {
|
public abstract class SpatialCursor {
|
||||||
public Vec3 p0, p1, p2, p3;
|
public Vec3 p0, p1, p2, p3;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
global using System;
|
global using System;
|
||||||
global using StereoKit;
|
global using StereoKit;
|
||||||
global using Oriels;
|
// global using Oriels;
|
||||||
|
|
||||||
SKSettings settings = new SKSettings {
|
SKSettings settings = new SKSettings {
|
||||||
appName = "oriels",
|
appName = "oriels",
|
||||||
|
@ -14,7 +14,8 @@ if (!SK.Initialize(settings))
|
||||||
Input.HandSolid(Handed.Max, false);
|
Input.HandSolid(Handed.Max, false);
|
||||||
Input.HandVisible(Handed.Max, true);
|
Input.HandVisible(Handed.Max, true);
|
||||||
|
|
||||||
Mono mono = Mono.inst;
|
Oriels.Mono mono = Oriels.Mono.inst;
|
||||||
|
mono.Init();
|
||||||
while (SK.Step(() => {
|
while (SK.Step(() => {
|
||||||
mono.Step();
|
mono.Step();
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Reference in a new issue