From 57328ec15159ce5fccbb8bc537f41307f7418689 Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 23:58:02 +0900 Subject: [PATCH] =?UTF-8?q?BT5-Dev=20#62:=20BT48=20commit=20b84c236=20?= =?UTF-8?q?=EC=8B=9C=EC=A0=90=20=EC=A0=95=ED=99=95=20=ED=9A=8C=EA=B7=80=20?= =?UTF-8?q?(PD=20=EB=AA=85=EC=8B=9C=20=EC=B1=84=ED=83=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PD 명시 (2026-05-07): "BT48로 복귀해봐" 변경 (git checkout b84c236): - Assets/Scripts/Mechanics/GameOptimizer.cs = BT48 시점 영역 (BT47 임계값 + BT48 작은 발판 휴리스틱 가로≤8+위·아래 빈) - Assets/Scripts/Mechanics/PlayerController.cs = BT48 시점 영역 (BT57 Debug.Log 폐기) - Assets/Prefabs/Player.prefab = BT48 시점과 동일 (m_Size 0.45×1.15·m_Offset 0,0.1) BT48 시점 동작 (Editor.log 이전 진단): - [BT48-MoveTiles] moved=1480 (high=1389 thresholdY=1.50 / smallAir=91 maxWidth=8) - Foreground TilemapCollider 자동 부착 + Layer 16 - ContactFilter mask 동적 (PlayerController.UpdateContactFilterForDropThrough) - Drop-Through 패턴 (위 착지 + ascending 통과) BT49~BT61 누적 14회 변경 모두 폐기 + BT48 정확 회귀. 후속 의무: - PD Refresh+Play 시각 검증 - 본 PM Editor.log [BT48-MoveTiles]·[BT48-DropThrough] direct read - 정합 시 BT49~BT61 영역 영구 폐기·feedback 메모리 등재 --- Assets/Scripts/Mechanics/GameOptimizer.cs | 48 ++++++++++++++++---- Assets/Scripts/Mechanics/PlayerController.cs | 7 --- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index b5a8c02..32bbd28 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -80,7 +80,10 @@ namespace Platformer.Mechanics fgTilemap = foreground.GetComponent(); } - // BT47 — Level Tilemap의 공중 Tile (Player 시작 Y + 1.5 이상 영역) 영역 → Foreground 영역 자동 이동 + // BT48 — Level → Foreground 자동 분류 강화. 분류 조건 2종 결합: + // (a) 임계값 위 (worldY >= playerY + 1.5) = 공중 = 무조건 Foreground (BT47 호환) + // (b) 임계값 아래여도 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 8 tile 이하 = 작은 공중 발판 + // → 일반 지면(통상 10+ tile 가로) 잘못 분류 방지 + 첨부 이미지 같은 작은 발판 자동 분류 var levelGo = GameObject.Find("Level"); if (levelGo != null && fgTilemap != null) { @@ -89,9 +92,10 @@ namespace Platformer.Mechanics if (levelTilemap != null && player != null) { float playerY = player.transform.position.y; - float airThresholdY = playerY + 1.5f; // Player 시작 Y + 1.5 위 = 공중 발판 영역 + float airThresholdY = playerY + 1.5f; // Player 시작 Y + 1.5 위 = 공중 (BT47 호환) + const int MAX_PLATFORM_WIDTH = 8; var bounds = levelTilemap.cellBounds; - int moved = 0; + int movedHigh = 0, movedSmall = 0; for (int x = bounds.xMin; x <= bounds.xMax; x++) { for (int y = bounds.yMin; y <= bounds.yMax; y++) @@ -99,24 +103,50 @@ namespace Platformer.Mechanics var pos = new Vector3Int(x, y, 0); if (!levelTilemap.HasTile(pos)) continue; Vector3 worldPos = levelTilemap.CellToWorld(pos); - if (worldPos.y < airThresholdY) continue; // 지면·벽 영역 그대로 - // 공중 영역 Tile → Foreground 영역 영역 이동 + bool aboveThreshold = worldPos.y >= airThresholdY; + bool isSmallAir = !aboveThreshold && IsSmallAirPlatform(levelTilemap, pos, MAX_PLATFORM_WIDTH); + if (!aboveThreshold && !isSmallAir) continue; var tile = levelTilemap.GetTile(pos); fgTilemap.SetTile(pos, tile); fgTilemap.SetColliderType(pos, UnityEngine.Tilemaps.Tile.ColliderType.Sprite); levelTilemap.SetTile(pos, null); - moved++; + if (aboveThreshold) movedHigh++; + else movedSmall++; } } if (fgTc != null) fgTc.ProcessTilemapChanges(); var lvlTc = levelGo.GetComponent(); if (lvlTc != null) lvlTc.ProcessTilemapChanges(); - Debug.Log($"[BT47-MoveTiles] moved={moved} air tiles from Level (worldY>={airThresholdY:F2}) to Foreground"); + Debug.Log($"[BT48-MoveTiles] moved={movedHigh + movedSmall} (high={movedHigh} thresholdY={airThresholdY:F2} / smallAir={movedSmall} maxWidth={MAX_PLATFORM_WIDTH})"); } } - Debug.Log($"[BT47-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); - Debug.Log($"[BT47-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); + Debug.Log($"[BT48-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); + Debug.Log($"[BT48-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); + } + + /// + /// BT48 — 작은 공중 발판 판별. 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 maxWidth 이하. + /// 일반 지면(통상 10+ tile 가로) 잘못 분류 방지. + /// + static bool IsSmallAirPlatform(UnityEngine.Tilemaps.Tilemap tm, Vector3Int pos, int maxWidth) + { + if (tm.HasTile(pos + Vector3Int.up)) return false; + if (tm.HasTile(pos + Vector3Int.down)) return false; + int width = 1; + for (int dx = 1; dx <= maxWidth; dx++) + { + if (!tm.HasTile(pos + new Vector3Int(dx, 0, 0))) break; + width++; + if (width > maxWidth) return false; + } + for (int dx = 1; dx <= maxWidth; dx++) + { + if (!tm.HasTile(pos + new Vector3Int(-dx, 0, 0))) break; + width++; + if (width > maxWidth) return false; + } + return width <= maxWidth; } } } diff --git a/Assets/Scripts/Mechanics/PlayerController.cs b/Assets/Scripts/Mechanics/PlayerController.cs index 311cef5..cbfccdc 100644 --- a/Assets/Scripts/Mechanics/PlayerController.cs +++ b/Assets/Scripts/Mechanics/PlayerController.cs @@ -221,13 +221,6 @@ namespace Platformer.Mechanics int mask = standingOnPlatform ? baseMask : (baseMask & ~(1 << JUMP_THROUGH_LAYER)); contactFilter.SetLayerMask(mask); contactFilter.useLayerMask = true; - - // BT57 — 진단 (점프 시점·발판 영역만 출력. PD Refresh+Play 후 본 PM Editor.log direct read 의무) - if (jump || jumpState == JumpState.PrepareToJump || jumpState == JumpState.Jumping - || (jumpState == JumpState.InFlight && Mathf.Abs(velocity.y) > 0.5f)) - { - Debug.Log($"[BT57-DropThrough] state={jumpState} velY={velocity.y:F2} stand={standingOnPlatform} mask16={(mask & (1<