diff --git a/Src/Client/Vulkan/VulkanRenderSession.cpp b/Src/Client/Vulkan/VulkanRenderSession.cpp index 07300ad..2f667c1 100644 --- a/Src/Client/Vulkan/VulkanRenderSession.cpp +++ b/Src/Client/Vulkan/VulkanRenderSession.cpp @@ -1205,7 +1205,7 @@ void VulkanRenderSession::drawWorld(GlobalTime gTime, float dTime, VkCommandBuff Pos::GlobalChunk x64offset = X64Offset >> Pos::Object_t::BS_Bit >> 4; 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, 1, PCO.ProjView, x64offset_region); glm::mat4 orig = PCO.Model; for(auto& [chunkPos, vertexs, vertexCount] : nodeVertexs) { diff --git a/Src/Server/GameServer.cpp b/Src/Server/GameServer.cpp index 06a6f8b..9914ac8 100644 --- a/Src/Server/GameServer.cpp +++ b/Src/Server/GameServer.cpp @@ -2355,31 +2355,31 @@ void GameServer::stepSyncContent() { remoteClient->onUpdate(); // Это для пробы строительства и ломания нод - // while(!cec->Build.empty()) { - // Pos::GlobalNode node = cec->Build.front(); - // cec->Build.pop(); + while(!remoteClient->Build.empty()) { + Pos::GlobalNode node = remoteClient->Build.front(); + remoteClient->Build.pop(); - // Pos::GlobalRegion rPos = node >> 6; - // Pos::bvec4u cPos = (node >> 4) & 0x3; - // Pos::bvec16u nPos = node & 0xf; + Pos::GlobalRegion rPos = node >> 6; + Pos::bvec4u cPos = (node >> 4) & 0x3; + Pos::bvec16u nPos = node & 0xf; - // auto ®ion = Expanse.Worlds[0]->Regions[rPos]; - // region->Nodes[cPos.pack()][nPos.pack()].NodeId = 4; - // region->IsChunkChanged_Nodes |= 1ull << cPos.pack(); - // } + auto ®ion = Expanse.Worlds[0]->Regions[rPos]; + region->Nodes[cPos.pack()][nPos.pack()].NodeId = 4; + region->IsChunkChanged_Nodes |= 1ull << cPos.pack(); + } - // while(!cec->Break.empty()) { - // Pos::GlobalNode node = cec->Break.front(); - // cec->Break.pop(); + while(!remoteClient->Break.empty()) { + Pos::GlobalNode node = remoteClient->Break.front(); + remoteClient->Break.pop(); - // Pos::GlobalRegion rPos = node >> 6; - // Pos::bvec4u cPos = (node >> 4) & 0x3; - // Pos::bvec16u nPos = node & 0xf; + Pos::GlobalRegion rPos = node >> 6; + Pos::bvec4u cPos = (node >> 4) & 0x3; + Pos::bvec16u nPos = node & 0xf; - // auto ®ion = Expanse.Worlds[0]->Regions[rPos]; - // region->Nodes[cPos.pack()][nPos.pack()].NodeId = 0; - // region->IsChunkChanged_Nodes |= 1ull << cPos.pack(); - // } + auto ®ion = Expanse.Worlds[0]->Regions[rPos]; + region->Nodes[cPos.pack()][nPos.pack()].NodeId = 0; + region->IsChunkChanged_Nodes |= 1ull << cPos.pack(); + } } diff --git a/Src/Server/RemoteClient.cpp b/Src/Server/RemoteClient.cpp index ae5da9d..3be9d40 100644 --- a/Src/Server/RemoteClient.cpp +++ b/Src/Server/RemoteClient.cpp @@ -764,7 +764,37 @@ void RemoteClient::NetworkAndResource_t::decrementAssets(ResUses_t::RefAssets_t& } void RemoteClient::onUpdate() { + Pos::Object pos = CameraPos; + Pos::GlobalRegion r1 = LastPos >> 12 >> 4 >> 2; + Pos::GlobalRegion r2 = pos >> 12 >> 4 >> 2; + if(r1 != r2) { + CrossedRegion = true; + } + + if(!Actions.get_read().empty()) { + auto lock = Actions.lock(); + while(!lock->empty()) { + uint8_t action = lock->front(); + lock->pop(); + + glm::quat q = CameraQuat.toQuat(); + glm::vec4 v = glm::mat4(q)*glm::vec4(0, 0, -6, 1); + Pos::GlobalNode pos = (Pos::GlobalNode) (glm::vec3) v; + pos += pos >> Pos::Object_t::BS_Bit; + + if(action == 0) { + // Break + Break.push(pos); + + } else if(action == 1) { + // Build + Build.push(pos); + } + } + } + + LastPos = pos; } std::vector> RemoteClient::getViewPoints() { diff --git a/Src/Server/RemoteClient.hpp b/Src/Server/RemoteClient.hpp index 2a0d3a5..72e1a77 100644 --- a/Src/Server/RemoteClient.hpp +++ b/Src/Server/RemoteClient.hpp @@ -320,6 +320,7 @@ class RemoteClient { public: const std::string Username; Pos::Object CameraPos = {0, 0, 0}; + Pos::Object LastPos = CameraPos; ToServer::PacketQuat CameraQuat = {0}; TOS::SpinlockObject> Actions; ResourceId RecievedAssets[(int) EnumAssets::MAX_ENUM] = {0}; @@ -328,6 +329,7 @@ public: ContentViewInfo ContentViewState; // Если игрок пересекал границы региона (для перерасчёта ContentViewState) bool CrossedRegion = true; + std::queue Build, Break; public: RemoteClient(asio::io_context &ioc, tcp::socket socket, const std::string username, std::vector &&client_cache) diff --git a/assets/shaders/chunk/node_opaque.frag b/assets/shaders/chunk/node_opaque.frag index f7c8c2a..4465ed4 100644 --- a/assets/shaders/chunk/node_opaque.frag +++ b/assets/shaders/chunk/node_opaque.frag @@ -87,4 +87,4 @@ void main() { // Frame = vec4(blendOverlay(vec3(Frame), vec3(Fragment.GeoPos/64.f)), Frame.w); if(Frame.w == 0) discard; -} \ No newline at end of file +}