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
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -35,7 +35,8 @@
],
"notes": [
"Experimental contact coefficients; iron material is unchanged.",
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg."
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg.",
"Iron uses nonzero dragCoefficient=0.47. Its large mass and normal contact resistance limit displacement under the reference wind; there is no wind exemption."
],
"airDensity": 1.225
}
}
+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.
File diff suppressed because it is too large Load Diff
+11 -1
View File
@@ -4,6 +4,11 @@
"id": "directional_boost",
"name": "定向加速",
"assetId": "directional_boost"
},
{
"id": "ice",
"name": "易碎冰块",
"assetId": "ice"
}
],
"nonInteractive": [
@@ -16,6 +21,11 @@
"id": "goal_hole",
"name": "锥口球洞",
"assetId": "goal_hole"
},
{
"id": "water",
"name": "水方块",
"assetId": "water"
}
]
}
}
+135 -3
View File
@@ -1,8 +1,21 @@
{
"schemaVersion": 1,
"ballTypes": [
{
"ballTypeId": "wood_ball",
"displayName": "原木球",
"assetId": "wood_ball",
"physicsProfileId": "wood_game"
},
{
"ballTypeId": "ceramic_ball",
"displayName": "陶瓷球",
"assetId": "ceramic_ball",
"physicsProfileId": "ceramic_game"
},
{
"ballTypeId": "iron_ball",
"displayName": "铁球",
"assetId": "iron_ball",
"physicsProfileId": "solid_iron_test"
}
@@ -13,6 +26,18 @@
"inertiaModel": "solidSphere",
"dragCoefficient": 0.47,
"contactMaterialId": "iron"
},
"wood_game": {
"massKg": 60,
"inertiaModel": "solidSphere",
"dragCoefficient": 0.47,
"contactMaterialId": "wood"
},
"ceramic_game": {
"massKg": 330,
"inertiaModel": "solidSphere",
"dragCoefficient": 0.04,
"contactMaterialId": "ceramic"
}
},
"contactMaterialPairs": [
@@ -31,11 +56,118 @@
"dynamicFriction": 0.25,
"rollingResistance": 0.01,
"restitution": 0.15
},
{
"materialAId": "wood",
"materialBId": "painted_wood",
"staticFriction": 0.42,
"dynamicFriction": 0.32,
"rollingResistance": 0.025,
"restitution": 0.08
},
{
"materialAId": "ceramic",
"materialBId": "painted_wood",
"staticFriction": 0.42,
"dynamicFriction": 0.32,
"rollingResistance": 0.025,
"restitution": 0.08
},
{
"materialAId": "wood",
"materialBId": "wood",
"staticFriction": 0.35,
"dynamicFriction": 0.25,
"rollingResistance": 0.01,
"restitution": 0.15
},
{
"materialAId": "ceramic",
"materialBId": "ceramic",
"staticFriction": 0.35,
"dynamicFriction": 0.25,
"rollingResistance": 0.01,
"restitution": 0.15
},
{
"materialAId": "wood",
"materialBId": "ceramic",
"staticFriction": 0.35,
"dynamicFriction": 0.25,
"rollingResistance": 0.01,
"restitution": 0.15
},
{
"materialAId": "wood",
"materialBId": "iron",
"staticFriction": 0.35,
"dynamicFriction": 0.25,
"rollingResistance": 0.01,
"restitution": 0.15
},
{
"materialAId": "ceramic",
"materialBId": "iron",
"staticFriction": 0.35,
"dynamicFriction": 0.25,
"rollingResistance": 0.01,
"restitution": 0.15
},
{
"materialAId": "wood",
"materialBId": "wall",
"staticFriction": 1.0,
"dynamicFriction": 0.9,
"rollingResistance": 0.8,
"restitution": 0.02
},
{
"materialAId": "wood",
"materialBId": "ice",
"staticFriction": 0.03,
"dynamicFriction": 0.02,
"rollingResistance": 0.002,
"restitution": 0.02
},
{
"materialAId": "ceramic",
"materialBId": "wall",
"staticFriction": 1.0,
"dynamicFriction": 0.9,
"rollingResistance": 0.8,
"restitution": 0.02
},
{
"materialAId": "ceramic",
"materialBId": "ice",
"staticFriction": 0.03,
"dynamicFriction": 0.02,
"rollingResistance": 0.002,
"restitution": 0.02
},
{
"materialAId": "iron",
"materialBId": "wall",
"staticFriction": 1.0,
"dynamicFriction": 0.9,
"rollingResistance": 0.8,
"restitution": 0.02
},
{
"materialAId": "iron",
"materialBId": "ice",
"staticFriction": 0.03,
"dynamicFriction": 0.02,
"rollingResistance": 0.002,
"restitution": 0.02
}
],
"notes": [
"Experimental contact coefficients; iron material is unchanged.",
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg."
"Game tuning: all balls have the same authored radius and shape. Wood mass 60 kg; ceramic 330 kg (confirmed initial mass, sinks and travels less than 2 m in the 8-second reference current); iron keeps its original 890.076 kg.",
"Air drag coefficients are gameplay parameters, not measured material constants: wood 0.47, ceramic 0.04, iron 0.47. Iron receives aerodynamic force through the same equation as other balls; its mass and ordinary contact resistance limit motion in the reference wind.",
"No extra fan multiplier or direct wind velocity override. All types use the established contact coefficients to isolate mass and aerodynamic differences.",
"The current native per-body friction/restitution approximation is retained; simultaneous mixed contact-pair solving is not introduced by this asset change.",
"Wall contacts use high friction and rolling resistance; ice uses low friction and rolling resistance. These are shared surface tuning, never per-level ball overrides."
],
"airDensity": 1.225
}
}
+75 -25
View File
@@ -10,6 +10,7 @@ import json
import math
import shutil
import time
import runpy
from pathlib import Path
from mathutils import Vector
@@ -63,7 +64,6 @@ def mat(name, color, metallic=0.0, roughness=.85):
bsdf.inputs['Roughness'].default_value = roughness
return m
mats={k:mat(k,v) for k,v in palette.items()}
mats['iron']=mat('iron satin','788A9E',.35,.5)
mats['wall']=mat('wall stone','A29E8B')
mats['wall_top']=mat('wall stone top','D8D3B4')
@@ -77,11 +77,18 @@ def mesh_object(name,vertices,faces):
def build_funnel():
bpy.data.objects.remove(bpy.data.objects['goal_hole'],do_unlink=True)
# A closed shell with a wide conical entrance and a true narrow outlet.
profile=[(.46,0),(.32,-.35),(.32,-1),(.36,-1),(.50,0)]
# A wall-sized cube around the original conical inlet and open throat.
# Matching square/circle rings form one closed manifold solid, with no
# hidden full-cube collider or overlapping shell blocking the ball.
sides=96
vertices=[(radius*math.cos(i*math.tau/sides),radius*math.sin(i*math.tau/sides),z)
for radius,z in profile for i in range(sides)]
profile=[('circle',.46,0),('circle',.32,-.35),('circle',.32,-1),
('square',.5,-1),('square',.5,0)]
vertices=[]
for shape,size,z in profile:
for i in range(sides):
x,y=math.cos(i*math.tau/sides),math.sin(i*math.tau/sides)
radius=size/max(abs(x),abs(y)) if shape=='square' else size
vertices.append((radius*x,radius*y,z))
faces=[]
for ring in range(len(profile)):
next_ring=(ring+1)%len(profile)
@@ -95,7 +102,22 @@ def build_wall(name='wall'):
faces=[(0,2,3,1),(4,5,7,6),(0,1,5,4),(2,6,7,3),(0,4,6,2),(1,3,7,5)]
return mesh_object(name,vertices,faces)
build_funnel();build_wall();build_wall('directional_boost')
build_funnel();build_wall();build_wall('directional_boost');build_wall('water');build_wall('ice')
mats['water']=mat('water','74C7D8',roughness=.25)
mats['water_surface']=mat('water_surface','63B8C5',roughness=.25)
mats['ice']=mat('ice','A8DAE0',roughness=.12)
mats['ice_top']=mat('ice top','DBF5EE',roughness=.12)
for key, alpha in [('water',.22),('water_surface',.55),('ice',.86)]:
material=mats[key]
material.diffuse_color=(*material.diffuse_color[:3],alpha)
material.node_tree.nodes.get('Principled BSDF').inputs['Alpha'].default_value=material.diffuse_color[3]
material.surface_render_method='DITHERED'
for kind in ['water','ice']:
catalog['models'][kind]={'role':kind,'category':'nonInteractive' if kind=='water' else 'interactive',
'collisionShape':'none' if kind=='water' else 'box','cellFootprint':[1,1],
'boundsBlender':{'min':[-.5,-.5,0],'max':[.5,.5,1],'size':[1,1,1]},
'declaredSize':[1,1,1],'geometryOrigin':'authored'}
catalog['models']['water']['flowDirectionGodot']=[1,0,0]
catalog['models']['wall']={'role':'solid','category':'nonInteractive','collisionShape':'box',
'cellFootprint':[1,1],'boundsBlender':{'min':[-.5,-.5,0],'max':[.5,.5,1],'size':[1,1,1]},
'declaredSize':[1,1,1],'geometryOrigin':'authored'}
@@ -105,9 +127,11 @@ catalog['models']['directional_boost']={'role':'boost','category':'interactive',
catalog['models']['goal_hole']={'role':'goal','category':'nonInteractive','openingRadius':.32,
'entranceRadius':.46,'funnelDepth':.35,'depth':1.0,'cellFootprint':[1,1],
'boundsBlender':{'min':[-.5,-.5,-1],'max':[.5,.5,0],'size':[1,1,1]},
'declaredSize':[1,1,1],'geometryOrigin':'authored'}
'declaredSize':[1,1,1],'geometryOrigin':'authored','outerShape':'cube'}
def export(objects, path):
if globals().get('EXPORT_KINDS') is not None and objects[0].name not in EXPORT_KINDS:
return
bpy.ops.object.select_all(action='DESELECT')
for obj in objects: obj.select_set(True)
bpy.context.view_layer.objects.active=objects[0]
@@ -148,15 +172,24 @@ def boost_arrow():
def asset_dir(kind):
category = 'balls' if kind == 'iron_ball' else 'goals' if kind == 'goal_hole' else 'blocks' if kind in ('wall','directional_boost') else 'chutes'
category = 'balls' if kind == 'iron_ball' else 'goals' if kind == 'goal_hole' else 'blocks' if kind in ('wall','directional_boost','water','ice') else 'chutes'
return ROOT / 'assets' / category / kind
kinds=['straight','turn_cw','turn_ccw','gentle','steep','y_merge']
snapshot_turn='turn_90' if 'turn_90' in bpy.data.objects else 'turn_cw'
catalog['models']['turn_90']=dict(catalog['models'][snapshot_turn], geometrySource=snapshot_turn)
# Retire duplicate objects only in this working scene; never rewrite the snapshot.
for legacy in ('turn_cw','turn_ccw'):
if legacy!=snapshot_turn and legacy in bpy.data.objects:
bpy.data.objects.remove(bpy.data.objects[legacy],do_unlink=True)
kinds=['straight','turn_90','gentle','steep','y_merge']
groups=[];report=[]
all_kinds=kinds+['iron_ball','goal_hole','wall','directional_boost']
all_kinds=kinds+['iron_ball','goal_hole','wall','directional_boost','water','ice']
if ONLY_ASSET is not None and ONLY_ASSET not in all_kinds:raise ValueError(ONLY_ASSET)
for kind in ([ONLY_ASSET] if ONLY_ASSET else all_kinds):
obj=bpy.data.objects[kind]
obj=bpy.data.objects[snapshot_turn if kind=='turn_90' else kind]
if kind=='turn_90':
obj.name=kind
obj['asset_id']=kind
obj.location=(0,0,0)
obj.data=obj.data.copy()
before_coords=[tuple(v.co) for v in obj.data.vertices]
@@ -169,22 +202,32 @@ for kind in ([ONLY_ASSET] if ONLY_ASSET else all_kinds):
group=[obj,outline(obj)]
category='chutes'
elif kind=='iron_ball':
for key in ['iron','ink','iron_light']:obj.data.materials.append(mats[key])
for face,old in zip(obj.data.polygons,old_indices):
face.material_index=1 if old==1 else 0
# An authored, low-detail bright cap gives the sphere a graphic highlight.
if face.center.z>0.19 and face.center.x<-.04 and old!=1:face.material_index=2
ball_style=runpy.run_path(str(ROOT/'assets/balls/shared/source/material_style.py'))
ball_style['apply_material'](obj,kind)
catalog['models'][kind]['albedoTexture']='res://assets/balls/iron_ball/textures/albedo.png'
group=[obj]
category='balls'
elif kind=='goal_hole':
obj.data.materials.append(mats['red'])
obj.data.materials.append(mats['top'])
obj.data.materials.append(mats['wall'])
obj.data.materials.append(mats['wall_top'])
obj.data.materials.append(mats['ink'])
for face in obj.data.polygons:
face.material_index=1 if face.index<96 else (2 if face.index<192 else 0)
face.use_smooth=face.index<192
inner=all(max(abs(obj.data.vertices[i].co.x),abs(obj.data.vertices[i].co.y))<.5-1e-6
for i in face.vertices)
face.material_index=2 if inner and face.normal.z<.01 else (1 if face.normal.z>0 else 0)
face.use_smooth=inner
group=[obj,outline(obj)]
category='environment'
elif kind in ('water','ice'):
obj.data.materials.append(mats[kind])
obj.data.materials.append(mats['ice_top' if kind=='ice' else 'water_surface'])
for face in obj.data.polygons:face.material_index=1 if face.normal.z>.5 else 0
group=[obj]
if kind=='ice':
ice_style=runpy.run_path(str(asset_dir(kind)/'source/material_style.py'))
ice_style['apply_ice_surface'](obj,mats['ice'],mats['ice_top'])
group.append(outline(obj))
category='entities'
else:
obj.data.materials.append(mats['wall']);obj.data.materials.append(mats['wall_top'])
for face in obj.data.polygons:face.material_index=1 if face.normal.z>.5 else 0
@@ -192,7 +235,7 @@ for kind in ([ONLY_ASSET] if ONLY_ASSET else all_kinds):
if kind=='directional_boost':group+=boost_arrow()
category='entities'
obj['style_family']='railbound_inspired'
obj['collision_source']='authored mesh' if kind in ('wall','goal_hole','directional_boost') else 'unchanged source mesh'
obj['collision_source']='authored mesh' if kind in ('wall','goal_hole','directional_boost','water','ice') else 'unchanged source mesh'
export(group,asset_dir(kind)/'model.glb')
catalog['models'][kind]['path']='res://'+str((asset_dir(kind)/'model.glb').relative_to(ROOT))
catalog['models'][kind]['sourceBlend']=str((asset_dir(kind)/'source/model.blend').relative_to(ROOT))
@@ -204,12 +247,13 @@ for kind in ([ONLY_ASSET] if ONLY_ASSET else all_kinds):
source_path=asset_dir(kind)/'source/model.blend'
source_path.parent.mkdir(parents=True,exist_ok=True)
# A separate editable source file contains only one asset family member.
report.append({'id':kind,'collisionGeometryUnchanged':kind not in ('wall','goal_hole','directional_boost') and before_coords==[tuple(v.co) for v in obj.data.vertices],
report.append({'id':kind,'collisionGeometryUnchanged':kind not in ('wall','goal_hole','directional_boost','water','ice') and before_coords==[tuple(v.co) for v in obj.data.vertices],
'vertices':len(obj.data.vertices),'separateBlend':str(source_path.relative_to(ROOT))})
groups.append(group)
if ONLY_ASSET:
existing=json.loads((OUT/'catalog.json').read_text())
for legacy in ('turn_cw','turn_ccw'):existing['models'].pop(legacy,None)
existing['models'][ONLY_ASSET]=catalog['models'][ONLY_ASSET]
catalog=existing
else:
@@ -218,10 +262,12 @@ catalog['styleFamily']='railbound_inspired'
catalog['palette']=palette
(OUT/'catalog.json').write_text(json.dumps(catalog,ensure_ascii=False,indent=2))
if not ONLY_ASSET:
(OUT/'physics.json').write_text(json.dumps(physics,ensure_ascii=False,indent=2))
(OUT/'entities.json').write_text(json.dumps({'interactive':[{'id':'directional_boost','name':'定向加速','assetId':'directional_boost'}],
# Geometry rebuilds must not overwrite curated ball types or physics tuning.
if not (OUT/'physics.json').exists():
(OUT/'physics.json').write_text(json.dumps(physics,ensure_ascii=False,indent=2))
(OUT/'entities.json').write_text(json.dumps({'interactive':[{'id':'directional_boost','name':'定向加速','assetId':'directional_boost'},{'id':'ice','name':'易碎冰块','assetId':'ice'}],
'nonInteractive':[{'id':'wall','name':'标准墙壁','assetId':'wall'},
{'id':'goal_hole','name':'锥口球洞','assetId':'goal_hole'}]},ensure_ascii=False,indent=2))
{'id':'goal_hole','name':'锥口球洞','assetId':'goal_hole'},{'id':'water','name':'水方块','assetId':'water'}]},ensure_ascii=False,indent=2))
if ONLY_ASSET:
names={member.name for member in groups[0]}
for obj in list(bpy.data.objects):
@@ -233,6 +279,8 @@ else:
bpy.ops.wm.save_as_mainfile(filepath=str(SOURCE/'collection.blend'))
group_names=[[member.name for member in group] for group in groups]
for entry, names in zip(report,group_names):
if globals().get('EXPORT_KINDS') is not None and entry['id'] not in EXPORT_KINDS:
continue
bpy.ops.wm.open_mainfile(filepath=str(SOURCE/'collection.blend'))
for obj in list(bpy.data.objects):
if obj.name not in names:bpy.data.objects.remove(obj,do_unlink=True)
@@ -243,3 +291,5 @@ else:
'models':report,'radius':catalog['models']['iron_ball']['radius'],
'physicalMaterialUnchanged':True,'outlineGeometry':'visual only'},indent=2))
print('STYLE_ASSETS_READY')
if not ONLY_ASSET:
runpy.run_path(str(ROOT/'assets/balls/shared/source/build_materials.py'))
Binary file not shown.
File diff suppressed because it is too large Load Diff
@@ -1,10 +1,11 @@
{
"files": {
"assets/collections/baseline/source/collection.blend": "f81477cb30f5f5eb5a486a3a5e75c95b097204cfa5380c286cb1b40a85ee6962",
"assets/collections/baseline/catalog.json": "7af16a52c10655df0353198e0de97864aaa1b7669503139e7c4f727450929085",
"assets/collections/baseline/physics.json": "b12802f7763c162d037b0795e79272955031162790424831e88c939288f5526e"
"assets/collections/baseline/source/collection.blend": "2d948b29f8332fa0b8faaa60ce7e92d5bf3b75c05e2dbd17795e63ea35b3d197",
"assets/collections/baseline/catalog.json": "3bbe2a939f3d4542c6c733548ff0e0549db332a30e5c2f09d51fe0aba0faa7a0",
"assets/collections/baseline/physics.json": "b0f2e8fa1637de0ee55c38471be808ccf3e018eaf1c3003e5e16c8b1a8c8de22"
},
"copiedAtUnix": 1794720924.17409,
"copiedAtUnix": 1794799536.467038,
"readOnlyBaseline": true,
"layoutMigration": "2026-11-16: paths moved; catalog resource paths rewritten; previous hashes retained in source_manifest.pre_reorganization.json"
}
"geometryRevision": "solid_base_v1",
"physicsUpdatedAtUnix": 1794810704.149133
}
@@ -35,7 +35,8 @@
],
"notes": [
"Experimental contact coefficients; iron material is unchanged.",
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg."
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg.",
"Iron uses nonzero dragCoefficient=0.47. Its large mass and normal contact resistance limit displacement under the reference wind; there is no wind exemption."
],
"airDensity": 1.225
}
}
+75 -12
View File
@@ -3,7 +3,10 @@ import bpy
import bmesh
import hashlib
import json
import math
from pathlib import Path
from mathutils import Vector
from mathutils.bvhtree import BVHTree
ROOT=Path(__file__).resolve().parents[4]
SOURCE=Path(__file__).resolve().parent/'snapshot'
@@ -11,18 +14,54 @@ catalog=json.loads((ROOT/'assets/collections/storybook/catalog.json').read_text(
bpy.ops.wm.open_mainfile(filepath=str(SOURCE/'source_snapshot.blend'))
def geometry(obj):
# Blender may reorder polygons when rebuilding an otherwise identical mesh.
# Compare face connectivity and winding, independent of list order/start vertex.
faces=[]
for polygon in obj.data.polygons:
face=list(polygon.vertices)
start=face.index(min(face))
faces.append(face[start:]+face[:start])
return ([list(v.co) for v in obj.data.vertices],
[list(p.vertices) for p in obj.data.polygons])
sorted(faces))
baseline={kind:geometry(bpy.data.objects[kind]) for kind in catalog['models'] if kind in bpy.data.objects}
def solid_base(obj, data):
bm=bmesh.new();bm.from_mesh(obj.data)
closed=all(e.is_manifold for e in bm.edges)
volume=abs(bm.calc_volume(signed=True));bm.free()
# Local mesh queries avoid the collection's display translations.
tree=BVHTree.FromPolygons([v.co for v in obj.data.vertices],
[list(p.vertices) for p in obj.data.polygons])
low=data['boundsBlender']['min'];high=data['boundsBlender']['max']
bottom_hits=[]
for u in (.05,.25,.5,.75,.95):
for v in (.05,.25,.5,.75,.95):
origin=Vector((low[0]+u*(high[0]-low[0]),low[1]+v*(high[1]-low[1]),-.1))
hit,normal,_,_=tree.ray_cast(origin,Vector((0,0,1)))
bottom_hits.append(hit is not None and abs(hit.z)<1e-5 and normal.z<-.99)
filled=[]
for path in data['upperPaths']:
for p in path[4:-4:4]:
point=Vector((p[0],-p[2],p[1]-data['grooveRadius']-.04))
hit,normal,_,_=tree.find_nearest(point)
filled.append(hit is not None and (point-hit).dot(normal)<-1e-5)
return {'passed':closed and volume>0 and all(bottom_hits) and all(filled),
'closedManifold':closed,'solidVolume':volume,'bottomSamples':len(bottom_hits),
'bottomClosed':all(bottom_hits),'grooveUndersideSamples':len(filled),
'grooveUndersideFilled':all(filled)}
source_names={data.get('geometrySource',kind) for kind,data in catalog['models'].items()}
baseline={kind:geometry(bpy.data.objects[kind]) for kind in source_names if kind in bpy.data.objects}
checks=[]
for kind,data in catalog['models'].items():
if data.get('solidBase'):
checks.append({'id':'baseline_'+kind,**solid_base(bpy.data.objects[data.get('geometrySource',kind)],data)})
for kind,data in catalog['models'].items():
path=ROOT/data['sourceBlend']
bpy.ops.wm.open_mainfile(filepath=str(path))
obj=bpy.data.objects[kind]
physical=[o for o in bpy.context.scene.objects if not o.name.startswith('ink_')]
authored=data.get('geometryOrigin')=='authored'
mesh_match=None if authored else geometry(obj)==baseline[kind]
mesh_match=None if authored else geometry(obj)==baseline[data.get('geometrySource',kind)]
correct=(len(physical)==1 and physical[0].name==kind and
(authored or mesh_match) and obj.location.length<1e-6 and
all(abs(x-1)<1e-6 for x in obj.scale))
@@ -30,11 +69,17 @@ for kind,data in catalog['models'].items():
'geometryMatchesSnapshot':mesh_match,
'origin':list(obj.location),'dimensions':list(obj.dimensions),
'materials':[m.name for m in obj.data.materials]}
if kind=='iron_ball':
if data.get('solidBase'):
solid=solid_base(obj,data)
check['solidBase']=solid
check['passed']=correct and solid['passed']
if kind in ('iron_ball','wood_ball','ceramic_ball'):
radius=max(v.co.length for v in obj.data.vertices)
check['measuredRadius']=radius
correct=correct and abs(radius-data['radius'])<1e-6
check['passed']=correct
textures=[n.image for m in obj.data.materials for n in m.node_tree.nodes if n.type=='TEX_IMAGE']
check['packedTextureCount']=sum(image.packed_file is not None for image in textures)
check['passed']=correct and len(textures)==2 and check['packedTextureCount']==2
if authored:
bm=bmesh.new();bm.from_mesh(obj.data)
volume=abs(bm.calc_volume(signed=True));closed=all(e.is_manifold for e in bm.edges);bm.free()
@@ -49,13 +94,31 @@ for kind,data in catalog['models'].items():
tip=max(points,key=lambda v:v.x)
correct=correct and tip.x>0 and abs(tip.y)<1e-6 and all(1<v.z<1.01 for v in points)
check['arrowTipBlender']=list(tip)
else:
rings={}
for vertex in obj.data.vertices:
z=round(vertex.co.z,5);radius=round((vertex.co.x**2+vertex.co.y**2)**.5,5)
rings.setdefault(str(z),set()).add(radius)
correct=correct and rings=={'0.0':{.46,.5},'-0.35':{.32},'-1.0':{.32,.36}}
check['measuredRings']={k:sorted(v) for k,v in rings.items()}
elif kind=='goal_hole':
tree=BVHTree.FromPolygons([v.co for v in obj.data.vertices],
[list(p.vertices) for p in obj.data.polygons])
corners=all(any((v.co-Vector((x,y,z))).length<1e-6 for v in obj.data.vertices)
for x in (-.5,.5) for y in (-.5,.5) for z in (-1,0))
side_hits=[]
for axis in (0,1):
for sign in (-1,1):
for tangent in (-.45,0,.45):
for height in (-.05,-.9):
origin=Vector((tangent,tangent,height));origin[axis]=sign
direction=Vector((0,0,0));direction[axis]=-sign
hit,normal,_,_=tree.ray_cast(origin,direction)
side_hits.append(hit is not None and abs(hit[axis]-sign*.5)<1e-6
and normal[axis]*sign>.999)
axis_open=tree.ray_cast(Vector((0,0,.1)),Vector((0,0,-1)))[0] is None
throat=tree.ray_cast(Vector((0,0,-.7)),Vector((1,0,0)))[0]
throat_open=throat is not None and abs(throat.x-.32)<1e-6
# The regular 96-sided circular cavity uses the unchanged inlet.
cavity=(.35*(.46**2+.46*.32+.32**2)/3+.65*.32**2)*48*math.sin(math.tau/96)
expected_volume=1-cavity
correct=correct and corners and all(side_hits) and axis_open and throat_open and abs(volume-expected_volume)<1e-6
check['cubeWithOpenFunnel']={'eightCorners':corners,'flatSideSamples':len(side_hits),
'flatSides':all(side_hits),'verticalPassageOpen':axis_open,
'throatRadiusCorrect':throat_open,'expectedSolidVolume':expected_volume}
check.update({'passed':correct,'closedManifold':closed,'solidVolume':volume})
checks.append(check)
manifest=json.loads((SOURCE/'source_manifest.json').read_text())