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;
|
||||
|
||||
public class Mono {
|
||||
private static readonly Lazy<Mono> lazy = new Lazy<Mono>(() => new Mono());
|
||||
public static Mono inst { get { return lazy.Value; } }
|
||||
private static readonly Lazy<Oriels.Mono> lazy = new Lazy<Oriels.Mono>(() => new Oriels.Mono());
|
||||
public static Oriels.Mono inst { get { return lazy.Value; } }
|
||||
|
||||
public PullRequest.Noise noise = new PullRequest.Noise(939949595);
|
||||
|
||||
|
@ -34,6 +34,9 @@ public class Mono {
|
|||
public Mono() {
|
||||
Renderer.SetClip(0.02f, 1000f);
|
||||
|
||||
}
|
||||
|
||||
public void Init() {
|
||||
spaceMono.Init();
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public static class PullRequest {
|
|||
}
|
||||
|
||||
int position;
|
||||
public float value {
|
||||
public float uvalue {
|
||||
get {
|
||||
float v = RNG(position, seed) / (float)CAP;
|
||||
position++;
|
||||
|
@ -119,8 +119,14 @@ public static class PullRequest {
|
|||
}
|
||||
}
|
||||
|
||||
public float D1(int position) {
|
||||
return RNG(position, seed) / (float)CAP;
|
||||
public float value { // not ideal *loss of precision*
|
||||
get {
|
||||
return uvalue * 2 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public float D1(int pos) {
|
||||
return RNG(pos, seed) / (float)CAP;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public uint RNG(int position, uint seed) {
|
||||
uint mangled = (uint)position;
|
||||
public uint RNG(int pos, uint seed) {
|
||||
uint mangled = (uint)pos;
|
||||
mangled *= BIT_NOISE1;
|
||||
mangled += seed;
|
||||
mangled ^= mangled >> 8;
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Space;
|
||||
public class Mono {
|
||||
|
||||
Node[] nodes = new Node[18];
|
||||
Vec3 playerPos;
|
||||
List<Vec3> enemies = new List<Vec3>();
|
||||
float spawnTime;
|
||||
|
@ -26,12 +26,25 @@ public class Mono {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void Frame() {
|
||||
Rig rig = Oriels.Mono.inst.rig;
|
||||
Oriel oriel = Oriels.Mono.inst.oriel;
|
||||
Oriels.Rig rig = Oriels.Mono.inst.rig;
|
||||
Oriels.Oriel oriel = Oriels.Mono.inst.oriel;
|
||||
|
||||
Matrix simMatrix = Matrix.TRS(
|
||||
new Vec3(0, 0, 0), //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),
|
||||
|
@ -65,8 +78,14 @@ public class Mono {
|
|||
|
||||
|
||||
|
||||
|
||||
// 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,
|
||||
Matrix.TRS(cursor, Quat.Identity, Vec3.One * 0.02f),
|
||||
new Color(1f, 1f, 1f)
|
||||
|
@ -153,3 +172,11 @@ public class Mono {
|
|||
float moveP = 8f;
|
||||
float moveI = 0.2f;
|
||||
}
|
||||
|
||||
public class Node {
|
||||
public Vec3 pos;
|
||||
|
||||
public Node(Vec3 pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using StereoKit;
|
||||
namespace Oriels;
|
||||
|
||||
public abstract class SpatialCursor {
|
||||
public Vec3 p0, p1, p2, p3;
|
||||
|
@ -26,7 +25,7 @@ public class StretchCursor : SpatialCursor {
|
|||
|
||||
model.Draw(Matrix.TS(p0, 0.06f));
|
||||
}
|
||||
public override void Calibrate() {}
|
||||
public override void Calibrate() { }
|
||||
}
|
||||
|
||||
public class ReachCursor : SpatialCursor {
|
||||
|
@ -80,7 +79,7 @@ public class TwistCursor : SpatialCursor {
|
|||
Quat from = Quat.LookAt(Vec3.Zero, quat * Vec3.Forward, twistFrom);
|
||||
float twist = (float)(Math.Acos(Vec3.Dot(from * Vec3.Up, quat * Vec3.Up)) / Math.PI);
|
||||
outty = Vec3.Dot(from * Vec3.Up, quat * Vec3.Right * (chirality ? 1 : -1)) > 0;
|
||||
|
||||
|
||||
p0 = pos + quat * Vec3.Forward * twist * str;
|
||||
|
||||
// Render
|
||||
|
@ -174,7 +173,7 @@ public class CubicFlow : SpatialCursor {
|
|||
// if toggle
|
||||
}
|
||||
|
||||
public override void Calibrate() {}
|
||||
public override void Calibrate() { }
|
||||
}
|
||||
|
||||
// a more symmetrical one would be cool
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
global using System;
|
||||
global using StereoKit;
|
||||
global using Oriels;
|
||||
// global using Oriels;
|
||||
|
||||
SKSettings settings = new SKSettings {
|
||||
appName = "oriels",
|
||||
|
@ -14,8 +14,9 @@ if (!SK.Initialize(settings))
|
|||
Input.HandSolid(Handed.Max, false);
|
||||
Input.HandVisible(Handed.Max, true);
|
||||
|
||||
Mono mono = Mono.inst;
|
||||
Oriels.Mono mono = Oriels.Mono.inst;
|
||||
mono.Init();
|
||||
while (SK.Step(() => {
|
||||
mono.Step();
|
||||
})) ;
|
||||
}));
|
||||
SK.Shutdown();
|
Loading…
Add table
Reference in a new issue