@@ -26,8 +26,6 @@ struct Vec3
26
26
{
27
27
public Num X , Y , Z ;
28
28
29
- public static readonly Vec3 Zero = new Vec3 ( ) ;
30
-
31
29
public Vec3 ( Num x , Num y , Num z )
32
30
{
33
31
X = x ;
@@ -115,6 +113,12 @@ public static Vec3 Normalize(Vec3 v)
115
113
}
116
114
}
117
115
116
+ static class Vec3Const
117
+ {
118
+ // Required for AOT with https://github.com/dotnet/runtime/issues/109170
119
+ public static readonly Vec3 Zero = new Vec3 ( ) ;
120
+ }
121
+
118
122
struct Ray
119
123
{
120
124
public Vec3 Org ;
@@ -226,7 +230,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth)
226
230
}
227
231
}
228
232
229
- if ( obj == null ) return Vec3 . Zero ;
233
+ if ( obj == null ) return Vec3Const . Zero ;
230
234
231
235
var point_of_hit = ray . Org + ( ray . Dir * nearest ) ;
232
236
var normal = Sphere . Normal ( obj , point_of_hit ) ;
@@ -238,7 +242,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth)
238
242
normal = - normal ;
239
243
}
240
244
241
- Vec3 color = Vec3 . Zero ;
245
+ Vec3 color = Vec3Const . Zero ;
242
246
var reflection_ratio = obj . Reflection ;
243
247
244
248
foreach ( var l in scene . Lights )
@@ -309,7 +313,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth)
309
313
310
314
public static byte [ ] Render ( Scene scene , byte [ ] pixels )
311
315
{
312
- var eye = Vec3 . Zero ;
316
+ var eye = Vec3Const . Zero ;
313
317
Num h = ( Num ) Math . Tan ( ( ( fov / 360 ) * ( 2 * PI ) ) / 2 ) * 2 ;
314
318
Num w = h * Width / Height ;
315
319
0 commit comments