@@ -26,21 +26,23 @@ private struct RayTraversalResult
2626
2727 public UpdateCallback ? Callback { get ; set ; } = null ;
2828
29- // The buffer we're rendering to
29+ public Camera Camera { get ; set ; } = new Camera ( ) ;
30+
31+ public Scene ? Scene { get ; set ; } = null ;
32+
33+ // Reference to the Bitmap we're drawing to
3034 public Bitmap ? Buffer { get ; set ; } = null ;
3135
32- public Scene ? Scene { get ; set ; } = null ;
33- private Camera mCamera = new Camera ( ) ;
3436 private Intersector mIntersector = new Intersector ( ) ;
3537
36- public int TraceDepth { get ; set ; } = DEFAULT_TRACE_DEPTH ;
37-
38- public bool ApplyGlobalReflection { get ; set ; } = true ;
38+ public bool GlobalReflection { get ; set ; } = true ;
3939 public bool ComputeSpecular { get ; set ; } = false ;
4040 public bool ComputeDiffuse { get ; set ; } = false ;
4141 public bool ComputeAmbient { get ; set ; } = false ;
4242 public bool ComputeFog { get ; set ; } = false ;
4343
44+ public int TraceDepth { get ; set ; } = DEFAULT_TRACE_DEPTH ;
45+
4446 private bool mStopRender = false ;
4547
4648 public Raytracer ( ) { }
@@ -125,7 +127,7 @@ private Color trace(Ray ray, int depth)
125127 lit = lit . Add ( diff ) ;
126128 }
127129
128- if ( ApplyGlobalReflection && refl > 0 && depth < TraceDepth )
130+ if ( GlobalReflection && refl > 0 && depth < TraceDepth )
129131 {
130132 Ray reflected = new Ray ( intersectionPoint , r ) ;
131133 Color acc = trace ( reflected , depth + 1 ) ;
@@ -178,7 +180,7 @@ public void Render()
178180 int lastPercent = 0 ;
179181 long count = 0 ;
180182
181- Matrix4 i2v = imageToViewportTransform ( imgWidth , imgHeight , mCamera ) ;
183+ Matrix4 i2v = imageToViewportTransform ( imgWidth , imgHeight , Camera ) ;
182184
183185 for ( int p = 0 ; ! mStopRender && p < imgWidth ; ++ p )
184186 {
@@ -189,9 +191,9 @@ public void Render()
189191 lastPercent = percent ;
190192
191193 Vector mapped = i2v . Multiply ( new Vector ( p , q , 0 ) ) ;
192- Vector dir = mapped - mCamera . Eye ;
194+ Vector dir = mapped - Camera . Eye ;
193195 dir . Normalize ( ) ;
194- Ray ray = new Ray ( mCamera . Eye , dir ) ;
196+ Ray ray = new Ray ( Camera . Eye , dir ) ;
195197
196198 Color c = trace ( ray , 1 ) ;
197199
@@ -209,8 +211,5 @@ public void Render()
209211 mStopRender = false ;
210212 }
211213
212- public Camera getCamera ( ) => mCamera ;
213-
214- public void setCamera ( Camera camera ) => mCamera = camera ;
215214 }
216215}
0 commit comments