edin / raytracer

Performance comparison of various compilers
MIT License
57 stars 22 forks source link

Revised Rust version not using function test_ray #15

Closed jzakiya closed 3 years ago

jzakiya commented 3 years ago

In going over the revised Rust version from a couple of days ago, the compiler says test_ray function not used, though the image does not appear affected because of it.

    fn test_ray(&self, ray: &Ray) -> Option<f32>
    {
        let intersect = self.intersections(ray);
        return match intersect {
            Some(result) => Some(result.dist),
            None => None
        }
    }

In the Ruby, Crystal, et al version it was used in

  def addLight(col, light, pos, norm, scene, thing, rd)
    ldis  = Vector.minus(light.pos, pos)
    livec = Vector.norm(ldis)
    neatIsect = self.testRay(Ray.new(pos, livec), scene)
   ...
 end

In Nim as

func getNaturalColor(scene: Scene, sp: SurfaceProperties,
  pos, rd, norm: Vector): Color =
  var rdNorm = rd.norm()
  for light in scene.lights:
    let
      ldis = light.pos - pos
      ldisLen = ldis.len()
      livec = ldis.norm()
      neatIsect = scene.testRay(pos, livec)
      ...
edin commented 3 years ago

It's updated now and the rest of the warnings related to the naming convention are fixed.

jzakiya commented 3 years ago

Great!! I tried to fix it, but see you had to make 2 changes to make it work. Confirmed it creates correct image.

I was waiting on the fix before I submit a PR of tweaks that make it slightly faster and simpler, but will now.

jzakiya commented 3 years ago

Unless you feel otherwise, I'll just close this since you've resolved the issue that was raised.