Исправлен баг с пропаданием территории на клиенте
This commit is contained in:
@@ -561,7 +561,7 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
|
|||||||
for(auto &pair : changeOrAddList_removeList) {
|
for(auto &pair : changeOrAddList_removeList) {
|
||||||
// Если случится что чанк был изменён и удалён, то исключаем его обновления
|
// Если случится что чанк был изменён и удалён, то исключаем его обновления
|
||||||
for(Pos::GlobalRegion removed : std::get<1>(pair.second)) {
|
for(Pos::GlobalRegion removed : std::get<1>(pair.second)) {
|
||||||
Pos::GlobalChunk pos = removed << 2;
|
Pos::GlobalChunk pos = Pos::GlobalChunk(removed) << 2;
|
||||||
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++) {
|
||||||
|
|||||||
@@ -255,14 +255,17 @@ void Vulkan::run()
|
|||||||
|
|
||||||
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
{
|
{
|
||||||
|
if(Game.RSession)
|
||||||
|
Game.RSession->pushStage(EnumRenderStage::WorldUpdate);
|
||||||
|
|
||||||
freeSwapchains();
|
freeSwapchains();
|
||||||
buildSwapchains();
|
buildSwapchains();
|
||||||
continue;
|
continue;
|
||||||
} else if (err == VK_SUBOPTIMAL_KHR)
|
// } else if (err == VK_SUBOPTIMAL_KHR)
|
||||||
{
|
// {
|
||||||
LOGGER.debug() << "VK_SUBOPTIMAL_KHR Pre";
|
// LOGGER.debug() << "VK_SUBOPTIMAL_KHR Pre";
|
||||||
continue;
|
// continue;
|
||||||
} else if(err == VK_SUCCESS) {
|
} else if(err == VK_SUBOPTIMAL_KHR || err == VK_SUCCESS) {
|
||||||
|
|
||||||
Screen.State = DrawState::Drawing;
|
Screen.State = DrawState::Drawing;
|
||||||
//Готовим инструкции рисовки
|
//Готовим инструкции рисовки
|
||||||
@@ -563,11 +566,9 @@ void Vulkan::run()
|
|||||||
vkAssert(!vkQueueSubmit(*lockQueue, 1, &submit_info, drawEndFence));
|
vkAssert(!vkQueueSubmit(*lockQueue, 1, &submit_info, drawEndFence));
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto now = std::chrono::high_resolution_clock::now();
|
|
||||||
// Насильно ожидаем завершения рендера кадра
|
// Насильно ожидаем завершения рендера кадра
|
||||||
vkWaitForFences(Graphics.Device, 1, &drawEndFence, true, -1);
|
vkWaitForFences(Graphics.Device, 1, &drawEndFence, true, -1);
|
||||||
vkResetFences(Graphics.Device, 1, &drawEndFence);
|
vkResetFences(Graphics.Device, 1, &drawEndFence);
|
||||||
// LOG.debug() << (std::chrono::high_resolution_clock::now()-now).count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -588,6 +589,12 @@ void Vulkan::run()
|
|||||||
err = vkQueuePresentKHR(*lockQueue, &present);
|
err = vkQueuePresentKHR(*lockQueue, &present);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto lockQueue = Graphics.DeviceQueueGraphic.lock();
|
||||||
|
vkDeviceWaitIdle(Graphics.Device);
|
||||||
|
lockQueue.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
{
|
{
|
||||||
freeSwapchains();
|
freeSwapchains();
|
||||||
@@ -1557,7 +1564,7 @@ void Vulkan::initNextSettings()
|
|||||||
"VK_LAYER_LUNARG_monitor"
|
"VK_LAYER_LUNARG_monitor"
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!SettingsNext.Debug)
|
if(!SettingsNext.Debug || getenv("no_vk_debug"))
|
||||||
knownDebugLayers.clear();
|
knownDebugLayers.clear();
|
||||||
|
|
||||||
std::vector<vkInstanceLayer> enableDebugLayers;
|
std::vector<vkInstanceLayer> enableDebugLayers;
|
||||||
@@ -2256,8 +2263,15 @@ void Vulkan::gui_ConnectedToServer() {
|
|||||||
if(Game.Session) {
|
if(Game.Session) {
|
||||||
if(ImGui::Begin("MainMenu", nullptr, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
|
if(ImGui::Begin("MainMenu", nullptr, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
|
||||||
{
|
{
|
||||||
std::string text = std::to_string(ImGui::GetIO().Framerate);
|
ImGui::Text("fps: %2.2f World: %u Pos: %i %i %i Region: %i %i %i",
|
||||||
ImGui::Text("%s", text.c_str());
|
ImGui::GetIO().Framerate, Game.RSession->WI,
|
||||||
|
(int) Game.RSession->PlayerPos.x, (int) Game.RSession->PlayerPos.y, (int) Game.RSession->PlayerPos.z,
|
||||||
|
(int) Game.RSession->PlayerPos.x >> 6, (int) Game.RSession->PlayerPos.y >> 6, (int) Game.RSession->PlayerPos.z >> 6
|
||||||
|
);
|
||||||
|
|
||||||
|
if(ImGui::Button("Delimeter"))
|
||||||
|
LOG.debug();
|
||||||
|
|
||||||
if(ImGui::Button("Выйти")) {
|
if(ImGui::Button("Выйти")) {
|
||||||
try {
|
try {
|
||||||
if(Game.Session)
|
if(Game.Session)
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ void VulkanRenderSession::ThreadVertexObj_t::run() {
|
|||||||
toRemove.push_back(worldId);
|
toRemove.push_back(worldId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(WorldId_t worldId : toRemove)
|
for(WorldId_t worldId : toRemove)
|
||||||
ChunkMesh.erase(ChunkMesh.find(worldId));
|
ChunkMesh.erase(ChunkMesh.find(worldId));
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ void VulkanRenderSession::ThreadVertexObj_t::run() {
|
|||||||
|
|
||||||
|
|
||||||
State.lock()->ChunkMesh_IsUse = false;
|
State.lock()->ChunkMesh_IsUse = false;
|
||||||
|
changedContent_RegionRemove.clear();
|
||||||
chunksUpdate.clear();
|
chunksUpdate.clear();
|
||||||
|
|
||||||
// LOG.debug() << "ChunkMesh_IsUse: " << Time::nowSystem() - now;
|
// LOG.debug() << "ChunkMesh_IsUse: " << Time::nowSystem() - now;
|
||||||
@@ -167,6 +169,7 @@ void VulkanRenderSession::ThreadVertexObj_t::run() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::vector<NodeVertexStatic> nodes = generateMeshForNodeChunks(chunk.Nodes.data());
|
std::vector<NodeVertexStatic> nodes = generateMeshForNodeChunks(chunk.Nodes.data());
|
||||||
|
|
||||||
if(!nodes.empty()) {
|
if(!nodes.empty()) {
|
||||||
drawChunk.NodePointer = VertexPool_Nodes.pushVertexs(std::move(nodes));
|
drawChunk.NodePointer = VertexPool_Nodes.pushVertexs(std::move(nodes));
|
||||||
hasVertexChanges = true;
|
hasVertexChanges = true;
|
||||||
@@ -1007,9 +1010,11 @@ void VulkanRenderSession::onChunksChange(WorldId_t worldId, const std::unordered
|
|||||||
std::unordered_map<WorldId_t, std::vector<Pos::GlobalChunk>> chunkChanges;
|
std::unordered_map<WorldId_t, std::vector<Pos::GlobalChunk>> chunkChanges;
|
||||||
if(!changeOrAddList.empty())
|
if(!changeOrAddList.empty())
|
||||||
chunkChanges[worldId] = std::vector<Pos::GlobalChunk>(changeOrAddList.begin(), changeOrAddList.end());
|
chunkChanges[worldId] = std::vector<Pos::GlobalChunk>(changeOrAddList.begin(), changeOrAddList.end());
|
||||||
|
|
||||||
std::unordered_map<WorldId_t, std::vector<Pos::GlobalRegion>> regionRemove;
|
std::unordered_map<WorldId_t, std::vector<Pos::GlobalRegion>> regionRemove;
|
||||||
if(!remove.empty())
|
if(!remove.empty())
|
||||||
regionRemove[worldId] = std::vector<Pos::GlobalRegion>(remove.begin(), remove.end());
|
regionRemove[worldId] = std::vector<Pos::GlobalRegion>(remove.begin(), remove.end());
|
||||||
|
|
||||||
VKCTX->ThreadVertexObj.onContentChunkChange(chunkChanges, regionRemove);
|
VKCTX->ThreadVertexObj.onContentChunkChange(chunkChanges, regionRemove);
|
||||||
|
|
||||||
// if(chunk.Voxels.empty()) {
|
// if(chunk.Voxels.empty()) {
|
||||||
@@ -1041,6 +1046,10 @@ void VulkanRenderSession::setCameraPos(WorldId_t worldId, Pos::Object pos, glm::
|
|||||||
WorldId = worldId;
|
WorldId = worldId;
|
||||||
Pos = pos;
|
Pos = pos;
|
||||||
Quat = quat;
|
Quat = quat;
|
||||||
|
|
||||||
|
WI = worldId;
|
||||||
|
PlayerPos = pos;
|
||||||
|
PlayerPos /= float(Pos::Object_t::BS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanRenderSession::beforeDraw() {
|
void VulkanRenderSession::beforeDraw() {
|
||||||
@@ -1209,7 +1218,15 @@ void VulkanRenderSession::drawWorld(GlobalTime gTime, float dTime, VkCommandBuff
|
|||||||
Pos::GlobalChunk x64offset = X64Offset >> Pos::Object_t::BS_Bit >> 4;
|
Pos::GlobalChunk x64offset = X64Offset >> Pos::Object_t::BS_Bit >> 4;
|
||||||
Pos::GlobalRegion x64offset_region = x64offset >> 2;
|
Pos::GlobalRegion x64offset_region = x64offset >> 2;
|
||||||
|
|
||||||
auto [voxelVertexs, nodeVertexs] = VKCTX->ThreadVertexObj.getChunksForRender(WorldId, Pos, 2, PCO.ProjView, x64offset_region);
|
auto [voxelVertexs, nodeVertexs] = VKCTX->ThreadVertexObj.getChunksForRender(WorldId, Pos, 4, PCO.ProjView, x64offset_region);
|
||||||
|
|
||||||
|
{
|
||||||
|
static uint32_t l = TOS::Time::getSeconds();
|
||||||
|
if(l != TOS::Time::getSeconds()) {
|
||||||
|
l = TOS::Time::getSeconds();
|
||||||
|
TOS::Logger("Test").debug() << nodeVertexs.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -364,6 +364,8 @@ class VulkanRenderSession : public IRenderSession, public IVulkanDependent {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
WorldPCO PCO;
|
WorldPCO PCO;
|
||||||
|
WorldId_t WI = 0;
|
||||||
|
glm::vec3 PlayerPos = glm::vec3(0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VulkanRenderSession();
|
VulkanRenderSession();
|
||||||
|
|||||||
Reference in New Issue
Block a user