clean up bubble + progress insertion

This commit is contained in:
ForeignGods
2022-05-21 23:01:05 +02:00
parent 5539d4d327
commit 7edcbcc0be
2 changed files with 146 additions and 23 deletions

View File

@@ -74,7 +74,10 @@ def origin_to_bottom(ob, matrix=Matrix()):
#create cubes with random location
for i in range(count):
bpy.ops.mesh.primitive_cube_add(location=(ran[i], 0, 0), scale=(0.25, 0.25, 0.25))
#shuffle array
random.shuffle(ran)
#assign random scale to all cubes and add them to array
i = 0
for ob in bpy.data.objects:
@@ -83,7 +86,10 @@ for ob in bpy.data.objects:
ob.scale.z = ran[i]
cubes.append(ob)
i += 1
#sort array based on location.x
cubes.sort(key = lambda obj: obj.location.x)
#bubble sort
for i in range(count):
@@ -117,4 +123,10 @@ for i in range(count):
cubes[j], cubes[j + 1] = cubes[j + 1], cubes[j]
already_sorted = False
if already_sorted:
break
break