I am implementing a ray tracer and am having trouble with basic Java references :/ I have been staring at this for a while and I can't see the problem...
IntersectResult ir = new IntersectResult();
root.intersect(ray, ir);
if(r.material!=null)
System.out.println(result.material.diffuse);
// Doesn't print at all!!
// in my Node Class...
@Override
public void intersect(Ray ray, IntersectResult result) {
IntersectResult i = new IntersectResult();
for (Intersectable child:children){
child.intersect(ray, i);
if (result.t>i.t)
result = new IntersectResult(i);
}
if(result.material!=null)
System.out.println(result.material.diffuse); // prints correctly!
}
Basically my question is why is result.material null after the intersect method call when the print statements within the method call show that it is not?