BT5-Dev #62: BT48 commit b84c236 시점 정확 회귀 (PD 명시 채택)

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 메모리 등재
This commit is contained in:
깃 관리자 2026-05-07 23:58:02 +09:00
parent 7e62f58267
commit 57328ec151
2 changed files with 39 additions and 16 deletions

View File

@ -80,7 +80,10 @@ namespace Platformer.Mechanics
fgTilemap = foreground.GetComponent<UnityEngine.Tilemaps.Tilemap>(); fgTilemap = foreground.GetComponent<UnityEngine.Tilemaps.Tilemap>();
} }
// 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"); var levelGo = GameObject.Find("Level");
if (levelGo != null && fgTilemap != null) if (levelGo != null && fgTilemap != null)
{ {
@ -89,9 +92,10 @@ namespace Platformer.Mechanics
if (levelTilemap != null && player != null) if (levelTilemap != null && player != null)
{ {
float playerY = player.transform.position.y; 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; var bounds = levelTilemap.cellBounds;
int moved = 0; int movedHigh = 0, movedSmall = 0;
for (int x = bounds.xMin; x <= bounds.xMax; x++) for (int x = bounds.xMin; x <= bounds.xMax; x++)
{ {
for (int y = bounds.yMin; y <= bounds.yMax; y++) for (int y = bounds.yMin; y <= bounds.yMax; y++)
@ -99,24 +103,50 @@ namespace Platformer.Mechanics
var pos = new Vector3Int(x, y, 0); var pos = new Vector3Int(x, y, 0);
if (!levelTilemap.HasTile(pos)) continue; if (!levelTilemap.HasTile(pos)) continue;
Vector3 worldPos = levelTilemap.CellToWorld(pos); Vector3 worldPos = levelTilemap.CellToWorld(pos);
if (worldPos.y < airThresholdY) continue; // 지면·벽 영역 그대로 bool aboveThreshold = worldPos.y >= airThresholdY;
// 공중 영역 Tile → Foreground 영역 영역 이동 bool isSmallAir = !aboveThreshold && IsSmallAirPlatform(levelTilemap, pos, MAX_PLATFORM_WIDTH);
if (!aboveThreshold && !isSmallAir) continue;
var tile = levelTilemap.GetTile(pos); var tile = levelTilemap.GetTile(pos);
fgTilemap.SetTile(pos, tile); fgTilemap.SetTile(pos, tile);
fgTilemap.SetColliderType(pos, UnityEngine.Tilemaps.Tile.ColliderType.Sprite); fgTilemap.SetColliderType(pos, UnityEngine.Tilemaps.Tile.ColliderType.Sprite);
levelTilemap.SetTile(pos, null); levelTilemap.SetTile(pos, null);
moved++; if (aboveThreshold) movedHigh++;
else movedSmall++;
} }
} }
if (fgTc != null) fgTc.ProcessTilemapChanges(); if (fgTc != null) fgTc.ProcessTilemapChanges();
var lvlTc = levelGo.GetComponent<UnityEngine.Tilemaps.TilemapCollider2D>(); var lvlTc = levelGo.GetComponent<UnityEngine.Tilemaps.TilemapCollider2D>();
if (lvlTc != null) lvlTc.ProcessTilemapChanges(); 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($"[BT48-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}");
Debug.Log($"[BT47-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); Debug.Log($"[BT48-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]");
}
/// <summary>
/// BT48 — 작은 공중 발판 판별. 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 maxWidth 이하.
/// 일반 지면(통상 10+ tile 가로) 잘못 분류 방지.
/// </summary>
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;
} }
} }
} }

View File

@ -221,13 +221,6 @@ namespace Platformer.Mechanics
int mask = standingOnPlatform ? baseMask : (baseMask & ~(1 << JUMP_THROUGH_LAYER)); int mask = standingOnPlatform ? baseMask : (baseMask & ~(1 << JUMP_THROUGH_LAYER));
contactFilter.SetLayerMask(mask); contactFilter.SetLayerMask(mask);
contactFilter.useLayerMask = true; 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<<JUMP_THROUGH_LAYER)) != 0} pos={transform.position.y:F2} bounds.min.y={(collider2d!=null?collider2d.bounds.min.y:0):F2}");
}
} }
protected override void ComputeVelocity() protected override void ComputeVelocity()