Sha256: 0dde227f497b34a48b793510150ba1dc634ace534497b65be8edb0f79934563d

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true
module Glitch3d
  module Duplication
    def alter_vertices(vertices_objects_array)
      # iteration_number = 2
      # res = []
      # iteration_number.times do |_|
      #   res = copy_random_element(vertices_objects_array, iteration_number, CHUNK_SIZE)
      # end
      # res
      shuffle_vertices(vertices_objects_array)
    end

    def alter_faces(faces_objects_array, vertex_objects_array)
      faces_objects_array
    end

    def shuffle_vertices(array)
      2.times do
        rand_index1 = rand(0..array.size - 1)
        rand_index2 = rand(0..array.size - 1)
        array[rand_index1], array[rand_index2] = array[rand_index2], array[rand_index1]
      end
      array
    end

    def copy_random_element(collection, iteration_number, chunk_size)
      new_array = collection
      iteration_number.times do
        rand1 = rand(0..collection.size - 1)
        rand2 = rand(0..collection.size - 1)
        new_array[rand1..rand1 + chunk_size] = new_array[rand2..rand2 + chunk_size]
      end
      new_array
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
glitch3d-0.2.3.6 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.3.3 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.3.2 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.3.1 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.3.0 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.2.9 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.2.8 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.2.6 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.2.5 lib/glitch3d/strategies/duplication.rb
glitch3d-0.2.2.3 lib/glitch3d/strategies/duplication.rb