lib/mikunyan/decoders/astc_block_decoder.rb in mikunyan-3.9.2 vs lib/mikunyan/decoders/astc_block_decoder.rb in mikunyan-3.9.3

- old
+ new

@@ -343,27 +343,23 @@ seeds = [0, 4, 8, 12, 16, 20, 24, 28].map{|i| (rnum >> i) & 0xf}.map!{|e| e * e} sh = [seed & 2 == 2 ? 4 : 5, @part_num == 3 ? 6 : 5] sh.reverse! if seed & 1 == 0 seeds.map!.with_index{|e, i| e >> sh[i % 2]} - @partition = Array.new(@bw * @bh) + @partition = (0...@bw * @bh).map do |i| + x = i % @bw + y = i / @bw + if small_block + x <<= 1 + y <<= 1 + end - for y in 0...@bh - for x in 0...@bw - idx = x + y * @bw + a = (seeds[0] * x + seeds[1] * y + (rnum >> 14)) & 0x3f + b = (seeds[2] * x + seeds[3] * y + (rnum >> 10)) & 0x3f + c = @part_num < 3 ? 0 : (seeds[4] * x + seeds[5] * y + (rnum >> 6)) & 0x3f + d = @part_num < 4 ? 0 : (seeds[6] * x + seeds[7] * y + (rnum >> 2)) & 0x3f - if small_block - x <<= 1 - y <<= 1 - end - - a = (seeds[0] * x + seeds[1] * y + (rnum >> 14)) & 0x3f - b = (seeds[2] * x + seeds[3] * y + (rnum >> 10)) & 0x3f - c = @part_num < 3 ? 0 : (seeds[4] * x + seeds[5] * y + (rnum >> 6)) & 0x3f - d = @part_num < 4 ? 0 : (seeds[6] * x + seeds[7] * y + (rnum >> 2)) & 0x3f - - @partition[idx] = 3 - [d, c, b, a].each_with_index.max[1] - end + 3 - [d, c, b, a].each_with_index.max[1] end end end def applicate_color