Skip to content

Commit

Permalink
Merge branch 'test-failures'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Dec 28, 2023
2 parents aa1f65c + daed902 commit efcc1b4
Show file tree
Hide file tree
Showing 20 changed files with 871 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
dotnet-version: '7.0.x'
- name: 'Test'
run: 'dotnet test -v minimal --filter "TestCategory!=Proprietary"'
run: 'dotnet test -v minimal --filter "TestCategory!=Proprietary" -s Test.runsettings'
release:
runs-on: 'ubuntu-latest'
steps:
Expand Down
11 changes: 11 additions & 0 deletions Test.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
</RunConfiguration>

<NUnit>
<InternalTraceLevel>Debug</InternalTraceLevel>
<NumberOfTestWorkers>1</NumberOfTestWorkers>
</NUnit>
</RunSettings>
120 changes: 63 additions & 57 deletions ZenKit.Test/TestMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,69 @@ public void SetUp()

[Test]
public void TestLoadG1()
{
var mat = new Material("./Samples/G1/DEMON_DIE_BODY.MAT");
Assert.That(mat.Name, Is.EqualTo("BODY"));
Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
Assert.That(mat.Color.R, Is.EqualTo(115));
Assert.That(mat.Color.G, Is.EqualTo(91));
Assert.That(mat.Color.B, Is.EqualTo(77));
Assert.That(mat.Color.A, Is.EqualTo(255));
Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(9.9999997e-005f));
Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
Assert.That(mat.DisableCollision, Is.EqualTo(false));
Assert.That(mat.DisableLightmap, Is.EqualTo(false));
Assert.That(mat.DontCollapse, Is.EqualTo(false));
Assert.That(mat.DetailObject, Is.EqualTo(""));
Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
}
{
var mat = new Material("./Samples/G1/DEMON_DIE_BODY.MAT");
Assert.Multiple(() =>
{
Assert.That(mat.Name, Is.EqualTo("BODY"));
Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
Assert.That(mat.Color.R, Is.EqualTo(115));
Assert.That(mat.Color.G, Is.EqualTo(91));
Assert.That(mat.Color.B, Is.EqualTo(77));
Assert.That(mat.Color.A, Is.EqualTo(255));
Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(9.9999997e-005f));
Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
Assert.That(mat.DisableCollision, Is.EqualTo(false));
Assert.That(mat.DisableLightmap, Is.EqualTo(false));
Assert.That(mat.DontCollapse, Is.EqualTo(false));
Assert.That(mat.DetailObject, Is.EqualTo(""));
Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
});
}

