Skip to content

Commit 877fb8e

Browse files
Merge pull request #1 from vpenades/master
develop
2 parents c71bf2c + 8a033fb commit 877fb8e

File tree

28 files changed

+242
-193
lines changed

28 files changed

+242
-193
lines changed

.github/workflows/Test.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/TestCommit.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ jobs:
77

88
runs-on: ${{ matrix.os }}
99
strategy:
10-
matrix:
11-
dotnet-version: [ '8.0.x' ]
12-
os: [windows-latest, ubuntu-latest]
10+
matrix:
11+
os: [windows-latest, ubuntu-latest, macos-latest]
1312

14-
steps:
15-
- uses: actions/checkout@v4
13+
steps:
14+
15+
- name: net48 on windows
16+
if: runner.os == 'Windows'
17+
run: choco install netfx-4.8 --ignore-checksums
1618

17-
- name: Setup dotnet ${{ matrix.dotnet-version }}
18-
uses: actions/setup-dotnet@v4
19+
- uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '6.x'
22+
23+
- uses: actions/setup-dotnet@v4
1924
with:
20-
dotnet-version: ${{ matrix.dotnet-version }}
25+
dotnet-version: '8.x'
26+
27+
- uses: actions/checkout@v4
2128

2229
- name: Install dependencies
2330
run: dotnet restore
@@ -26,5 +33,12 @@ jobs:
2633
# https://github.com/dotnet/core/issues/7840 failed to build with 0 errors
2734
run: dotnet build --configuration Debug --no-restore --disable-build-servers
2835

29-
- name: Test
30-
run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --no-build --verbosity diagnostic
36+
- name: Test net48
37+
if: runner.os == 'Windows'
38+
run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --framework net48 --no-build
39+
40+
- name: Test net6
41+
run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --framework net6 --no-build
42+
43+
- name: Test net8
44+
run: dotnet test ./tests/SharpGLTF.Ext.3DTiles.Tests/SharpGLTF.Ext.3DTiles.Tests.csproj --framework net8 --no-build

SharpGLTF.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
README.md = README.md
1818
SharpGLTF.Build.sh = SharpGLTF.Build.sh
1919
SharpGLTF.ruleset = SharpGLTF.ruleset
20-
.github\workflows\Test.yml = .github\workflows\Test.yml
2120
.github\workflows\TestCommit.yml = .github\workflows\TestCommit.yml
2221
EndProjectSection
2322
EndProject

build/SharpGLTF.CodeGen/MainSchemaProcessor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ public override void PrepareTypes(CSharpEmitter newEmitter, SchemaType.Context c
8989
newEmitter.SetRuntimeName("CUBICSPLINE-LINEAR-STEP", "AnimationInterpolationMode");
9090
newEmitter.SetRuntimeName("LINEAR-NEAREST", "TextureInterpolationFilter");
9191
newEmitter.SetRuntimeName("CLAMP_TO_EDGE-MIRRORED_REPEAT-REPEAT", "TextureWrapMode");
92-
newEmitter.SetRuntimeName("LINEAR-LINEAR_MIPMAP_LINEAR-LINEAR_MIPMAP_NEAREST-NEAREST-NEAREST_MIPMAP_LINEAR-NEAREST_MIPMAP_NEAREST", "TextureMipMapFilter");
92+
newEmitter.SetRuntimeName("LINEAR-LINEAR_MIPMAP_LINEAR-LINEAR_MIPMAP_NEAREST-NEAREST-NEAREST_MIPMAP_LINEAR-NEAREST_MIPMAP_NEAREST", "TextureMipMapFilter");
93+
94+
// add "pointer" enum value to PropertyPath, which is required by KHR_animation_pointer
95+
var propertyPathEnum = ctx.FindEnum("rotation-scale-translation-weights");
96+
propertyPathEnum?.SetValue("pointer", 0);
9397

9498
var meshClass = ctx.FindClass("Mesh");
9599
if (meshClass != null)

build/SharpGLTF.CodeGen/SharpGLTF.CodeGen.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
<ItemGroup>
1010
<PackageReference Include="LibGit2Sharp" Version="0.30.0" />
11-
<PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="11.0.2" />
12-
<PackageReference Include="NJsonSchema.NewtonsoftJson" Version="11.0.2" />
11+
<PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="11.1.0" />
12+
<PackageReference Include="NJsonSchema.NewtonsoftJson" Version="11.1.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

examples/SharpGLTF.Runtime.MonoGame/SharpGLTF.Runtime.MonoGame.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
11+
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

src/SharpGLTF.Core/IO/Serialization.cs

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static Object AsEnum(this in Utf8JsonReader reader, Type enumType)
4343
try { return Enum.Parse(enumType, jsonVal, true); }
4444
catch (System.ArgumentException ex)
4545
{
46-
throw new System.Text.Json.JsonException($"Value {jsonVal} not found int {enumType}", ex);
46+
throw new System.Text.Json.JsonException($"Value '{jsonVal}' not found in '{enumType}'", ex);
4747
}
4848
}
4949

