This commit is contained in:
2025-07-09 23:02:19 +06:00
parent 2eb48d12a8
commit c0989a53ea
13 changed files with 59 additions and 39 deletions

View File

@@ -307,8 +307,14 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
if(RS && !changeOrAddList_removeList.empty()) {
for(auto &pair : changeOrAddList_removeList) {
// Если случится что чанк был изменён и удалён, то исключаем его обновления
for(Pos::GlobalChunk removed : std::get<1>(pair.second))
std::get<0>(pair.second).erase(removed);
for(Pos::GlobalRegion removed : std::get<1>(pair.second)) {
Pos::GlobalChunk pos = removed << 2;
for(int z = 0; z < 4; z++)
for(int y = 0; y < 4; y++)
for(int x = 0; x < 4; x++) {
std::get<0>(pair.second).erase(pos+Pos::GlobalChunk(x, y, z));
}
}
RS->onChunksChange(pair.first, std::get<0>(pair.second), std::get<1>(pair.second));
}

View File

@@ -104,7 +104,7 @@ public:
return {0, 0, 0};
// Необходимое количество блоков
uint16_t blocks = data.size() / size_t(PerBlock);
uint16_t blocks = (data.size()+PerBlock-1) / PerBlock;
assert(blocks <= PerPool);
// Нужно найти пулл в котором будет свободно blocks количество блоков или создать новый
@@ -112,13 +112,17 @@ public:
Pool &pool = Pools[iterPool];
size_t pos = pool.Allocation._Find_first();
if(pos == PerPool)
continue;
while(true) {
int countEmpty = 1;
for(size_t pos2 = pos+1; pos2 < PerPool && pool.Allocation.test(pos2) && countEmpty < blocks; pos2++, countEmpty++);
if(countEmpty == blocks) {
for(int block = 0; block < blocks; block++)
for(int block = 0; block < blocks; block++) {
pool.Allocation.reset(pos+block);
}
size_t count = data.size();
pushData(std::move(data), iterPool, pos);
@@ -245,6 +249,8 @@ public:
task.Data.size()*sizeof(Vertex)
};
assert(copyRegion.dstOffset+copyRegion.size < sizeof(Vertex)*PerBlock*PerPool);
vkCmdCopyBuffer(commandBuffer, HostCoherent.getBuffer(), Pools[task.PoolId].DeviceBuff.getBuffer(),
1, &copyRegion);

View File

@@ -617,6 +617,12 @@ void VulkanRenderSession::onChunksChange(WorldId_t worldId, const std::unordered
auto &table = External.ChunkVoxelMesh[worldId];
for(Pos::GlobalChunk pos : changeOrAddList) {
if(pos.y < 0) {
int g = 0;
g++;
}
Pos::GlobalRegion rPos = pos >> 2;
Pos::bvec4u cPos = pos & 0x3;

View File

@@ -112,7 +112,7 @@ void GameServer::BackingChunkPressure_t::run(int id) {
for(int x = 0; x < 4; x++)
{
auto &toPtr = dumpRegion.Nodes[Pos::bvec4u(x, y, z)];
const Node *fromPtr = (const Node*) &regionObj.Nodes[0][0][0][x][y][z];
const Node *fromPtr = regionObj.Nodes[Pos::bvec4u(x, y, z).pack()].data();
std::copy(fromPtr, fromPtr+16*16*16, toPtr.data());
}
} else {
@@ -142,7 +142,7 @@ void GameServer::BackingChunkPressure_t::run(int id) {
chunkPos.unpack(index);
auto &toPtr = dumpRegion.Nodes[chunkPos];
const Node *fromPtr = (const Node*) &regionObj.Nodes[0][0][0][chunkPos.x][chunkPos.y][chunkPos.z];
const Node *fromPtr = regionObj.Nodes[chunkPos.pack()].data();
std::copy(fromPtr, fromPtr+16*16*16, toPtr.data());
}
}
@@ -752,7 +752,7 @@ IWorldSaveBackend::TickSyncInfo_Out GameServer::stepDatabaseSync() {
ContentViewCircle cvc;
cvc.WorldId = oPos.WorldId;
cvc.Pos = Pos::Object_t::asChunkPos(oPos.ObjectPos);
cvc.Range = 2*2;
cvc.Range = 2;
std::vector<ContentViewCircle> newCVCs = Expanse.accumulateContentViewCircles(cvc);
ContentViewInfo newCbg = Expanse_t::makeContentViewInfo(newCVCs);
@@ -842,26 +842,34 @@ void GameServer::stepGeneratorAndLuaAsync(IWorldSaveBackend::TickSyncInfo_Out db
auto &obj = toLoadRegions[key.WId].emplace_back(key.RegionPos, World::RegionIn()).second;
float *ptr = &region[0];
for(int z = 0; z < 64; z++)
for(int y = 0; y < 64; y++)
for(int x = 0; x < 64; x++, ptr++) {
// DefVoxelId_t id = *ptr > 0.9 ? 1 : 0;
Pos::bvec64u nodePos(x, y, z);
auto &node = obj.Nodes[Pos::bvec4u(nodePos >> 4).pack()][Pos::bvec16u(nodePos & 0xf).pack()];
// node.NodeId = id;
// node.Meta = 0;
if(y == (key.RegionPos.y % 64))
node.NodeId = 1;
else
node.NodeId = 0;
node.Meta = 0;
{
Node node;
node.Data = 0;
std::fill((Node*) obj.Nodes.data(), ((Node*) obj.Nodes.data())+64*64*64, node);
}
// Node node;
// node.Data = 0;
// std::fill((Node*) obj.Nodes.data(), ((Node*) obj.Nodes.data())+64*64*64, node);
if((key.RegionPos.x == 0 || key.RegionPos.x == 0) && key.RegionPos.y == 0 && key.RegionPos.z == 0) {
for(int z = 0; z < 64; z++)
for(int y = 0; y < 64; y++)
for(int x = 0; x < 64; x++, ptr++) {
// DefVoxelId_t id = *ptr > 0.9 ? 1 : 0;
Pos::bvec64u nodePos(x, y, z);
auto &node = obj.Nodes[Pos::bvec4u(nodePos >> 4).pack()][Pos::bvec16u(nodePos & 0xf).pack()];
// node.NodeId = id;
// node.Meta = 0;
if(
(y == 0 && z == 0)
// || (x == 0 && z == 0)
// || (x == 0 && y == 0)
) {
if(x+y+z <= 18)
node.NodeId = (((x+y+z)/3)%3)+1;
}
node.Meta = 0;
}
}
// obj.Nodes[0][0].NodeId = 1;
}

View File

@@ -40,7 +40,7 @@ std::vector<Pos::GlobalRegion> World::onCEC_RegionsEnter(std::shared_ptr<Content
for(int z = 0; z < 4; z++)
for(int y = 0; y < 4; y++)
for(int x = 0; x < 4; x++) {
nodes[Pos::bvec4u(x, y, z)] = (const Node*) &region.Nodes[0][0][0][x][y][z];
nodes[Pos::bvec4u(x, y, z)] = region.Nodes[Pos::bvec4u(x, y, z).pack()].data();
}
@@ -73,13 +73,7 @@ void World::pushRegions(std::vector<std::pair<Pos::GlobalRegion, RegionIn>> regi
for(auto& [key, value] : regions) {
Region &region = *(Regions[key] = std::make_unique<Region>());
region.Voxels = std::move(value.Voxels);
Node *ptr = (Node*) region.Nodes;
for(std::array<Node, 16*16*16>& nodes : value.Nodes) {
std::copy(nodes.data(), nodes.data()+16*16*16, ptr);
ptr += 16*16*16;
}
region.Nodes = value.Nodes;
}
}

View File

@@ -22,7 +22,7 @@ public:
// x y cx cy cz
//LightPrism Lights[16][16][4][4][4];
Node Nodes[16][16][16][4][4][4];
std::array<std::array<Node, 16*16*16>, 4*4*4> Nodes;
std::vector<Entity> Entityes;
std::vector<std::shared_ptr<ContentEventController>> CECs, NewCECs;

View File

@@ -5,13 +5,13 @@ layout (triangle_strip, max_vertices = 3) out;
layout(location = 0) in GeometryObj {
vec3 GeoPos; // Реальная позиция в мире
uint Texture; // Текстура
flat uint Texture; // Текстура
vec2 UV;
} Geometry[];
layout(location = 0) out FragmentObj {
vec3 GeoPos; // Реальная позиция в мире
uint Texture; // Текстура
flat uint Texture; // Текстура
vec2 UV;
} Fragment;

Binary file not shown.

View File

@@ -4,7 +4,7 @@ layout(location = 0) in uvec3 Vertex;
layout(location = 0) out GeometryObj {
vec3 GeoPos; // Реальная позиция в мире
uint Texture; // Текстура
flat uint Texture; // Текстура
vec2 UV;
} Geometry;

Binary file not shown.

View File

@@ -2,7 +2,7 @@
layout(location = 0) in FragmentObj {
vec3 GeoPos; // Реальная позиция в мире
uint Texture; // Текстура
flat uint Texture; // Текстура
vec2 UV;
} Fragment;

View File

@@ -2,7 +2,7 @@
layout(location = 0) in FragmentObj {
vec3 GeoPos; // Реальная позиция в мире
uint Texture; // Текстура
flat uint Texture; // Текстура
vec2 UV;
} Fragment;