Files
2026-11-16 23:50:40 +03:00

37 lines
1.5 KiB
Python

import bpy, math, os
from mathutils import Vector
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_compacting.blend'),copy=True)
shift=23.0
directions=[Vector((-math.sin(i*math.tau/10),math.cos(i*math.tau/10),0)) for i in range(10)]
count=0
for o in list(sc.objects):
if o.name.startswith('Zone_'):
i=int(o.name.split('_')[1])-1
elif o.name.startswith(('Snow_Soft_','Snow_Drape_')):
pos=o.matrix_world.translation;i=max(range(10),key=lambda k:pos.dot(directions[k]))
else:continue
world=o.matrix_world.copy();world.translation-=directions[i]*shift;o.matrix_world=world;count+=1
for name in ('Plaza_Border','Plaza_Tiles'):
o=sc.objects.get(name)
if o:bpy.data.objects.remove(o,do_unlink=True)
o=sc.objects.get('Paths')
if o:
o.data=o.data.copy();inv=o.matrix_world.inverted()
for v in o.data.vertices:
p=o.matrix_world@v.co;i=max(range(10),key=lambda k:p.dot(directions[k]))
p-=directions[i]*shift;v.co=inv@p
o=sc.objects.get('Island')
if o:
o.data=o.data.copy();inv=o.matrix_world.inverted()
for v in o.data.vertices:
p=o.matrix_world@v.co;r=math.hypot(p.x,p.y)
if r>39:
newr=39+(r-39)*(139/162*162-39)/(162-39)
p.x*=newr/r;p.y*=newr/r;v.co=inv@p
bpy.context.view_layer.update()
assert sum(1 for o in sc.objects if o.name.startswith('Zone_') and o.name.endswith('_Fence'))==10
path=os.path.join(folder,'map_compact.blend')
bpy.ops.wm.save_as_mainfile(filepath=path)
print('Moved objects:',count,'inward:',shift,'10 fences retained. Saved:',path)