feat: 切换至滚动阻力运行模型并更新资产、编辑器与验证
- 物理规则:现行模型仅保留滚动阻力耗能与恢复系数碰撞,风力、空气阻力、静摩擦、动摩擦不再参与运行;确认三球质量 60/330/约890 kg 及水密度、流阻参数 - 定向加速改为真实顶面接触触发的一次性 +5 m/s 速度事件,模型新增渐进式 U 形导槽出口 - 更新球体、滑槽、水/冰/墙、球洞模型与 storybook 目录、物理、实体配置 - 工坊摆放、编辑器、运行适配与检查脚本同步;删除过时的 baseline 三组检查 - 新增谜题设计参考文档、关卡草稿与本轮实验产物
This commit is contained in:
@@ -34,7 +34,7 @@ func add_colliders(node: Node, kind: String) -> void:
|
||||
body.collision_mask = 2
|
||||
body.set_meta("piece_type",kind)
|
||||
var material := PhysicsMaterial.new()
|
||||
material.friction = .25 if kind=="goal_hole" else 1.0 # native pair uses min.
|
||||
material.friction = 0.0
|
||||
material.bounce = 0.0
|
||||
body.physics_material_override = material
|
||||
var collider := CollisionShape3D.new()
|
||||
@@ -60,16 +60,13 @@ func create_ball() -> RigidBody3D:
|
||||
body.radius = float(data["radius"])
|
||||
body.mass = float(profile["massKg"])
|
||||
body.inertia = Vector3.ONE * (0.4 * body.mass * body.radius * body.radius)
|
||||
body.drag_coefficient = float(profile["dragCoefficient"])
|
||||
body.air_density = float(physics["airDensity"])
|
||||
body.mu_static = float(pair["staticFriction"])
|
||||
body.mu_dynamic = float(pair["dynamicFriction"])
|
||||
body.rolling_resistance = float(pair["rollingResistance"])
|
||||
body.collision_layer = 2
|
||||
body.collision_mask = 3
|
||||
var material := PhysicsMaterial.new()
|
||||
material.friction = body.mu_static
|
||||
material.friction = 0.0
|
||||
material.bounce = float(pair["restitution"])
|
||||
body.base_bounce = material.bounce
|
||||
body.physics_material_override = material
|
||||
var shape := SphereShape3D.new()
|
||||
shape.radius = body.radius
|
||||
@@ -100,7 +97,7 @@ func create_box(size: Vector3, location: Vector3, color: Color, solid := true) -
|
||||
root.collision_layer = 1
|
||||
root.collision_mask = 2
|
||||
var pm := PhysicsMaterial.new()
|
||||
pm.friction = 1.0
|
||||
pm.friction = 0.0
|
||||
root.physics_material_override = pm
|
||||
return root
|
||||
|
||||
@@ -143,7 +140,8 @@ func create_goal_hole(location: Vector3) -> Node3D:
|
||||
return create_piece("goal_hole",location)
|
||||
|
||||
func crossed_goal(previous: Vector3, current: Vector3, goal: Vector3, radius: float) -> bool:
|
||||
var height: float=goal.y-float(catalog["goal_hole"].depth)
|
||||
# This older straight bore has its throat entrance at the rim.
|
||||
var height: float=goal.y
|
||||
if previous.y<=height or current.y>height:return false
|
||||
var ratio: float=(previous.y-height)/maxf(previous.y-current.y,.000001)
|
||||
var crossing: Vector3=previous.lerp(current,ratio)
|
||||
|
||||
@@ -1,67 +1 @@
|
||||
extends RigidBody3D
|
||||
|
||||
var radius: float = 0.3
|
||||
var drag_coefficient: float = 0.47
|
||||
var air_density: float = 1.225
|
||||
var wind_velocity := Vector3.ZERO
|
||||
var mu_static: float = 0.42
|
||||
var mu_dynamic: float = 0.32
|
||||
var rolling_resistance: float = 0.025
|
||||
var friction_enabled := true
|
||||
var rolling_enabled := true
|
||||
var drag_enabled := true
|
||||
var contact_count := 0
|
||||
var ball_contact_count := 0
|
||||
var contact_slip := 0.0
|
||||
var air_force := Vector3.ZERO
|
||||
var rolling_torque := Vector3.ZERO
|
||||
var travelled := 0.0
|
||||
var previous_position := Vector3.ZERO
|
||||
var tracking_started := false
|
||||
|
||||
func _ready() -> void:
|
||||
continuous_cd = true
|
||||
contact_monitor = true
|
||||
max_contacts_reported = 12
|
||||
can_sleep = false
|
||||
linear_damp_mode = RigidBody3D.DAMP_MODE_REPLACE
|
||||
angular_damp_mode = RigidBody3D.DAMP_MODE_REPLACE
|
||||
linear_damp = 0.0
|
||||
angular_damp = 0.0
|
||||
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
if freeze:
|
||||
return
|
||||
contact_count = state.get_contact_count()
|
||||
ball_contact_count = 0
|
||||
contact_slip = 0.0
|
||||
var support_normal := Vector3.ZERO
|
||||
for i in range(contact_count):
|
||||
if state.get_contact_collider_object(i) is RigidBody3D:ball_contact_count+=1
|
||||
# Contact positions are global; the sphere's radial direction is unambiguous.
|
||||
var n := (state.transform.origin - state.get_contact_local_position(i)).normalized()
|
||||
var relative := state.get_contact_local_velocity_at_position(i) - state.get_contact_collider_velocity_at_position(i)
|
||||
var slip := relative - n * relative.dot(n)
|
||||
contact_slip = maxf(contact_slip, slip.length())
|
||||
if n.dot(Vector3.UP) > 0.15:
|
||||
support_normal += n
|
||||
# Godot exposes one native friction coefficient. Select a slip-dependent
|
||||
# coefficient; native contact solver still owns the friction impulse.
|
||||
physics_material_override.friction = (mu_static if contact_slip < 0.035 else mu_dynamic) if friction_enabled else 0.0
|
||||
var relative_air := state.linear_velocity - wind_velocity
|
||||
air_force = -0.5 * air_density * drag_coefficient * PI * radius * radius * relative_air.length() * relative_air if drag_enabled else Vector3.ZERO
|
||||
state.apply_central_force(air_force)
|
||||
rolling_torque = Vector3.ZERO
|
||||
if rolling_enabled and support_normal.length_squared() > 0.001:
|
||||
var n := support_normal.normalized()
|
||||
var roll := state.angular_velocity - n * state.angular_velocity.dot(n)
|
||||
if roll.length() > 0.0001:
|
||||
var support := maxf(0.0, -(mass * state.total_gravity + air_force).dot(n))
|
||||
var moment := 0.4 * mass * radius * radius
|
||||
var limit := roll.length() * moment / state.step
|
||||
rolling_torque = -roll.normalized() * minf(rolling_resistance * support * radius, limit)
|
||||
state.apply_torque(rolling_torque)
|
||||
if tracking_started:
|
||||
travelled += state.transform.origin.distance_to(previous_position)
|
||||
previous_position = state.transform.origin
|
||||
tracking_started = true
|
||||
extends "res://assets/balls/shared/physics.gd"
|
||||
|
||||
@@ -68,7 +68,6 @@ var start_button: Button
|
||||
var quota_label: Label
|
||||
var mode_selector: OptionButton
|
||||
var speed_slider: HSlider
|
||||
var wind_slider: HSlider
|
||||
var type_buttons: Array = []
|
||||
var ui_font: SystemFont
|
||||
var capture_frames := -1
|
||||
@@ -262,12 +261,6 @@ func setup_ui() -> void:
|
||||
if not started: configure_spawn(); reset_ball()
|
||||
)
|
||||
column.add_child(speed_slider)
|
||||
column.add_child(label_for("横风速度(m/s)",13,MUTED))
|
||||
wind_slider = HSlider.new()
|
||||
wind_slider.min_value = 0
|
||||
wind_slider.max_value = 60
|
||||
wind_slider.step = 5
|
||||
column.add_child(wind_slider)
|
||||
var checks := HBoxContainer.new()
|
||||
var trail_check := CheckButton.new()
|
||||
trail_check.text = "轨迹"
|
||||
@@ -323,7 +316,6 @@ func build_preset(new_mode: int) -> void:
|
||||
selected_kind="y_merge"
|
||||
launch_speed=0
|
||||
speed_slider.set_value_no_signal(0)
|
||||
wind_slider.set_value_no_signal(0)
|
||||
elif previous_mode==3:
|
||||
launch_speed=1.2
|
||||
speed_slider.set_value_no_signal(launch_speed)
|
||||
@@ -674,7 +666,6 @@ func _physics_process(delta: float) -> void:
|
||||
process_merge(delta)
|
||||
return
|
||||
if not is_instance_valid(ball):return
|
||||
ball.wind_velocity=Vector3(0,0,float(wind_slider.value))
|
||||
if started and not paused and not ball.freeze:
|
||||
elapsed+=delta
|
||||
max_speed=maxf(max_speed,ball.linear_velocity.length())
|
||||
@@ -785,7 +776,6 @@ func process_merge(delta: float) -> void:
|
||||
for i in range(merge_balls.size()):
|
||||
if merge_entered.has(i) or merge_lost.has(i):continue
|
||||
var sphere=merge_balls[i]
|
||||
sphere.wind_velocity=Vector3(0,0,float(wind_slider.value))
|
||||
max_speed=maxf(max_speed,sphere.linear_velocity.length())
|
||||
if sphere.ball_contact_count>0:touching_ball=true
|
||||
if lib.crossed_goal(merge_previous_positions[i],sphere.position,goal_position,sphere.radius):
|
||||
|
||||
Reference in New Issue
Block a user