In Files

  • benchmark/bm_ao_render.rb

Parent

Methods

Plane

Public Class Methods

new(p, n) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 112
def initialize(p, n)
  @p = p
  @n = n
end
            

Public Instance Methods

intersect(ray, isect) click to toggle source
 
               # File benchmark/bm_ao_render.rb, line 117
def intersect(ray, isect)
  d = -@p.vdot(@n)
  v = ray.dir.vdot(@n)
  v0 = v
  if v < 0.0
    v0 = -v
  end
  if v0 < 1.0e-17
    return
  end

  t = -(ray.org.vdot(@n) + d) / v

  if t > 0.0 and t < isect.t
    isect.hit = true
    isect.t = t
    isect.n = @n
    isect.pl = Vec.new(ray.org.x + t * ray.dir.x,
                      ray.org.y + t * ray.dir.y,
                      ray.org.z + t * ray.dir.z)
  end
end