[Test]
[Test]
public void TestLoadG2()
{
var mat = new Material("./Samples/G2/DEMON_DIE_BODY.MAT");
Assert.That(mat.Name, Is.EqualTo("BODY"));
Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
Assert.That(mat.Color.R, Is.EqualTo(115));
Assert.That(mat.Color.G, Is.EqualTo(91));
Assert.That(mat.Color.B, Is.EqualTo(77));
Assert.That(mat.Color.A, Is.EqualTo(255));
Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(0.0f));
Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
Assert.That(mat.DisableCollision, Is.EqualTo(false));
Assert.That(mat.DisableLightmap, Is.EqualTo(false));
Assert.That(mat.DontCollapse, Is.EqualTo(false));
Assert.That(mat.DetailObject, Is.EqualTo(""));
Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
Assert.That(mat.AlphaFunction, Is.EqualTo(AlphaFunction.None));
Assert.That(mat.DetailObjectScale, Is.EqualTo(1.0f));
Assert.That(mat.ForceOccluder, Is.EqualTo(false));
Assert.That(mat.EnvironmentMapping, Is.EqualTo(false));
Assert.That(mat.EnvironmentMappingStrength, Is.EqualTo(1.0f));
Assert.That(mat.WaveMode, Is.EqualTo(WaveMode.None));
Assert.That(mat.WaveSpeed, Is.EqualTo(WaveSpeed.Normal));
Assert.That(mat.WaveAmplitude, Is.EqualTo(30.0f));
Assert.That(mat.WaveGridSize, Is.EqualTo(100.0f));
Assert.That(mat.IgnoreSun, Is.EqualTo(false));
}
{
var mat = new Material("./Samples/G2/DEMON_DIE_BODY.MAT");
Assert.Multiple(() =>
{
Assert.That(mat.Name, Is.EqualTo("BODY"));
Assert.That(mat.Group, Is.EqualTo(MaterialGroup.Undefined));
Assert.That(mat.Color.R, Is.EqualTo(115));
Assert.That(mat.Color.G, Is.EqualTo(91));
Assert.That(mat.Color.B, Is.EqualTo(77));
Assert.That(mat.Color.A, Is.EqualTo(255));
Assert.That(mat.SmoothAngle, Is.EqualTo(60.0f));
Assert.That(mat.Texture, Is.EqualTo("DEM_BODY_V0.TGA"));
Assert.That(mat.TextureScale.X, Is.EqualTo(512.0f));
Assert.That(mat.TextureScale.Y, Is.EqualTo(512.0f));
Assert.That(mat.TextureAnimationFps, Is.EqualTo(0.0f));
Assert.That(mat.TextureAnimationMapping, Is.EqualTo(AnimationMapping.None));
Assert.That(mat.TextureAnimationMappingDirection.X, Is.EqualTo(0.0f));
Assert.That(mat.TextureAnimationMappingDirection.Y, Is.EqualTo(0.0f));
Assert.That(mat.DisableCollision, Is.EqualTo(false));
Assert.That(mat.DisableLightmap, Is.EqualTo(false));
Assert.That(mat.DontCollapse, Is.EqualTo(false));
Assert.That(mat.DetailObject, Is.EqualTo(""));
Assert.That(mat.DefaultMapping.X, Is.EqualTo(2.34375f));
Assert.That(mat.DefaultMapping.Y, Is.EqualTo(2.34375f));
Assert.That(mat.AlphaFunction, Is.EqualTo(AlphaFunction.None));
Assert.That(mat.DetailObjectScale, Is.EqualTo(1.0f));
Assert.That(mat.ForceOccluder, Is.EqualTo(false));
Assert.That(mat.EnvironmentMapping, Is.EqualTo(false));
Assert.That(mat.EnvironmentMappingStrength, Is.EqualTo(1.0f));
Assert.That(mat.WaveMode, Is.EqualTo(WaveMode.None));
Assert.That(mat.WaveSpeed, Is.EqualTo(WaveSpeed.Normal));
Assert.That(mat.WaveAmplitude, Is.EqualTo(30.0f));
Assert.That(mat.WaveGridSize, Is.EqualTo(100.0f));
Assert.That(mat.IgnoreSun, Is.EqualTo(false));
});
}
}
82 changes: 74 additions & 8 deletions ZenKit/BspTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using ZenKit.Util;

namespace ZenKit
Expand Down Expand Up @@ -97,17 +98,19 @@ public interface IBspTree : ICacheable<IBspTree>
public List<uint> PolygonIndices { get; }
public List<uint> LeafPolygonIndices { get; }
public List<uint> PortalPolygonIndices { get; }
public ulong LightPointCount { get; }
public List<Vector3> LightPoints { get; }
public List<ulong> LeafNodeIndices { get; }
public ulong NodeCount { get; }
public List<BspNode> Nodes { get; }
public List<IBspSector> Sectors { get; }

public ulong SectorCount { get; }

public IBspSector GetSector(ulong i)
{
return Sectors[(int)i];
}
public IBspSector GetSector(ulong i);

public Vector3 GetLightPoint(ulong i);
public BspNode GetNode(ulong i);
}

[Serializable]
Expand All @@ -117,12 +120,33 @@ public class CachedBspTree : IBspTree
public List<uint> PolygonIndices { get; set; }

Check warning on line 120 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (windows-2019)

Non-nullable property 'PolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 120 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / release

Non-nullable property 'PolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 120 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Non-nullable property 'PolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public List<uint> LeafPolygonIndices { get; set; }

Check warning on line 121 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (windows-2019)

Non-nullable property 'LeafPolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 121 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / release

Non-nullable property 'LeafPolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 121 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Non-nullable property 'LeafPolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public List<uint> PortalPolygonIndices { get; set; }

Check warning on line 122 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (windows-2019)

Non-nullable property 'PortalPolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 122 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / release

Non-nullable property 'PortalPolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 122 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Non-nullable property 'PortalPolygonIndices' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public ulong LightPointCount => (ulong)LightPoints.LongCount();

public List<Vector3> LightPoints { get; set; }

Check warning on line 126 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (windows-2019)

Non-nullable property 'LightPoints' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 126 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / release