@@ -102,58 +102,54 @@ public static T GetValueAs<T>(this in Utf8JsonReader reader)
102102

103103
public static bool TryWriteProperty(this Utf8JsonWriter writer, string property, Object value)
104104
{
105-
if (value is String vstr) { writer.WriteString(property, vstr); return true; }
106-
if (value is Boolean vbol) { writer.WriteBoolean(property, vbol); return true; }
107-
108-
if (value is Byte vu8) { writer.WriteNumber(property, vu8); return true; }
109-
if (value is UInt16 vu16) { writer.WriteNumber(property, vu16); return true; }
110-
if (value is UInt32 vu32) { writer.WriteNumber(property, vu32); return true; }
111-
if (value is UInt64 vu64) { writer.WriteNumber(property, vu64); return true; }
112-
113-
if (value is SByte vs8) { writer.WriteNumber(property, vs8); return true; }
114-
if (value is Int16 vs16) { writer.WriteNumber(property, vs16); return true; }
115-
if (value is Int32 vs32) { writer.WriteNumber(property, vs32); return true; }
116-
if (value is Int64 vs64) { writer.WriteNumber(property, vs64); return true; }
117-
118-
if (value is Single vf32) { writer.WriteNumber(property, vf32); return true; }
119-
if (value is Double vf64) { writer.WriteNumber(property, vf64); return true; }
120-
if (value is Decimal vfxx) { writer.WriteNumber(property, vfxx); return true; }
121-
122-
if (value is Vector2 vvv2) { writer.WritePropertyName(property); writer.WriteVector2(vvv2); return true; }
123-
if (value is Vector3 vvv3) { writer.WritePropertyName(property); writer.WriteVector3(vvv3); return true; }
124-
if (value is Vector4 vvv4) { writer.WritePropertyName(property); writer.WriteVector4(vvv4); return true; }
125-
if (value is Quaternion qqq4) { writer.WritePropertyName(property); writer.WriteQuaternion(qqq4); return true; }
126-
if (value is Matrix4x4 mm44) { writer.WritePropertyName(property); writer.WriteMatrix4x4(mm44); return true; }
127-
128-
return false;
105+
switch (value)
106+
{
107+
case string vstr: writer.WriteString(property, vstr); return true;
108+
case bool vbol: writer.WriteBoolean(property, vbol); return true;
109+
case byte vu8: writer.WriteNumber(property, vu8); return true;
110+
case ushort vu16: writer.WriteNumber(property, vu16); return true;
111+
case uint vu32: writer.WriteNumber(property, vu32); return true;
112+
case ulong vu64: writer.WriteNumber(property, vu64); return true;
113+
case sbyte vs8: writer.WriteNumber(property, vs8); return true;
114+
case short vs16: writer.WriteNumber(property, vs16); return true;
115+
case int vs32: writer.WriteNumber(property, vs32); return true;
116+
case long vs64: writer.WriteNumber(property, vs64); return true;
117+
case float vf32: writer.WriteNumber(property, vf32); return true;
118+
case double vf64: writer.WriteNumber(property, vf64); return true;
119+
case decimal vfxx: writer.WriteNumber(property, vfxx); return true;
120+
case Vector2 vvv2: writer.WritePropertyName(property); writer.WriteVector2(vvv2); return true;
121+
case Vector3 vvv3: writer.WritePropertyName(property); writer.WriteVector3(vvv3); return true;
122+
case Vector4 vvv4: writer.WritePropertyName(property); writer.WriteVector4(vvv4); return true;
123+
case Quaternion qqq4: writer.WritePropertyName(property); writer.WriteQuaternion(qqq4); return true;
124+
case Matrix4x4 mm44: writer.WritePropertyName(property); writer.WriteMatrix4x4(mm44); return true;
125+
default: return false;
126+
}
129127
}
130128

