*
This commit is contained in:
@@ -307,8 +307,14 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
|
|||||||
if(RS && !changeOrAddList_removeList.empty()) {
|
if(RS && !changeOrAddList_removeList.empty()) {
|
||||||
for(auto &pair : changeOrAddList_removeList) {
|
for(auto &pair : changeOrAddList_removeList) {
|
||||||
// Если случится что чанк был изменён и удалён, то исключаем его обновления
|
// Если случится что чанк был изменён и удалён, то исключаем его обновления
|
||||||
for(Pos::GlobalChunk removed : std::get<1>(pair.second))
|
for(Pos::GlobalRegion removed : std::get<1>(pair.second)) {
|
||||||
std::get<0>(pair.second).erase(removed);
|
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));
|
RS->onChunksChange(pair.first, std::get<0>(pair.second), std::get<1>(pair.second));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
return {0, 0, 0};
|
return {0, 0, 0};
|
||||||
|
|
||||||
// Необходимое количество блоков
|
// Необходимое количество блоков
|
||||||
uint16_t blocks = data.size() / size_t(PerBlock);
|
uint16_t blocks = (data.size()+PerBlock-1) / PerBlock;
|
||||||
assert(blocks <= PerPool);
|
assert(blocks <= PerPool);
|
||||||
|
|
||||||
// Нужно найти пулл в котором будет свободно blocks количество блоков или создать новый
|
// Нужно найти пулл в котором будет свободно blocks количество блоков или создать новый
|
||||||
@@ -112,13 +112,17 @@ public:
|
|||||||
Pool &pool = Pools[iterPool];
|
Pool &pool = Pools[iterPool];
|
||||||
size_t pos = pool.Allocation._Find_first();
|
size_t pos = pool.Allocation._Find_first();
|
||||||
|
|
||||||
|
if(pos == PerPool)
|
||||||
|
continue;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
int countEmpty = 1;
|
int countEmpty = 1;
|
||||||
for(size_t pos2 = pos+1; pos2 < PerPool && pool.Allocation.test(pos2) && countEmpty < blocks; pos2++, countEmpty++);
|
for(size_t pos2 = pos+1; pos2 < PerPool && pool.Allocation.test(pos2) && countEmpty < blocks; pos2++, countEmpty++);
|
||||||
|
|
||||||
if(countEmpty == blocks) {
|
if(countEmpty == blocks) {
|
||||||
for(int block = 0; block < blocks; block++)
|
for(int block = 0; block < blocks; block++) {
|
||||||
pool.Allocation.reset(pos+block);
|
pool.Allocation.reset(pos+block);
|
||||||
|
}
|
||||||
|
|
||||||
size_t count = data.size();
|
size_t count = data.size();
|
||||||
pushData(std::move(data), iterPool, pos);
|
pushData(std::move(data), iterPool, pos);
|
||||||
@@ -245,6 +249,8 @@ public:
|
|||||||
task.Data.size()*sizeof(Vertex)
|
task.Data.size()*sizeof(Vertex)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
assert(copyRegion.dstOffset+copyRegion.size < sizeof(Vertex)*PerBlock*PerPool);
|
||||||
|
|
||||||
vkCmdCopyBuffer(commandBuffer, HostCoherent.getBuffer(), Pools[task.PoolId].DeviceBuff.getBuffer(),
|
vkCmdCopyBuffer(commandBuffer, HostCoherent.getBuffer(), Pools[task.PoolId].DeviceBuff.getBuffer(),
|
||||||
1, ©Region);
|
1, ©Region);
|
||||||
|
|
||||||
|
|||||||
@@ -617,6 +617,12 @@ void VulkanRenderSession::onChunksChange(WorldId_t worldId, const std::unordered
|
|||||||
auto &table = External.ChunkVoxelMesh[worldId];
|
auto &table = External.ChunkVoxelMesh[worldId];
|
||||||
|
|
||||||
for(Pos::GlobalChunk pos : changeOrAddList) {
|
for(Pos::GlobalChunk pos : changeOrAddList) {
|
||||||
|
if(pos.y < 0) {
|
||||||
|
int g = 0;
|
||||||
|
g++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Pos::GlobalRegion rPos = pos >> 2;
|
Pos::GlobalRegion rPos = pos >> 2;
|
||||||
Pos::bvec4u cPos = pos & 0x3;
|
Pos::bvec4u cPos = pos & 0x3;
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ void GameServer::BackingChunkPressure_t::run(int id) {
|
|||||||
for(int x = 0; x < 4; x++)
|
for(int x = 0; x < 4; x++)
|
||||||
{
|
{
|
||||||
auto &toPtr = dumpRegion.Nodes[Pos::bvec4u(x, y, z)];
|
auto &toPtr = dumpRegion.Nodes[Pos::bvec4u(x, y, z)];
|
||||||
const Node *fromPtr = (const Node*) ®ionObj.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());
|
std::copy(fromPtr, fromPtr+16*16*16, toPtr.data());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -142,7 +142,7 @@ void GameServer::BackingChunkPressure_t::run(int id) {
|
|||||||
chunkPos.unpack(index);
|
chunkPos.unpack(index);
|
||||||
|
|
||||||
auto &toPtr = dumpRegion.Nodes[chunkPos];
|
auto &toPtr = dumpRegion.Nodes[chunkPos];
|
||||||
const Node *fromPtr = (const Node*) ®ionObj.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());
|
std::copy(fromPtr, fromPtr+16*16*16, toPtr.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -752,7 +752,7 @@ IWorldSaveBackend::TickSyncInfo_Out GameServer::stepDatabaseSync() {
|
|||||||
ContentViewCircle cvc;
|
ContentViewCircle cvc;
|
||||||
cvc.WorldId = oPos.WorldId;
|
cvc.WorldId = oPos.WorldId;
|
||||||
cvc.Pos = Pos::Object_t::asChunkPos(oPos.ObjectPos);
|
cvc.Pos = Pos::Object_t::asChunkPos(oPos.ObjectPos);
|
||||||
cvc.Range = 2*2;
|
cvc.Range = 2;
|
||||||
|
|
||||||
std::vector<ContentViewCircle> newCVCs = Expanse.accumulateContentViewCircles(cvc);
|
std::vector<ContentViewCircle> newCVCs = Expanse.accumulateContentViewCircles(cvc);
|
||||||
ContentViewInfo newCbg = Expanse_t::makeContentViewInfo(newCVCs);
|
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;
|
auto &obj = toLoadRegions[key.WId].emplace_back(key.RegionPos, World::RegionIn()).second;
|
||||||
float *ptr = ®ion[0];
|
float *ptr = ®ion[0];
|
||||||
|
|
||||||
for(int z = 0; z < 64; z++)
|
{
|
||||||
for(int y = 0; y < 64; y++)
|
Node node;
|
||||||
for(int x = 0; x < 64; x++, ptr++) {
|
node.Data = 0;
|
||||||
// DefVoxelId_t id = *ptr > 0.9 ? 1 : 0;
|
std::fill((Node*) obj.Nodes.data(), ((Node*) obj.Nodes.data())+64*64*64, node);
|
||||||
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;
|
if((key.RegionPos.x == 0 || key.RegionPos.x == 0) && key.RegionPos.y == 0 && key.RegionPos.z == 0) {
|
||||||
// node.Data = 0;
|
for(int z = 0; z < 64; z++)
|
||||||
// std::fill((Node*) obj.Nodes.data(), ((Node*) obj.Nodes.data())+64*64*64, node);
|
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;
|
// obj.Nodes[0][0].NodeId = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ std::vector<Pos::GlobalRegion> World::onCEC_RegionsEnter(std::shared_ptr<Content
|
|||||||
for(int z = 0; z < 4; z++)
|
for(int z = 0; z < 4; z++)
|
||||||
for(int y = 0; y < 4; y++)
|
for(int y = 0; y < 4; y++)
|
||||||
for(int x = 0; x < 4; x++) {
|
for(int x = 0; x < 4; x++) {
|
||||||
nodes[Pos::bvec4u(x, y, z)] = (const Node*) ®ion.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) {
|
for(auto& [key, value] : regions) {
|
||||||
Region ®ion = *(Regions[key] = std::make_unique<Region>());
|
Region ®ion = *(Regions[key] = std::make_unique<Region>());
|
||||||
region.Voxels = std::move(value.Voxels);
|
region.Voxels = std::move(value.Voxels);
|
||||||
|
region.Nodes = value.Nodes;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
// x y cx cy cz
|
// x y cx cy cz
|
||||||
//LightPrism Lights[16][16][4][4][4];
|
//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<Entity> Entityes;
|
||||||
std::vector<std::shared_ptr<ContentEventController>> CECs, NewCECs;
|
std::vector<std::shared_ptr<ContentEventController>> CECs, NewCECs;
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ layout (triangle_strip, max_vertices = 3) out;
|
|||||||
|
|
||||||
layout(location = 0) in GeometryObj {
|
layout(location = 0) in GeometryObj {
|
||||||
vec3 GeoPos; // Реальная позиция в мире
|
vec3 GeoPos; // Реальная позиция в мире
|
||||||
uint Texture; // Текстура
|
flat uint Texture; // Текстура
|
||||||
vec2 UV;
|
vec2 UV;
|
||||||
} Geometry[];
|
} Geometry[];
|
||||||
|
|
||||||
layout(location = 0) out FragmentObj {
|
layout(location = 0) out FragmentObj {
|
||||||
vec3 GeoPos; // Реальная позиция в мире
|
vec3 GeoPos; // Реальная позиция в мире
|
||||||
uint Texture; // Текстура
|
flat uint Texture; // Текстура
|
||||||
vec2 UV;
|
vec2 UV;
|
||||||
} Fragment;
|
} Fragment;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -4,7 +4,7 @@ layout(location = 0) in uvec3 Vertex;
|
|||||||
|
|
||||||
layout(location = 0) out GeometryObj {
|
layout(location = 0) out GeometryObj {
|
||||||
vec3 GeoPos; // Реальная позиция в мире
|
vec3 GeoPos; // Реальная позиция в мире
|
||||||
uint Texture; // Текстура
|
flat uint Texture; // Текстура
|
||||||
vec2 UV;
|
vec2 UV;
|
||||||
} Geometry;
|
} Geometry;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
layout(location = 0) in FragmentObj {
|
layout(location = 0) in FragmentObj {
|
||||||
vec3 GeoPos; // Реальная позиция в мире
|
vec3 GeoPos; // Реальная позиция в мире
|
||||||
uint Texture; // Текстура
|
flat uint Texture; // Текстура
|
||||||
vec2 UV;
|
vec2 UV;
|
||||||
} Fragment;
|
} Fragment;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
layout(location = 0) in FragmentObj {
|
layout(location = 0) in FragmentObj {
|
||||||
vec3 GeoPos; // Реальная позиция в мире
|
vec3 GeoPos; // Реальная позиция в мире
|
||||||
uint Texture; // Текстура
|
flat uint Texture; // Текстура
|
||||||
vec2 UV;
|
vec2 UV;
|
||||||
} Fragment;
|
} Fragment;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user