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

33 lines
1.2 KiB
Python

import bpy,os,math
sc=bpy.context.scene
folder=os.path.dirname(bpy.data.filepath)
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'snow_before_cleanup.blend'),copy=True)
def gate(o):
x,y,z=o.matrix_world.translation
if z>6:return False
for i in range(10):
t=i*math.tau/10
u=x*math.cos(t)+y*math.sin(t);v=-x*math.sin(t)+y*math.cos(t)
if abs(u)<4.35 and 94.8<v<101:return True
return False
remove=set()
for name in ['Snow_Rounded_Caps','Snow_Posts_Repaired']:
c=bpy.data.collections.get(name)
if c:remove.update(c.objects)
for o in list(sc.objects):
if o.name.endswith('_FenceSnow'):remove.add(o)
c=bpy.data.collections.get('Snow_Organic_Domes')
if c:
for o in c.objects:
if o.location.z>5.8 or o.hide_render or gate(o):remove.add(o)
c=bpy.data.collections.get('Snow_Draped_Reference')
if c:
for o in c.objects:
if gate(o):remove.add(o)
count=len(remove)
for o in remove:bpy.data.objects.remove(o,do_unlink=True)
remaining=[o.name for o in sc.objects if o.type=='MESH' and o.name.startswith('Snow_') and gate(o)]
assert not remaining,remaining
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_terrain_snow_cleaned.blend'))
print('Removed',count,'remaining gate snow',len(remaining))