feat(mpsync): 实体位置广播(EntityMove)与客户端在线玩家显示;mesh 顶点池复用(性能与内存.md §2)

This commit is contained in:
NianGao Dev
2026-08-16 00:05:17 +08:00
parent e70314fb3f
commit 95c8d677ea
10 changed files with 146 additions and 21 deletions

View File

@@ -26,6 +26,22 @@ func dummyUV(key string) (float32, float32, float32, float32, bool) {
return 0, 0, 1, 1, true
}
// TestPoolReuse 顶点池复用:Build → Release → 再次 Build 不崩溃且结果正确(性能与内存.md §2)。
func TestPoolReuse(t *testing.T) {
reg := loadReg(t)
stone, _ := reg.ID("stone")
c := chunk.New(0, 0)
c.Fill(0, 0, 0, block.NewState(stone, 0))
b := NewBuilder(reg, dummyUV)
for i := 0; i < 3; i++ {
m := b.Build(c, airNb)
if len(m.Opaque) != 24 {
t.Fatalf("第 %d 次构建顶点数异常: %d", i, len(m.Opaque))
}
Release(m)
}
}
// TestSingleBlock 单方块 6 面全生成:24 顶点(6 面 × 4 顶点四边形)。
func TestSingleBlock(t *testing.T) {
reg := loadReg(t)