feat: 更新 IntoHole 的球体、滑槽和环境资产

- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考
- 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档
- 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹
- 同步 Blender 源资产、Godot 加载、工坊和试玩预览
This commit is contained in:
Yanchen
2026-11-19 16:18:41 +08:00
parent 39ff1fd7b4
commit d1141b04c7
467 changed files with 67228 additions and 44624 deletions
+14 -27
View File
@@ -15,7 +15,6 @@ SOURCE = Path(__file__).resolve().parent
BALL_R = 0.3
FIT_CLEARANCE = 0.02
R = BALL_R + FIT_CLEARANCE
HOLE_R = BALL_R + FIT_CLEARANCE
GOAL_R = BALL_R + FIT_CLEARANCE
GOAL_DEPTH = 0.55
SIDES = 64
@@ -24,6 +23,7 @@ SOURCE.mkdir(parents=True, exist_ok=True)
(ROOT/'playtest/artifacts/baseline').mkdir(parents=True, exist_ok=True)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
bpy.context.preferences.filepaths.save_version = 0
bpy.context.scene.unit_settings.system = 'METRIC'
bpy.context.scene.unit_settings.scale_length = 1.0
@@ -119,8 +119,8 @@ def extend(points, amount=.18):
def paths(kind,rise):
if kind in ('straight','gentle','steep'):
return [[(x,0,top_height(x,rise)) for x in [-.5+i/24 for i in range(25)]]]
if kind in ('turn_cw','turn_ccw'):
sign=-1 if kind=='turn_cw' else 1
if kind=='turn_90':
sign=-1
return [[(-.5+.5*math.sin(t),sign*(.5-.5*math.cos(t)),1) for t in [i*math.pi/2/48 for i in range(49)]]]
# 2x2 Y connector: adjacent 1m lanes on the -X face, both at the same height.
# Lane A continues straight; lane B merges through a tangent-continuous S.
@@ -141,6 +141,8 @@ def asset_dir(kind):
return ROOT / 'assets' / category / kind
def export_objects(objects, name):
if globals().get('EXPORT_KINDS') is not None and name not in EXPORT_KINDS:
return
export_path = asset_dir(name) / 'baseline/model.glb'
export_path.parent.mkdir(parents=True, exist_ok=True)
bpy.ops.object.select_all(action='DESELECT')
@@ -151,27 +153,22 @@ def export_objects(objects, name):
def godot(v): return [round(v[0],6),round(v[2],6),round(-v[1],6)]
catalog={'schemaVersion':1,'unitsPerMeter':1,'authoringUp':'Z','runtimeUp':'Y','models':{}}
report={'generator':'Blender Python','ball_radius_m':BALL_R,'groove_radius_m':R,'hole_radius_m':HOLE_R,'assets':[],
catalog={'schemaVersion':1,'geometryRevision':'solid_base_v1','unitsPerMeter':1,'authoringUp':'Z','runtimeUp':'Y','models':{}}
report={'generator':'Blender Python','geometryRevision':'solid_base_v1','ball_radius_m':BALL_R,'groove_radius_m':R,'assets':[],
'fit_clearance_m':FIT_CLEARANCE,'goal_radius_m':GOAL_R,
'important':['Flat blocks now contain closed circular passages; ramp passages can open through the bottom and use the test platform as support.',
'important':['All five chutes have solid bases; only the upper rolling grooves are cut into the body.',
'The steep ramp preserves 1m rise; its retained 1.5m prototype envelope remains explicitly flagged.']}
showcase=[]
for kind,rise in [('straight',0),('turn_cw',0),('turn_ccw',0),('gentle',.5),('steep',1),('y_merge',0)]:
for kind,rise in [('straight',0),('turn_90',0),('gentle',.5),('steep',1),('y_merge',0)]:
body=block(kind,rise)
upper_paths=paths(kind,rise)
for n,path in enumerate(upper_paths):
cut(body,tube(f'{kind}_upper_{n}',extend(path),R,channel))
floor_center=top_height(0,rise)-R
hole_z=floor_center-HOLE_R*math.sqrt(1+rise*rise)-.02
# Diagonal mirror swaps X/Y, while keeping lower passages level.
lower_paths=[[(y,x,hole_z) for x,y,z in path] for path in upper_paths]
for n,path in enumerate(lower_paths):
cut(body,tube(f'{kind}_lower_{n}',extend(path),HOLE_R,wood))
for face in body.data.polygons:
face.use_smooth=(face.material_index==1)
body['asset_id']=kind
body['groove_radius_m']=R
body['solid_base']=True
declared_size=[2.0,2.0,1.0] if kind=='y_merge' else [1.0,1.0,1.0]
body['declared_size_m']=declared_size
body['rise_m']=rise
@@ -180,14 +177,6 @@ for kind,rise in [('straight',0),('turn_cw',0),('turn_ccw',0),('gentle',.5),('st
low=[min(v[i] for v in coords) for i in range(3)]
high=[max(v[i] for v in coords) for i in range(3)]
bounds=[round(high[i]-low[i],6) for i in range(3)]
# Sample the actual final boolean mesh for open channels and clearance.
from mathutils.bvhtree import BVHTree
tree=BVHTree.FromObject(body,bpy.context.evaluated_depsgraph_get())
minimum_clearance=10.0
for path in lower_paths:
for point in path[::4]:
loc,normal,index,distance=tree.find_nearest(Vector(point))
if loc is not None: minimum_clearance=min(minimum_clearance,distance)
manifold=bmesh.new();manifold.from_mesh(body.data)
bad_edges=sum(not e.is_manifold for e in manifold.edges);manifold.free()
upper_ports=[]
@@ -200,10 +189,9 @@ for kind,rise in [('straight',0),('turn_cw',0),('turn_ccw',0),('gentle',.5),('st
tangent=Vector((1,0,0)) # parallel interfaces on the opposite X faces
entry={'surface':godot(v),'travel':godot(tangent)}
if not any(p['surface']==entry['surface'] for p in upper_ports):upper_ports.append(entry)
meta={'path':'res://'+str((asset_dir(kind)/'baseline/model.glb').relative_to(ROOT)),'radius':None,'rise':rise,'grooveRadius':R,'passageRadius':HOLE_R,
meta={'path':'res://'+str((asset_dir(kind)/'baseline/model.glb').relative_to(ROOT)),'radius':None,'rise':rise,'grooveRadius':R,'solidBase':True,
'upperPaths':[[godot(p) for p in path] for path in upper_paths],
'lowerPaths':[[godot(p) for p in path] for path in lower_paths],
'ports':upper_ports,'bottomArchCenter':hole_z,'bottomRouteFloor':hole_z-HOLE_R,
'ports':upper_ports,
'boundsBlender':{'min':low,'max':high,'size':bounds},'nominalCellFits':all(d<=1.001 for d in bounds),
'cellFootprint':[int(declared_size[0]),int(declared_size[1])],
'declaredSize':declared_size,'declaredBoundsFits':all(bounds[i]<=declared_size[i]+.001 for i in range(3)),
@@ -215,14 +203,13 @@ for kind,rise in [('straight',0),('turn_cw',0),('turn_ccw',0),('gentle',.5),('st
report['assets'].append({'id':kind,'size_m':bounds,'single_cell_compliant':meta['nominalCellFits'],
'declared_size_m':declared_size,'declared_size_compliant':meta['declaredBoundsFits'],
'mesh_vertices':len(body.data.vertices),'mesh_faces':len(body.data.polygons),'non_manifold_edges':bad_edges,
'lower_path_min_distance_to_mesh_m':round(minimum_clearance,6),'lower_route_floor_local_z':hole_z-HOLE_R,
'passage_open_at_bottom':hole_z-HOLE_R<0})
'solid_base':True})
showcase.append(body)
if kind=='y_merge':
report['y_connections']={'inlet_surface_positions':[godot((-1,-.5,1-R)),godot((-1,.5,1-R))],
'outlet_surface_position':godot((1,-.5,1-R)),'inlet_center_spacing_m':1.0,'inlet_height_difference_m':0.0,
'lower_passage':'closed circular bore in the same block'}
'solid_base':True}
bpy.ops.mesh.primitive_uv_sphere_add(segments=64,ring_count=32,radius=BALL_R,location=(0,0,0))
ball=bpy.context.object;ball.name='iron_ball';ball.data.materials.append(iron);ball.data.materials.append(mark)
Binary file not shown.