feat: embed tile height placeholder inside arena .tscn files and bake terrain transform shifts natively instead of using code hacks
This commit is contained in:
+16
-17
@@ -166,13 +166,17 @@ func _instantiate_3d_arena(scene_path: String):
|
||||
var arena_instance = arena_scene.instantiate()
|
||||
arena_instance.name = "ArenaEnvironment3D"
|
||||
|
||||
if "freemode" in scene_path or "stop_n_go" in scene_path:
|
||||
# The Terrainv2.gltf (and related arenas) have their floor physically modeled around Y=0.22.
|
||||
# Shift it down so the visual floor aligns properly with gridmap items.
|
||||
arena_instance.position.y = -0.22
|
||||
# Note: We no longer shift the arena via code (e.g., position.y = -0.22)
|
||||
# The physical shifts have been baked directly into the .tscn files using EditorTileReference.
|
||||
|
||||
add_child(arena_instance)
|
||||
move_child(arena_instance, 0)
|
||||
|
||||
# Clean up the EditorTileReference if it was left in the scene
|
||||
var editor_ref = arena_instance.get_node_or_null("EditorTileReference")
|
||||
if editor_ref:
|
||||
editor_ref.queue_free()
|
||||
|
||||
print("Instantiated 3D Arena: ", scene_path)
|
||||
|
||||
func _hide_ground_tiles():
|
||||
@@ -194,21 +198,16 @@ func _setup_effect_elevation():
|
||||
if em and em.mesh_library:
|
||||
var ml = em.mesh_library.duplicate()
|
||||
|
||||
# Only lift tiles for modes that use the shifted Terrainv2.gltf (-0.22 offset)
|
||||
# Now that terrain heights are perfectly aligned inside the .tscn files,
|
||||
# we no longer need to dynamically lift all tiles by 0.08.
|
||||
# However, we still need to slightly drop TILE_SAFE (id 2) so it
|
||||
# renders strictly as a floor decal without clipping.
|
||||
if LobbyManager.game_mode in ["Stop n Go", "Freemode"]:
|
||||
var lift_transform = Transform3D().translated(Vector3(0, 0.08, 0))
|
||||
for id in ml.get_item_list():
|
||||
if id == 4: continue # Skip hidden non-walkable blocks
|
||||
|
||||
var apply_transform = lift_transform
|
||||
# TILE_SAFE (2) is painted on Layer 2 (Y=0.10).
|
||||
# We want it below all grid tiles (Layer 0 is at 0.08) but above the terrain (0.06).
|
||||
# We set it to 0.07 by applying a -0.03 offset (0.10 - 0.03 = 0.07).
|
||||
if id == 2:
|
||||
apply_transform = Transform3D().translated(Vector3(0, -0.03, 0))
|
||||
|
||||
if ml.find_item_by_name("safe_zone") != -1 or 2 in ml.get_item_list():
|
||||
var id = 2
|
||||
var current_transform = ml.get_item_mesh_transform(id)
|
||||
ml.set_item_mesh_transform(id, apply_transform * current_transform)
|
||||
# Push it down by -0.02 so it sits perfectly between terrain and tiles
|
||||
ml.set_item_mesh_transform(id, Transform3D().translated(Vector3(0, -0.02, 0)) * current_transform)
|
||||
|
||||
em.mesh_library = ml
|
||||
|
||||
|
||||
Reference in New Issue
Block a user