49 lines
1.8 KiB
Markdown
49 lines
1.8 KiB
Markdown
---
|
||
title: "LargeWorldCoordinates"
|
||
type: concept
|
||
tags: ["unreal-engine", "coordinates", "precision", "open-world"]
|
||
sources: ["unreal-world-builder"]
|
||
last_updated: 2026-04-30
|
||
---
|
||
|
||
## Aliases
|
||
- LWC
|
||
- Large World Coordinates
|
||
- 大世界坐标
|
||
- 双精度坐标
|
||
|
||
## Definition
|
||
Large World Coordinates(LWC)是 Unreal Engine 5 引入的双精度(double)坐标系统,用于解决超大世界(任何轴超过 2km)中的浮点精度问题。无 LWC 时,约 20km 处开始出现可见的浮点精度错误。
|
||
|
||
## Precision Problem
|
||
IEEE 754 单精度浮点数(float)在以下场景产生精度损失:
|
||
- **大数值**:坐标值越大,相邻值之间的 gap 越大
|
||
- **远距离相加**:大坐标值与小数值的加法丢失精度
|
||
- **累积误差**:多次变换后误差累积
|
||
|
||
## LWC Enabling Threshold
|
||
- **强制启用**:世界任何轴超过 2km
|
||
- **精度损失临界点**:~20km(无 LWC 时可见)
|
||
- **最大安全范围**:建议 100km 以内(即使启用 LWC)
|
||
|
||
## Code Changes Required
|
||
| 位置 | float → double 替代 |
|
||
|------|-------------------|
|
||
| 游戏性代码(位置计算) | `FVector` → `FVector3d` |
|
||
| 着色器/材质 | 直接世界位置采样 → `LWCToFloat()` 转换 |
|
||
| 网络复制 | 仍用单精度(本地双精度,复制时转换) |
|
||
|
||
## LWC Compliance Audit
|
||
迁移到 LWC 时必须审查:
|
||
- [ ] 所有着色器和材质使用 `LWCToFloat()` 而非直接世界位置采样
|
||
- [ ] 游戏中所有位置计算使用 `FVector3d`
|
||
- [ ] 在 100km 以外spawn玩家并验证无视觉/物理瑕疵
|
||
|
||
## Connections
|
||
- [[UnrealWorldBuilder]] ← 坐标系统 ← LargeWorldCoordinates
|
||
- [[UnrealEngine5]] ← 核心引擎 ← LargeWorldCoordinates
|
||
- [[WorldPartition]] ← 空间管理 ← LargeWorldCoordinates
|
||
|
||
## Sources
|
||
- [[unreal-world-builder]]
|