Fix: stalagmite base at tile centre, not tile physical bottom
The affinity model's visual base is at body-local Y=0 (= world Y=tile_h/2, the tile centre), because _fit_model_to_tile seats AABB bottom there. The stalagmite base (AABB top) must sit at the same height so it connects seamlessly. Previous shift -(tile_h/2 + scaled_h) placed the base at body-local Y=-tile_h/2 (world Y=0 = tile physical bottom), creating a gap of tile_h/2 between the affinity model and the stalagmite. Fix: shift by -scaled_h only, bringing AABB top to body-local Y=0. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -542,14 +542,15 @@ func _try_load_tile_bottom(body_ref: Variant, url: String) -> void:
|
||||
# the internal _model_local_aabb call returns a valid AABB.
|
||||
_fit_model_to_tile(bottom_node, 0.98)
|
||||
|
||||
# After fitting: AABB bottom (spike tip) is at body-local Y=0,
|
||||
# AABB top (wide base) is at body-local Y = scaled_h.
|
||||
# We want the wide base flush with the tile underside (body-local Y=-tile_h/2).
|
||||
# Shift = -(tile_h/2 + scaled_h).
|
||||
# After _fit_model_to_tile: the model's AABB bottom (spike tip) is at
|
||||
# body-local Y=0 and the AABB top (wide base) is at body-local Y = scaled_h.
|
||||
# The affinity model's visual base sits at body-local Y=0 (tile centre,
|
||||
# world Y = tile_h/2), so we want the stalagmite base there too.
|
||||
# Shift down by exactly scaled_h to bring the AABB top to body-local Y=0.
|
||||
var btm_aabb := _model_local_aabb(bottom_node)
|
||||
if btm_aabb.size != Vector3.ZERO:
|
||||
var scaled_h := bottom_node.scale.y * btm_aabb.size.y
|
||||
bottom_node.position.y -= tile_h * 0.5 + scaled_h
|
||||
bottom_node.position.y -= scaled_h
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user