Non-nullable property 'LightPoints' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 126 in ZenKit/BspTree.cs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Non-nullable property 'LightPoints' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public List<ulong> LeafNodeIndices { get; set; }

public ulong NodeCount => (ulong)Nodes.LongCount();

public List<BspNode> Nodes { get; set; }
public List<IBspSector> Sectors { get; set; }
public ulong SectorCount => (ulong)Sectors.LongCount();

public IBspSector GetSector(ulong i)
{
return Sectors[(int)i];
}

public Vector3 GetLightPoint(ulong i)
{
return LightPoints[(int)i];
}

public BspNode GetNode(ulong i)
{
return Nodes[(int)i];
}

public IBspTree Cache()
{
return this;
Expand Down Expand Up @@ -154,13 +178,45 @@ internal BspTree(UIntPtr handle)
public List<uint> PortalPolygonIndices =>
Native.ZkBspTree_getPortalPolygonIndices(_handle, out var count).MarshalAsList<uint>(count);

public List<Vector3> LightPoints =>
Native.ZkBspTree_getLightPoints(_handle, out var count).MarshalAsList<Vector3>(count);
public ulong LightPointCount => Native.ZkBspTree_getLightPointCount(_handle);

public List<Vector3> LightPoints
{
get
{
var points = new List<Vector3>();

Native.ZkBspTree_enumerateLightPoints(_handle, (_, v) =>
{
points.Add(v);
return false;
}, UIntPtr.Zero);

return points;
}
}

public List<ulong> LeafNodeIndices =>
Native.ZkBspTree_getLeafNodeIndices(_handle, out var count).MarshalAsList<ulong>(count);

public List<BspNode> Nodes => Native.ZkBspTree_getNodes(_handle, out var count).MarshalAsList<BspNode>(count);
public ulong NodeCount => Native.ZkBspTree_getNodeCount(_handle);

public List<BspNode> Nodes
{
get
{
var nodes = new List<BspNode>();

Native.ZkBspTree_enumerateNodes(_handle, (_, node) =>
{
nodes.Add(Marshal.PtrToStructure<BspNode>(node));
return false;
}, UIntPtr.Zero);

return nodes;
}
}

public ulong SectorCount => Native.ZkBspTree_getSectorCount(_handle);

public List<IBspSector> Sectors
Expand Down Expand Up @@ -204,9 +260,19 @@ public bool IsCached()
return false;
}

public BspSector GetSector(ulong i)
public IBspSector GetSector(ulong i)
{
return new BspSector(Native.ZkBspTree_getSector(_handle, i));
}

public Vector3 GetLightPoint(ulong i)
{
return Native.ZkBspTree_getLightPoint(_handle, i);
}

public BspNode GetNode(ulong i)
{
return Native.ZkBspTree_getNode(_handle, i);
}
}
}
41 changes: 1 addition & 40 deletions ZenKit/DaedalusInstance.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using ZenKit.Daedalus;
using ZenKit.Util;

namespace ZenKit
{
Expand Down Expand Up @@ -31,31 +30,7 @@ public enum DaedalusInstanceType
Invalid = 21
}

public interface IDaedalusInstance : ICacheable<IDaedalusInstance>
{
public DaedalusInstanceType Type { get; }
public uint Index { get; }
}

[Serializable]
public class CachedDaedalusInstance : IDaedalusInstance
{
public DaedalusInstanceType Type { get; set; }
public uint Index { get; set; }

public IDaedalusInstance Cache()
{
return this;
}

public bool IsCached()
{
return true;
}
}


public class DaedalusInstance : IDaedalusInstance
public class DaedalusInstance
{
protected DaedalusInstance(UIntPtr handle)
{
Expand All @@ -67,20 +42,6 @@ protected DaedalusInstance(UIntPtr handle)
public DaedalusInstanceType Type => Native.ZkDaedalusInstance_getType(Handle);
public uint Index => Native.ZkDaedalusInstance_getIndex(Handle);

public IDaedalusInstance Cache()
{
return new CachedDaedalusInstance
{
Type = Type,
Index = Index
};
}

public bool IsCached()
{
return false;
}

public static DaedalusInstance? FromNative(UIntPtr handle)
{
if (handle == UIntPtr.Zero) return null;
Expand Down
Loading

0 comments on commit efcc1b4

Please sign in to comment.