diff --git a/src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs b/src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs index 303f39f07..2ee7f0b81 100644 --- a/src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs +++ b/src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs @@ -26,8 +26,6 @@ struct Vec3 { public Num X, Y, Z; - public static readonly Vec3 Zero = new Vec3(); - public Vec3(Num x, Num y, Num z) { X = x; @@ -115,6 +113,12 @@ public static Vec3 Normalize(Vec3 v) } } + static class Vec3Const + { + // Required for AOT with https://github.com/dotnet/runtime/issues/109170 + public static readonly Vec3 Zero = new Vec3(); + } + struct Ray { public Vec3 Org; @@ -226,7 +230,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth) } } - if (obj == null) return Vec3.Zero; + if (obj == null) return Vec3Const.Zero; var point_of_hit = ray.Org + (ray.Dir * nearest); var normal = Sphere.Normal(obj, point_of_hit); @@ -238,7 +242,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth) normal = -normal; } - Vec3 color = Vec3.Zero; + Vec3 color = Vec3Const.Zero; var reflection_ratio = obj.Reflection; foreach(var l in scene.Lights) @@ -309,7 +313,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth) public static byte[] Render(Scene scene, byte[] pixels) { - var eye = Vec3.Zero; + var eye = Vec3Const.Zero; Num h = (Num)Math.Tan(((fov / 360) * (2 * PI)) / 2) * 2; Num w = h * Width / Height;