131129
public static bool TryWriteValue(this Utf8JsonWriter writer, Object value)
132130
{
133-
if (value is String vstr) { writer.WriteStringValue(vstr); return true; }
134-
if (value is Boolean vbol) { writer.WriteBooleanValue(vbol); return true; }
135-
136-
if (value is Byte vu8) { writer.WriteNumberValue(vu8); return true; }
137-
if (value is UInt16 vu16) { writer.WriteNumberValue(vu16); return true; }
138-
if (value is UInt32 vu32) { writer.WriteNumberValue(vu32); return true; }
139-
if (value is UInt64 vu64) { writer.WriteNumberValue(vu64); return true; }
140-
141-
if (value is SByte vs8) { writer.WriteNumberValue(vs8); return true; }
142-
if (value is Int16 vs16) { writer.WriteNumberValue(vs16); return true; }
143-
if (value is Int32 vs32) { writer.WriteNumberValue(vs32); return true; }
144-
if (value is Int64 vs64) { writer.WriteNumberValue(vs64); return true; }
145-
146-
if (value is Single vf32) { writer.WriteNumberValue(vf32); return true; }
147-
if (value is Double vf64) { writer.WriteNumberValue(vf64); return true; }
148-
if (value is Decimal vfxx) { writer.WriteNumberValue(vfxx); return true; }
149-
150-
if (value is Vector2 vvv2) { writer.WriteVector2(vvv2); return true; }
151-
if (value is Vector3 vvv3) { writer.WriteVector3(vvv3); return true; }
152-
if (value is Vector4 vvv4) { writer.WriteVector4(vvv4); return true; }
153-
if (value is Quaternion qqq4) { writer.WriteQuaternion(qqq4); return true; }
154-
if (value is Matrix4x4 mm44) { writer.WriteMatrix4x4(mm44); return true; }
155-
156-
return false;
131+
switch (value)
132+
{
133+
case string vstr: writer.WriteStringValue(vstr); return true;
134+
case bool vbol: writer.WriteBooleanValue(vbol); return true;
135+
case byte vu8: writer.WriteNumberValue(vu8); return true;
136+
case ushort vu16: writer.WriteNumberValue(vu16); return true;
137+
case uint vu32: writer.WriteNumberValue(vu32); return true;
138+
case ulong vu64: writer.WriteNumberValue(vu64); return true;
139+
case sbyte vs8: writer.WriteNumberValue(vs8); return true;
140+
case short vs16: writer.WriteNumberValue(vs16); return true;
141+
case int vs32: writer.WriteNumberValue(vs32); return true;
142+
case long vs64: writer.WriteNumberValue(vs64); return true;
143+
case float vf32: writer.WriteNumberValue(vf32); return true;
144+
case double vf64: writer.WriteNumberValue(vf64); return true;
145+
case decimal vfxx: writer.WriteNumberValue(vfxx); return true;
146+
case Vector2 vvv2: writer.WriteVector2(vvv2); return true;
147+
case Vector3 vvv3: writer.WriteVector3(vvv3); return true;
148+
case Vector4 vvv4: writer.WriteVector4(vvv4); return true;
149+
case Quaternion qqq4: writer.WriteQuaternion(qqq4); return true;
150+
case Matrix4x4 mm44: writer.WriteMatrix4x4(mm44); return true;
151+
default: return false;
152+
}
157153
}
158154

159155
public static void WriteVector2(this Utf8JsonWriter writer, Vector2 v)

src/SharpGLTF.Core/Schema2/Generated/gltf.g.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public enum PropertyPath
7777
rotation,
7878
scale,
7979
weights,
80+
pointer,
8081
}
8182

8283

src/SharpGLTF.Core/Schema2/Serialization.ReadContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private static MODEL _FilterErrors((MODEL Model, Validation.ValidationResult Val
315315

316316
// we must do a basic validation before resolving external dependencies
317317

318-
if (true)
318+
if (this.Validation != VALIDATIONMODE.Skip) // disable validation at your own risk
319319
{
320320
root.ValidateReferences(vcontext.GetContext());
321321
var ex = vcontext.Errors.FirstOrDefault();
@@ -326,10 +326,10 @@ private static MODEL _FilterErrors((MODEL Model, Validation.ValidationResult Val
326326

327327
root._ResolveSatelliteDependencies(this);
328328

329-
// full validation
329+
// content validation
330330

331-
if (this.Validation != VALIDATIONMODE.Skip)
332-
{
331+
if (this.Validation != VALIDATIONMODE.Skip) // disable validation at your own risk
332+
{
333333
root.ValidateContent(vcontext.GetContext());
334334
var ex = vcontext.Errors.FirstOrDefault();
335335
if (ex != null) return (null, vcontext);

src/SharpGLTF.Core/Schema2/gltf.Accessors.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,14 @@ internal void ValidateMatrices4x3(VALIDATIONCTX validate, bool mustInvert = true
576576

577577
internal void ValidateAnimationInput(VALIDATIONCTX validate)
578578
{
579-
SourceBufferView.ValidateBufferUsagePlainData(validate);
579+
SourceBufferView.ValidateBufferUsagePlainData(validate, false); // as per glTF specification, animation accessors must not have ByteStride
580580

581581
validate.IsAnyOf(nameof(Dimensions), Dimensions, DimensionType.SCALAR);
582582
}
583583

584584
internal void ValidateAnimationOutput(VALIDATIONCTX validate)
585585
{
586-
SourceBufferView.ValidateBufferUsagePlainData(validate);
586+
SourceBufferView.ValidateBufferUsagePlainData(validate, false); // as per glTF specification, animation accessors must not have ByteStride
587587

588588
validate.IsAnyOf(nameof(Dimensions), Dimensions, DimensionType.SCALAR, DimensionType.VEC3, DimensionType.VEC4);
589589
}

0 commit comments

Comments
 (0)