summaryrefslogtreecommitdiffhomepage
path: root/benchmark/bm_ao_render.rb
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/bm_ao_render.rb')
-rw-r--r--benchmark/bm_ao_render.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/benchmark/bm_ao_render.rb b/benchmark/bm_ao_render.rb
index 8212c3a13..dc4388c7d 100644
--- a/benchmark/bm_ao_render.rb
+++ b/benchmark/bm_ao_render.rb
@@ -68,7 +68,7 @@ class Vec
def vnormalize
len = vlength
v = Vec.new(@x, @y, @z)
- if len > 1.0e-17 then
+ if len > 1.0e-17
v.x = v.x / len
v.y = v.y / len
v.z = v.z / len
@@ -92,10 +92,10 @@ class Sphere
b = rs.vdot(ray.dir)
c = rs.vdot(rs) - (@radius * @radius)
d = b * b - c
- if d > 0.0 then
+ if d > 0.0
t = - b - Math.sqrt(d)
- if t > 0.0 and t < isect.t then
+ if t > 0.0 and t < isect.t
isect.t = t
isect.hit = true
isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
@@ -118,16 +118,16 @@ class Plane
v = ray.dir.vdot(@n)
v0 = v
- if v < 0.0 then
+ if v < 0.0
v0 = -v
end
- if v0 < 1.0e-17 then
+ if v0 < 1.0e-17
return
end
t = -(ray.org.vdot(@n) + d) / v
- if t > 0.0 and t < isect.t then
+ if t > 0.0 and t < isect.t
isect.hit = true
isect.t = t
isect.n = @n
@@ -170,10 +170,10 @@ end
def clamp(f)
i = f * 255.5
- if i > 255.0 then
+ if i > 255.0
i = 255.0
end
- if i < 0.0 then
+ if i < 0.0
i = 0.0
end
i.to_i
@@ -183,11 +183,11 @@ def otherBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
- if n.x < 0.6 and n.x > -0.6 then
+ if n.x < 0.6 and n.x > -0.6
basis[1].x = 1.0
- elsif n.y < 0.6 and n.y > -0.6 then
+ elsif n.y < 0.6 and n.y > -0.6
basis[1].y = 1.0
- elsif n.z < 0.6 and n.z > -0.6 then
+ elsif n.z < 0.6 and n.z > -0.6
basis[1].z = 1.0
else
basis[1].x = 1.0
@@ -221,8 +221,8 @@ class Scene
p0 = Vec.new(isect.pl.x + eps * isect.n.x,
isect.pl.y + eps * isect.n.y,
isect.pl.z + eps * isect.n.z)
- nphi.times do |j|
- ntheta.times do |i|
+ nphi.times do
+ ntheta.times do
r = Rand::rand
phi = 2.0 * 3.14159265 * Rand::rand
x = Math.cos(phi) * Math.sqrt(1.0 - r)
@@ -241,7 +241,7 @@ class Scene
@spheres[1].intersect(ray, occisect)
@spheres[2].intersect(ray, occisect)
@plane.intersect(ray, occisect)
- if occisect.hit then
+ if occisect.hit
occlusion = occlusion + 1.0
else
0.0
@@ -283,7 +283,7 @@ class Scene
@spheres[1].intersect(ray, isect)
@spheres[2].intersect(ray, isect)
@plane.intersect(ray, isect)
- if isect.hit then
+ if isect.hit
col = ambient_occlusion(isect)
rad.x = rad.x + col.x
rad.y = rad.y + col.y