feat: 更新 IntoHole 的球体、滑槽和环境资产
- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考 - 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档 - 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹 - 同步 Blender 源资产、Godot 加载、工坊和试玩预览
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
# Isolated physics/asset adapter copied from the baseline on 2026-11-15.
|
||||
extends RefCounted
|
||||
|
||||
const BallScript = preload("res://assets/balls/iron_ball/physics.gd")
|
||||
const BallScript = preload("res://assets/balls/shared/physics.gd")
|
||||
const Water = preload("res://assets/blocks/water/behavior.gd")
|
||||
const WaterSurface = preload("res://assets/blocks/water/surface.gd")
|
||||
const Ice = preload("res://assets/blocks/ice/behavior.gd")
|
||||
const IceAppearance = preload("res://assets/blocks/ice/appearance.gd")
|
||||
const Booster = preload("res://assets/blocks/directional_boost/behavior.gd")
|
||||
var catalog: Dictionary
|
||||
var physics: Dictionary
|
||||
@@ -16,7 +20,7 @@ func vector(a: Array) -> Vector3:
|
||||
return Vector3(float(a[0]),float(a[1]),float(a[2]))
|
||||
|
||||
func create_piece(kind: String, location := Vector3.ZERO, quarter := 0) -> Node3D:
|
||||
var root := Node3D.new()
|
||||
var root: Node3D = Water.new() if kind=="water" else Ice.new() if kind=="ice" else Node3D.new()
|
||||
root.name = kind
|
||||
root.set_meta("piece_type",kind)
|
||||
root.set_meta("quarter",quarter)
|
||||
@@ -30,7 +34,19 @@ func create_piece(kind: String, location := Vector3.ZERO, quarter := 0) -> Node3
|
||||
scene_cache[kind] = load(catalog[kind]["path"])
|
||||
var visual: Node3D = scene_cache[kind].instantiate()
|
||||
root.add_child(visual)
|
||||
add_colliders(visual,kind)
|
||||
if kind == "ice":
|
||||
IceAppearance.apply(visual, location)
|
||||
if kind=="water":
|
||||
var bounds: Dictionary=catalog[kind].boundsBlender
|
||||
root.bounds=AABB(Vector3(bounds.min[0],bounds.min[2],-bounds.max[1]),Vector3(bounds.size[0],bounds.size[2],bounds.size[1]))
|
||||
root.local_direction=vector(catalog[kind].flowDirectionGodot)
|
||||
WaterSurface.apply(visual, root.local_direction)
|
||||
# Selection-only area: no blocking response and no automatic gravity override.
|
||||
var area:=Area3D.new();area.collision_layer=8;area.collision_mask=0
|
||||
var shape:=BoxShape3D.new();shape.size=root.bounds.size
|
||||
var collision:=CollisionShape3D.new();collision.shape=shape;collision.position=root.bounds.get_center()
|
||||
area.add_child(collision);root.add_child(area)
|
||||
else:add_colliders(visual,kind)
|
||||
return root
|
||||
|
||||
func add_colliders(node: Node, kind: String) -> void:
|
||||
@@ -63,13 +79,41 @@ func add_colliders(node: Node, kind: String) -> void:
|
||||
if not child is StaticBody3D:
|
||||
add_colliders(child,kind)
|
||||
|
||||
func create_ball() -> RigidBody3D:
|
||||
func ball_type_ids() -> Array:
|
||||
return physics.ballTypes.map(func(item): return item.ballTypeId)
|
||||
|
||||
func ball_type(id: String) -> Dictionary:
|
||||
for item in physics.ballTypes:
|
||||
if item.ballTypeId == id: return item
|
||||
assert(false,"Unknown ball type: "+id)
|
||||
return {}
|
||||
|
||||
func ball_model(id: String = "iron_ball") -> Dictionary:
|
||||
return catalog[ball_type(id).assetId]
|
||||
|
||||
func ball_radius(id: String = "iron_ball") -> float:
|
||||
return float(ball_model(id).radius)
|
||||
|
||||
func surface_pair(material_id: String) -> Dictionary:
|
||||
for pair in physics.contactMaterialPairs:
|
||||
if (pair.materialAId == material_id and pair.materialBId == "painted_wood") or (pair.materialBId == material_id and pair.materialAId == "painted_wood"):
|
||||
return pair
|
||||
assert(false,"Missing ball/surface material pair: "+material_id)
|
||||
return {}
|
||||
|
||||
func create_ball(type_id: String = "iron_ball") -> RigidBody3D:
|
||||
var body = BallScript.new()
|
||||
body.name = "IronBall"
|
||||
var kind: Dictionary = physics["ballTypes"][0]
|
||||
body.name = type_id
|
||||
body.set_meta("ball_type_id",type_id)
|
||||
var kind: Dictionary = ball_type(type_id)
|
||||
var profile: Dictionary = physics["physicsProfiles"][kind["physicsProfileId"]]
|
||||
var data: Dictionary = catalog[kind["assetId"]]
|
||||
var pair: Dictionary = physics["contactMaterialPairs"][0]
|
||||
var pair: Dictionary = surface_pair(profile.contactMaterialId)
|
||||
body.surface_pairs={}
|
||||
for surface in ["wall","ice"]:
|
||||
for contact in physics.contactMaterialPairs:
|
||||
if (contact.materialAId==profile.contactMaterialId and contact.materialBId==surface) or (contact.materialBId==profile.contactMaterialId and contact.materialAId==surface):
|
||||
body.surface_pairs[surface]=contact
|
||||
body.radius = float(data["radius"])
|
||||
body.mass = float(profile["massKg"])
|
||||
body.inertia = Vector3.ONE * (0.4 * body.mass * body.radius * body.radius)
|
||||
@@ -83,6 +127,7 @@ func create_ball() -> RigidBody3D:
|
||||
var material := PhysicsMaterial.new()
|
||||
material.friction = body.mu_static
|
||||
material.bounce = float(pair["restitution"])
|
||||
body.base_bounce=material.bounce
|
||||
body.physics_material_override = material
|
||||
var shape := SphereShape3D.new()
|
||||
shape.radius = body.radius
|
||||
@@ -117,15 +162,14 @@ func create_box(size: Vector3, location: Vector3, color: Color, solid := true) -
|
||||
root.physics_material_override = pm
|
||||
return root
|
||||
|
||||
func path_point(kind: String, t: float, branch := 0, lower := false) -> Vector3:
|
||||
var key := "lowerPaths" if lower else "upperPaths"
|
||||
var path: Array = catalog[kind][key][branch]
|
||||
func path_point(kind: String, t: float, branch := 0) -> Vector3:
|
||||
var path: Array = catalog[kind]["upperPaths"][branch]
|
||||
var f := clampf(t,0.0,1.0)*(path.size()-1)
|
||||
var i := mini(int(f),path.size()-2)
|
||||
return vector(path[i]).lerp(vector(path[i+1]),f-i)
|
||||
|
||||
func path_tangent(kind: String, t: float, branch := 0, lower := false) -> Vector3:
|
||||
return (path_point(kind,minf(t+.02,1.0),branch,lower)-path_point(kind,maxf(t-.02,0.0),branch,lower)).normalized()
|
||||
func path_tangent(kind: String, t: float, branch := 0) -> Vector3:
|
||||
return (path_point(kind,minf(t+.02,1.0),branch)-path_point(kind,maxf(t-.02,0.0),branch)).normalized()
|
||||
|
||||
func ball_on_surface(kind: String, t: float, branch := 0) -> Vector3:
|
||||
var p := path_point(kind,t,branch)
|
||||
@@ -135,10 +179,6 @@ func ball_on_surface(kind: String, t: float, branch := 0) -> Vector3:
|
||||
var normal := (Vector3.UP-horizontal*slope).normalized()
|
||||
return p-Vector3.UP*float(catalog[kind]["grooveRadius"])+normal*float(catalog["iron_ball"]["radius"])+Vector3.UP*.018
|
||||
|
||||
func lower_passage_spec(kind: String) -> Dictionary:
|
||||
var floor_y: float=catalog[kind].bottomRouteFloor
|
||||
return {"floor_y":floor_y,"center_height":floor_y+float(catalog["iron_ball"].radius)}
|
||||
|
||||
func footprint(kind: String, quarter := 0) -> Vector2i:
|
||||
var size: Array=catalog[kind].get("cellFootprint",[1,1])
|
||||
return Vector2i(int(size[0]),int(size[1])) if quarter%2==0 else Vector2i(int(size[1]),int(size[0]))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
extends RefCounted
|
||||
|
||||
const IDS = ["straight", "turn_90", "gentle", "steep", "y_merge"]
|
||||
|
||||
static func canonical_kind(kind: String) -> String:
|
||||
return "turn_90" if kind in ["turn_cw","turn_ccw"] else kind
|
||||
|
||||
static func canonical_quarter(kind: String, quarter: int) -> int:
|
||||
# The mirrored quarter-circle equals the clockwise model rotated 90 degrees,
|
||||
# with its reference path traversed in reverse. Runtime travel is bidirectional.
|
||||
return (quarter+1)%4 if kind=="turn_ccw" else quarter
|
||||
|
||||
static func canonical_record(record: Dictionary) -> Dictionary:
|
||||
var result:=record.duplicate(true)
|
||||
result.quarter=canonical_quarter(record.kind,int(record.quarter))
|
||||
result.kind=canonical_kind(record.kind)
|
||||
return result
|
||||
@@ -0,0 +1 @@
|
||||
uid://c2hf5yroxa5pu
|
||||
Reference in New Issue
Block a user