bm_ao_rendar.rb: use instance variables instead of class variables.

Class variables are slower than instance variables of classes.
parent e5810db1
...@@ -12,18 +12,18 @@ NAO_SAMPLES = 8 ...@@ -12,18 +12,18 @@ NAO_SAMPLES = 8
module Rand module Rand
# Use xorshift # Use xorshift
@@x = 123456789 @x = 123456789
@@y = 362436069 @y = 362436069
@@z = 521288629 @z = 521288629
@@w = 88675123 @w = 88675123
BNUM = 1 << 29 BNUM = 1 << 29
BNUMF = BNUM.to_f BNUMF = BNUM.to_f
def self.rand def self.rand
x = @@x x = @x
t = x ^ ((x & 0xfffff) << 11) t = x ^ ((x & 0xfffff) << 11)
w = @@w w = @w
@@x, @@y, @@z = @@y, @@z, w @x, @y, @z = @y, @z, w
w = @@w = (w ^ (w >> 19) ^ (t ^ (t >> 8))) w = @w = (w ^ (w >> 19) ^ (t ^ (t >> 8)))
(w % BNUM) / BNUMF (w % BNUM) / BNUMF
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment