fix(world-map): 🐛 Fix overlapping world content in arena mode by adjusting SubViewportContainer z-index and positioning
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
4527ca7737
commit
7672732e7d
1 changed files with 13 additions and 28 deletions
|
|
@ -146,10 +146,19 @@ func _apply_arena_camera_fit() -> void:
|
|||
bg_vp.size = win_size
|
||||
|
||||
# Also resize the SubViewportContainer (the immediate parent of the
|
||||
# SubViewport) so the stretch math doesn't compound the wrong ratio.
|
||||
# SubViewport) and bump its z_index so it draws OVER any world content
|
||||
# rendered directly by the root viewport. The SubViewport shares the
|
||||
# root viewport's world_2d, which means TerrainLayer/UnitLayer/etc are
|
||||
# rendered TWICE — once at zoom 1.0 directly by the root viewport, and
|
||||
# once at zoom 0.084 inside the SubViewport. They overlap incorrectly
|
||||
# in the composite. Pushing the container's z_index above the world
|
||||
# renderers (which are at default z=0) makes the composite cover them.
|
||||
var bg_container: Node = vwm.get_node_or_null("BackgroundViewport")
|
||||
if bg_container is Control:
|
||||
(bg_container as Control).size = win_size_v
|
||||
var bg_ctrl: Control = bg_container as Control
|
||||
bg_ctrl.size = win_size_v
|
||||
bg_ctrl.position = Vector2.ZERO
|
||||
bg_ctrl.z_index = 50
|
||||
|
||||
var viewport: Viewport = _world_map.get_viewport()
|
||||
if viewport == null:
|
||||
|
|
@ -298,34 +307,10 @@ func _capture_viewport_screenshot_async() -> void:
|
|||
if err != OK:
|
||||
push_warning("[AI ARENA] screenshot save failed: %s" % error_string(err))
|
||||
return
|
||||
var diag_zoom: float = -1.0
|
||||
var diag_subvp_size: Vector2i = Vector2i.ZERO
|
||||
var diag_vwm_size: Vector2 = Vector2.ZERO
|
||||
var vwm_diag: Node = _world_map.get_node_or_null("ViewportWindowManager")
|
||||
if vwm_diag != null:
|
||||
if vwm_diag is Control:
|
||||
diag_vwm_size = (vwm_diag as Control).size
|
||||
if vwm_diag.has_method("get_background_camera"):
|
||||
var diag_cam: Camera2D = vwm_diag.get_background_camera()
|
||||
if diag_cam != null:
|
||||
diag_zoom = diag_cam.zoom.x
|
||||
if vwm_diag.has_method("get_background_viewport"):
|
||||
var diag_vp: SubViewport = vwm_diag.call("get_background_viewport") as SubViewport
|
||||
if diag_vp != null:
|
||||
diag_subvp_size = diag_vp.size
|
||||
print(
|
||||
(
|
||||
"[AI ARENA] screenshot saved: %s (%dx%d) cam_zoom=%.3f subvp=%dx%d vwm=%dx%d"
|
||||
% [
|
||||
path,
|
||||
image.get_width(),
|
||||
image.get_height(),
|
||||
diag_zoom,
|
||||
diag_subvp_size.x,
|
||||
diag_subvp_size.y,
|
||||
int(diag_vwm_size.x),
|
||||
int(diag_vwm_size.y),
|
||||
]
|
||||
"[AI ARENA] screenshot saved: %s (%dx%d)"
|
||||
% [path, image.get_width(), image.get_height()]
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue