BT5-Dev #52: 자동 분류 보수적 정정 — TileFloating* 3종만 (PD 옵션 A 채택)
PD 결정 (2026-05-07): "A안대로 진행해" 근본 원인 (Editor.log 직접 read): - [BT48-MoveTiles] moved=3524 비정상 (정상 1389 대비 2.5배) - BT47/BT48 휴리스틱(임계값 playerY+1.5·작은 발판 가로≤8+위·아래 빈) = 정상 길·배경 벽지까지 자동 Foreground 이동 - → "숨겨진 레이어가 정상적인 길을 막고 있어" 근본 원인 - BT49/BT50/BT51 사후 복원 가설 모두 효과 X (restored=0/forced=0) — 4회 누적 부정확 자인 옵션 A 변경 (PD 승인 범위): 1. 휴리스틱 폐기: 임계값·작은 발판·BT49 None 차단 영역 모두 폐기 2. 새 알고리즘: Tile asset 이름 prefix "TileFloating" 3종만 자동 분류 (TileFloatingLeftEdge·TileFloatingRightEdge·TileFloatingTileMiddle — 카탈로그 17종 중 명시적 Floating 의도 3종) 3. 그 외 모든 Tile = Level 잔존 (PD Inspector 직접 분류 — 표준 Unity Tilemap 워크플로우) 4. 마이그레이션 X (PD 옵션 A 결정 — Foreground 변경 X·위험 최소화) 5. IsSmallAirPlatform 헬퍼 폐기 (dead code) 6. 사후 복원 영역 (BT51 None 처리) 유지 후속 의무: - PD Refresh+Play 시각 검증 + 잘못 분류된 영역 발견 시 PD 직접 Inspector 정정 또는 카탈로그 확장 안건 - 본 PM 직접 Editor.log [BT52-Classify] floating moved=N read 의무 Debug.Log: [BT52-Classify] floating moved=N (Level→Foreground TileFloating* 3종만)
This commit is contained in:
parent
dc00afd0a2
commit
77915e21ab
|
|
@ -80,55 +80,43 @@ namespace Platformer.Mechanics
|
|||
fgTilemap = foreground.GetComponent<UnityEngine.Tilemaps.Tilemap>();
|
||||
}
|
||||
|
||||
// BT48 — Level → Foreground 자동 분류 강화. 분류 조건 2종 결합:
|
||||
// (a) 임계값 위 (worldY >= playerY + 1.5) = 공중 = 무조건 Foreground (BT47 호환)
|
||||
// (b) 임계값 아래여도 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 8 tile 이하 = 작은 공중 발판
|
||||
// → 일반 지면(통상 10+ tile 가로) 잘못 분류 방지 + 첨부 이미지 같은 작은 발판 자동 분류
|
||||
// BT52-A — 자동 분류 알고리즘 보수적 정정 (PD 옵션 A 채택 2026-05-07).
|
||||
// BT47/BT48 임계값(playerY+1.5)·작은 발판(가로≤8+위·아래 빈) 휴리스틱 폐기.
|
||||
// 근거: Editor.log [BT48-MoveTiles] moved=3524 비정상 (정상 1389 대비 2.5배)
|
||||
// = 휴리스틱이 정상 길·배경 벽지까지 자동 Foreground 이동 → "숨겨진 레이어가 정상적인 길을 막고 있어" 근본 원인.
|
||||
// 새 알고리즘: Tile asset 이름 prefix "TileFloating" 3종만 명확한 공중 발판 의도로 자동 분류.
|
||||
// (TileFloatingLeftEdge·TileFloatingRightEdge·TileFloatingTileMiddle — 카탈로그 17종 중 명시적 Floating 의도 3종)
|
||||
// 그 외 모든 Tile = Level 잔존 (PD Inspector 직접 의도 분류 — 표준 Unity Tilemap 워크플로우).
|
||||
// 마이그레이션 X (PD 옵션 A 결정 — Foreground 변경 X·위험 최소화).
|
||||
var levelGo = GameObject.Find("Level");
|
||||
if (levelGo != null && fgTilemap != null)
|
||||
{
|
||||
var levelTilemap = levelGo.GetComponent<UnityEngine.Tilemaps.Tilemap>();
|
||||
var player = Object.FindFirstObjectByType<PlayerController>();
|
||||
if (levelTilemap != null && player != null)
|
||||
if (levelTilemap != null)
|
||||
{
|
||||
float playerY = player.transform.position.y;
|
||||
float airThresholdY = playerY + 1.5f; // Player 시작 Y + 1.5 위 = 공중 (BT47 호환)
|
||||
const int MAX_PLATFORM_WIDTH = 8;
|
||||
var bounds = levelTilemap.cellBounds;
|
||||
int movedHigh = 0, movedSmall = 0;
|
||||
int movedFloating = 0;
|
||||
for (int x = bounds.xMin; x <= bounds.xMax; x++)
|
||||
{
|
||||
for (int y = bounds.yMin; y <= bounds.yMax; y++)
|
||||
{
|
||||
var pos = new Vector3Int(x, y, 0);
|
||||
if (!levelTilemap.HasTile(pos)) continue;
|
||||
|
||||
// BT49 — Tile asset의 m_ColliderType=None = 배경 의도 (예: tree·cloud) = 자동 분류 제외
|
||||
var tileAsset = levelTilemap.GetTile<UnityEngine.Tilemaps.Tile>(pos);
|
||||
if (tileAsset != null && tileAsset.colliderType == UnityEngine.Tilemaps.Tile.ColliderType.None) continue;
|
||||
|
||||
Vector3 worldPos = levelTilemap.CellToWorld(pos);
|
||||
bool aboveThreshold = worldPos.y >= airThresholdY;
|
||||
bool isSmallAir = !aboveThreshold && IsSmallAirPlatform(levelTilemap, pos, MAX_PLATFORM_WIDTH);
|
||||
if (!aboveThreshold && !isSmallAir) continue;
|
||||
if (tileAsset == null) continue;
|
||||
string nm = tileAsset.name ?? string.Empty;
|
||||
if (!nm.StartsWith("TileFloating")) continue;
|
||||
var tile = levelTilemap.GetTile(pos);
|
||||
// BT49 — Foreground 이동 시 Tile asset 원래 colliderType 존중 (None=배경, Sprite=발판)
|
||||
// BT50 — Grid (1) Tile은 Sprite (2)로 강제. 이전 BT47 호환 — Grid 사각형 Collider는
|
||||
// sprite 빈 픽셀 영역(두 레이어 겹친 숨겨진 길)을 차단 → Sprite 정확 Collider로 빈 영역 통과 보존
|
||||
var srcColliderType = (tileAsset != null) ? tileAsset.colliderType : UnityEngine.Tilemaps.Tile.ColliderType.Sprite;
|
||||
if (srcColliderType == UnityEngine.Tilemaps.Tile.ColliderType.Grid)
|
||||
srcColliderType = UnityEngine.Tilemaps.Tile.ColliderType.Sprite;
|
||||
fgTilemap.SetTile(pos, tile);
|
||||
fgTilemap.SetColliderType(pos, srcColliderType);
|
||||
fgTilemap.SetColliderType(pos, UnityEngine.Tilemaps.Tile.ColliderType.Sprite);
|
||||
levelTilemap.SetTile(pos, null);
|
||||
if (aboveThreshold) movedHigh++;
|
||||
else movedSmall++;
|
||||
movedFloating++;
|
||||
}
|
||||
}
|
||||
if (fgTc != null) fgTc.ProcessTilemapChanges();
|
||||
var lvlTc = levelGo.GetComponent<UnityEngine.Tilemaps.TilemapCollider2D>();
|
||||
if (lvlTc != null) lvlTc.ProcessTilemapChanges();
|
||||
Debug.Log($"[BT48-MoveTiles] moved={movedHigh + movedSmall} (high={movedHigh} thresholdY={airThresholdY:F2} / smallAir={movedSmall} maxWidth={MAX_PLATFORM_WIDTH})");
|
||||
Debug.Log($"[BT52-Classify] floating moved={movedFloating} (Level→Foreground TileFloating* 3종만 / 마이그레이션 X)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -164,28 +152,7 @@ namespace Platformer.Mechanics
|
|||
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;
|
||||
}
|
||||
// BT52-A — IsSmallAirPlatform 헬퍼 폐기 (BT48 휴리스틱 알고리즘 폐기에 따른 dead code 제거).
|
||||
// 새 알고리즘은 Tile asset 이름 매칭만 사용 — 헬퍼 불요.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue