Files
IntoHole/designer/scripts/placement.gd
T
Yanchen 39ff1fd7b4 feat: 建立关卡工坊并整理项目目录
- 加入 Godot 基础试玩、画风展示和通孔验证场景
- 支持自由放球、多层叠放、墙壁、锥口球洞及固定 +5 m/s 定向加速方块
- 保存 Blender 源资产、模型导出、资源制作脚本和关卡编辑存档逻辑
- 按七类目录归档工程,集中 zsh 启动入口并补充 AGENTS.md 文件索引
- 同步设计规则、依赖锁定、验证报告和目录迁移记录

验证:目录迁移后的资源导入与四个场景加载通过;本次提交前检查暂存内容,未重复运行整套物理测试。
2026-11-16 11:12:21 +08:00

33 lines
1.5 KiB
GDScript

extends RefCounted
# The editor always works in bottom-face coordinates; imported mesh origins stay intact.
var lib
func _init(library) -> void:lib=library
func bottom_of(record: Dictionary) -> Vector3:
return record.position+Vector3.UP*float(lib.catalog[record.kind].boundsBlender.min[2])
func record_at(kind: String,bottom: Vector3,quarter: int,id: String) -> Dictionary:
var at:=bottom
if kind!="goal_hole":at=Vector3(round(at.x),snappedf(at.y,.5),round(at.z))
var local_min: float=lib.catalog[kind].boundsBlender.min[2]
return {"id":id,"kind":kind,"position":at-Vector3.UP*local_min,"quarter":quarter}
func on_face(support: Dictionary,point: Vector3,normal: Vector3,kind: String,quarter: int) -> Vector3:
var bounds: AABB=lib.record_bounds(support)
var size: Vector2i=lib.footprint(kind,quarter)
var height: float=lib.catalog[kind].boundsBlender.size[2]
var result:=Vector3(round(point.x),bounds.position.y,round(point.z))
var axis:=normal.abs().max_axis_index()
if axis==1:
result.y=bounds.end.y if normal.y>=0 else bounds.position.y-height
elif axis==0:
result.x=bounds.end.x+.5 if normal.x>=0 else bounds.position.x+.5-size.x
else:
result.z=bounds.end.z+.5 if normal.z>=0 else bounds.position.z+.5-size.y
if kind!="goal_hole":
if axis==1:result.y=ceilf(result.y*2-.0001)/2 if normal.y>=0 else floorf(result.y*2+.0001)/2
elif axis==0:result.x=ceilf(result.x-.0001) if normal.x>=0 else floorf(result.x+.0001)
else:result.z=ceilf(result.z-.0001) if normal.z>=0 else floorf(result.z+.0001)
return result