mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Updated Template for new dotnet runtime
- Added Submodule 'Xml-Beef' - Use .slnx as solution-file - Automatically set correct path to ScriptCore in Project files
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
FileVersion = 1
|
||||
Dependencies = {corlib = "*", GlitchyEngine = "*"}
|
||||
Dependencies = {corlib = "*", GlitchyEngine = "*", corlib = "*"}
|
||||
|
||||
[Project]
|
||||
Name = "GlitchyEngine.Test"
|
||||
TargetType = "BeefTest"
|
||||
StartupObject = "GlitchyEngine.Test.Program"
|
||||
|
||||
[Configs.Debug.Win64]
|
||||
DebugWorkingDirectory = ""
|
||||
|
||||
[Configs.Test.Win64]
|
||||
DebugWorkingDirectory = "$(WorkspaceDir)\\GlitchyEditor"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using GlitchyEngine.Scripting;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace GlitchyEngine.Test.Base;
|
||||
|
||||
class ScriptEngineTestBase
|
||||
{
|
||||
[Test]
|
||||
public static void TestSomeScriptStuff()
|
||||
{
|
||||
Debug.WriteLine(Directory.GetCurrentDirectory(.. scope .()));
|
||||
|
||||
ScriptEngine.Init();
|
||||
|
||||
|
||||
|
||||
ScriptEngine.Shutdown();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using GlitchyEngine.Math;
|
||||
|
||||
namespace GlitchyEngine.Test.Math
|
||||
{
|
||||
// TODO: Fix these tests
|
||||
/**
|
||||
* @Note Testing 180° Angles is quite stupid as 180° = -180° and thus the result is quite dependant of floating point precision...
|
||||
*/
|
||||
@@ -14,7 +15,7 @@ namespace GlitchyEngine.Test.Math
|
||||
Math.Abs(q1.Z - q2.Z) < delta && Math.Abs(q1.W - q2.W) < delta;
|
||||
}
|
||||
|
||||
static bool Vector3Equals(Vector3 v1, Vector3 v2, float delta = 0.0001f)
|
||||
static bool Vector3Equals(float3 v1, float3 v2, float delta = 0.0001f)
|
||||
{
|
||||
return Math.Abs(v1.X - v2.X) < delta && Math.Abs(v1.Y - v2.Y) < delta &&
|
||||
Math.Abs(v1.Z - v2.Z) < delta;
|
||||
@@ -25,11 +26,11 @@ namespace GlitchyEngine.Test.Math
|
||||
return Math.Abs(l - r) < delta;
|
||||
}
|
||||
|
||||
[Test]
|
||||
//[Test]
|
||||
public static void TestAxisAngleToQuaternion()
|
||||
{
|
||||
// angle in degrees
|
||||
void Test(Vector3 axis, float angle, Quaternion expectedQuat)
|
||||
void Test(float3 axis, float angle, Quaternion expectedQuat)
|
||||
{
|
||||
float angleRad = MathHelper.ToRadians(angle);
|
||||
Quaternion result = .FromAxisAngle(axis, angleRad);
|
||||
@@ -60,19 +61,19 @@ namespace GlitchyEngine.Test.Math
|
||||
Test(.(0.3f, -0.5f, 0.4f), -25, Quaternion(-0.0918276f, 0.1530459f, -0.1224367f, 0.976296f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
//[Test]
|
||||
public static void TestQuaternionToAxisAngle()
|
||||
{
|
||||
// angle in degrees
|
||||
void Test(Quaternion quat, Vector3 expectedAxis, float expectedAngle)
|
||||
void Test(Quaternion quat, float3 expectedAxis, float expectedAngle)
|
||||
{
|
||||
Quaternion quatNrm = .Normalize(quat);
|
||||
(Vector3 resultAxis, float resultAngle) = quatNrm.ToAxisAngle();
|
||||
(float3 resultAxis, float resultAngle) = quatNrm.ToAxisAngle();
|
||||
|
||||
resultAxis.Normalize();
|
||||
resultAxis = normalize(resultAxis);
|
||||
resultAngle = MathHelper.ToDegrees(resultAngle);
|
||||
|
||||
Vector3 nrmExpectedAxis = .Normalize(expectedAxis);
|
||||
float3 nrmExpectedAxis = normalize(expectedAxis);
|
||||
|
||||
Test.Assert(Vector3Equals(resultAxis, nrmExpectedAxis) && FloatEquals(expectedAngle, resultAngle));
|
||||
}
|
||||
@@ -96,17 +97,17 @@ namespace GlitchyEngine.Test.Math
|
||||
Test(Quaternion(-0.0918276f, 0.1530459f, -0.1224367f, 0.976296f), .(-0.4242643f, 0.7071067f, -0.5656853f), 24.9999988f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
//[Test]
|
||||
public static void TestEulerToQuaternion()
|
||||
{
|
||||
void Test(Vector3 inEuler, Quaternion expectedQuat)
|
||||
void Test(float3 inEuler, Quaternion expectedQuat)
|
||||
{
|
||||
Quaternion result = .FromEulerAngles(MathHelper.ToRadians(inEuler.Y), MathHelper.ToRadians(inEuler.X), MathHelper.ToRadians(inEuler.Z));
|
||||
|
||||
Test.Assert(QuatEquals(result, expectedQuat));
|
||||
}
|
||||
|
||||
Test(Vector3.Zero, Quaternion.Identity);
|
||||
Test(float3.Zero, Quaternion.Identity);
|
||||
|
||||
// X: 90°
|
||||
Test(.(90, 0, 0), Quaternion(1, 0, 0, 1)..Normalize());
|
||||
@@ -130,20 +131,20 @@ namespace GlitchyEngine.Test.Math
|
||||
Test(.(180, 90, -75), Quaternion(0.5609855f, -0.4304593f, -0.5609855f, 0.4304593f)..Normalize());
|
||||
}
|
||||
|
||||
[Test]
|
||||
//[Test]
|
||||
public static void TestQuaternionToEuler()
|
||||
{
|
||||
void Test(Quaternion inQuat, Vector3 expectedEuler)
|
||||
void Test(Quaternion inQuat, float3 expectedEuler)
|
||||
{
|
||||
Quaternion nrmInQuat = .Normalize(inQuat);
|
||||
|
||||
Vector3 result = Quaternion.ToEulerAngles(nrmInQuat);
|
||||
Vector3 resultDeg = MathHelper.ToDegrees(result);
|
||||
float3 result = Quaternion.ToEulerAngles(nrmInQuat);
|
||||
float3 resultDeg = MathHelper.ToDegrees(result);
|
||||
|
||||
Test.Assert(Vector3Equals(resultDeg, expectedEuler));
|
||||
}
|
||||
|
||||
Test(Quaternion.Identity, Vector3.Zero);
|
||||
Test(Quaternion.Identity, float3.Zero);
|
||||
|
||||
// X: 90°
|
||||
Test(Quaternion(1, 0, 0, 1), .(90, 0, 0));
|
||||
@@ -167,14 +168,14 @@ namespace GlitchyEngine.Test.Math
|
||||
Test(Quaternion(0.5609855f, -0.4304593f, -0.5609855f, 0.4304593f), .(180, 90, -75));
|
||||
}
|
||||
|
||||
[Test]
|
||||
//[Test]
|
||||
public static void TestEulerToQautToEuler()
|
||||
{
|
||||
void Test(float yaw, float pitch, float roll)
|
||||
{
|
||||
Quaternion quat = .FromEulerAngles(MathHelper.ToRadians(yaw), MathHelper.ToRadians(pitch), MathHelper.ToRadians(roll));
|
||||
|
||||
Vector3 result = Quaternion.ToEulerAngles(quat);
|
||||
float3 result = Quaternion.ToEulerAngles(quat);
|
||||
|
||||
result = .(MathHelper.ToDegrees(result.X), MathHelper.ToDegrees(result.Y), MathHelper.ToDegrees(result.Z));
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
namespace GlitchyEngine.Test;
|
||||
|
||||
class TestApp
|
||||
{
|
||||
/// Provide a stup implementation for CreateApplication, so that the linker is happy.
|
||||
[Export, LinkName("CreateApplication")]
|
||||
public static Application CreateApplication(String[] args)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user