*
This commit is contained in:
@@ -64,10 +64,9 @@ public:
|
||||
class IRenderSession {
|
||||
public:
|
||||
// Подгрузка двоичных ресурсов
|
||||
virtual void onBinaryResourceAdd(std::unordered_map<EnumBinResource, std::unordered_map<ResourceId_t, BinaryResource>>) = 0;
|
||||
virtual void onBinaryResourceLost(std::unordered_map<EnumBinResource, std::vector<ResourceId_t>>) = 0;
|
||||
virtual void onBinaryResourceAdd(std::vector<Hash_t>) = 0;
|
||||
|
||||
virtual void onContentDefinesAdd(std::unordered_map<EnumDefContent, std::unordered_map<ResourceId_t, std::u8string>>) = 0;
|
||||
virtual void onContentDefinesAdd(std::unordered_map<EnumDefContent, std::vector<ResourceId_t>>) = 0;
|
||||
virtual void onContentDefinesLost(std::unordered_map<EnumDefContent, std::vector<ResourceId_t>>) = 0;
|
||||
|
||||
// Сообщаем об изменившихся чанках
|
||||
@@ -90,10 +89,6 @@ struct DefVoxelInfo {
|
||||
|
||||
};
|
||||
|
||||
struct DefNodeInfo {
|
||||
|
||||
};
|
||||
|
||||
struct DefWorldInfo {
|
||||
|
||||
};
|
||||
@@ -142,10 +137,24 @@ struct DefItemInfo {
|
||||
|
||||
/* Интерфейс обработчика сессии с сервером */
|
||||
class IServerSession {
|
||||
struct ArrayHasher {
|
||||
std::size_t operator()(const Hash_t& a) const {
|
||||
std::size_t h = 0;
|
||||
for (auto e : a)
|
||||
h ^= std::hash<int>{}(e) + 0x9e3779b9 + (h << 6) + (h >> 2);
|
||||
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
struct {
|
||||
std::unordered_map<Hash_t, BinaryResource, ArrayHasher> Resources;
|
||||
} Binary;
|
||||
|
||||
struct {
|
||||
std::unordered_map<DefVoxelId_t, DefVoxelInfo> DefVoxel;
|
||||
std::unordered_map<DefNodeId_t, DefNodeInfo> DefNode;
|
||||
std::unordered_map<DefNodeId_t, DefNode_t> DefNode;
|
||||
std::unordered_map<DefWorldId_t, DefWorldInfo> DefWorld;
|
||||
std::unordered_map<DefPortalId_t, DefPortalInfo> DefPortal;
|
||||
std::unordered_map<DefEntityId_t, DefEntityInfo> DefEntity;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Common/Abstract.hpp"
|
||||
#include "Common/Net.hpp"
|
||||
#include "TOSLib.hpp"
|
||||
#include "glm/ext/quaternion_geometric.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/this_coro.hpp>
|
||||
@@ -24,8 +25,8 @@ struct PP_Content_ChunkVoxels : public ParsedPacket {
|
||||
Pos::GlobalChunk Pos;
|
||||
std::vector<VoxelCube> Cubes;
|
||||
|
||||
PP_Content_ChunkVoxels(ToClient::L1 l1, uint8_t l2, WorldId_t id, Pos::GlobalChunk pos, std::vector<VoxelCube> &&cubes)
|
||||
: ParsedPacket(l1, l2), Id(id), Pos(pos), Cubes(std::move(cubes))
|
||||
PP_Content_ChunkVoxels(WorldId_t id, Pos::GlobalChunk pos, std::vector<VoxelCube> &&cubes)
|
||||
: ParsedPacket(ToClient::L1::Content, (uint8_t) ToClient::L2Content::ChunkVoxels), Id(id), Pos(pos), Cubes(std::move(cubes))
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -34,8 +35,8 @@ struct PP_Content_ChunkNodes : public ParsedPacket {
|
||||
Pos::GlobalChunk Pos;
|
||||
std::array<Node, 16*16*16> Nodes;
|
||||
|
||||
PP_Content_ChunkNodes(ToClient::L1 l1, uint8_t l2, WorldId_t id, Pos::GlobalChunk pos)
|
||||
: ParsedPacket(l1, l2), Id(id), Pos(pos)
|
||||
PP_Content_ChunkNodes(WorldId_t id, Pos::GlobalChunk pos)
|
||||
: ParsedPacket(ToClient::L1::Content, (uint8_t) ToClient::L2Content::ChunkNodes), Id(id), Pos(pos)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -44,8 +45,36 @@ struct PP_Content_RegionRemove : public ParsedPacket {
|
||||
WorldId_t Id;
|
||||
Pos::GlobalRegion Pos;
|
||||
|
||||
PP_Content_RegionRemove(ToClient::L1 l1, uint8_t l2, WorldId_t id, Pos::GlobalRegion pos)
|
||||
: ParsedPacket(l1, l2), Id(id), Pos(pos)
|
||||
PP_Content_RegionRemove(WorldId_t id, Pos::GlobalRegion pos)
|
||||
: ParsedPacket(ToClient::L1::Content, (uint8_t) ToClient::L2Content::RemoveRegion), Id(id), Pos(pos)
|
||||
{}
|
||||
};
|
||||
|
||||
struct PP_Definition_FreeNode : public ParsedPacket {
|
||||
DefNodeId_t Id;
|
||||
|
||||
PP_Definition_FreeNode(DefNodeId_t id)
|
||||
: ParsedPacket(ToClient::L1::Definition, (uint8_t) ToClient::L2Definition::Node),
|
||||
Id(id)
|
||||
{}
|
||||
};
|
||||
|
||||
struct PP_Definition_Node : public ParsedPacket {
|
||||
DefNodeId_t Id;
|
||||
DefNode_t Def;
|
||||
|
||||
PP_Definition_Node(DefNodeId_t id, DefNode_t def)
|
||||
: ParsedPacket(ToClient::L1::Definition, (uint8_t) ToClient::L2Definition::Node),
|
||||
Id(id), Def(def)
|
||||
{}
|
||||
};
|
||||
|
||||
struct PP_Resource_InitResSend : public ParsedPacket {
|
||||
Hash_t Hash;
|
||||
BinaryResource Resource;
|
||||
|
||||
PP_Resource_InitResSend(Hash_t hash, BinaryResource res)
|
||||
: ParsedPacket(ToClient::L1::Resource, (uint8_t) ToClient::L2Resource::InitResSend), Hash(hash), Resource(res)
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -283,11 +312,32 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
|
||||
|
||||
{
|
||||
std::unordered_map<WorldId_t, std::tuple<std::unordered_set<Pos::GlobalChunk>, std::unordered_set<Pos::GlobalRegion>>> changeOrAddList_removeList;
|
||||
std::unordered_map<EnumDefContent, std::vector<ResourceId_t>> onContentDefinesAdd;
|
||||
std::unordered_map<EnumDefContent, std::vector<ResourceId_t>> onContentDefinesLost;
|
||||
|
||||
// Пакеты
|
||||
ParsedPacket *pack;
|
||||
while(NetInputPackets.pop(pack)) {
|
||||
if(pack->Level1 == ToClient::L1::Content) {
|
||||
if(pack->Level1 == ToClient::L1::Definition) {
|
||||
ToClient::L2Resource l2 = ToClient::L2Resource(pack->Level2);
|
||||
if(l2 == ToClient::L2Resource::InitResSend) {
|
||||
PP_Resource_InitResSend &p = *dynamic_cast<PP_Resource_InitResSend*>(pack);
|
||||
|
||||
}
|
||||
|
||||
} else if(pack->Level1 == ToClient::L1::Definition) {
|
||||
ToClient::L2Definition l2 = ToClient::L2Definition(pack->Level2);
|
||||
if(l2 == ToClient::L2Definition::Node) {
|
||||
PP_Definition_Node &p = *dynamic_cast<PP_Definition_Node*>(pack);
|
||||
Registry.DefNode[p.Id] = p.Def;
|
||||
onContentDefinesAdd[EnumDefContent::Node].push_back(p.Id);
|
||||
} else if(l2 == ToClient::L2Definition::FreeNode) {
|
||||
PP_Definition_FreeNode &p = *dynamic_cast<PP_Definition_FreeNode*>(pack);
|
||||
onContentDefinesLost[EnumDefContent::Node].push_back(p.Id);
|
||||
}
|
||||
|
||||
|
||||
} else if(pack->Level1 == ToClient::L1::Content) {
|
||||
ToClient::L2Content l2 = ToClient::L2Content(pack->Level2);
|
||||
if(l2 == ToClient::L2Content::ChunkVoxels) {
|
||||
PP_Content_ChunkVoxels &p = *dynamic_cast<PP_Content_ChunkVoxels*>(pack);
|
||||
@@ -339,6 +389,14 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
|
||||
|
||||
RS->onChunksChange(pair.first, std::get<0>(pair.second), std::get<1>(pair.second));
|
||||
}
|
||||
|
||||
if(!onContentDefinesAdd.empty()) {
|
||||
RS->onContentDefinesAdd(std::move(onContentDefinesAdd));
|
||||
}
|
||||
|
||||
if(!onContentDefinesLost.empty()) {
|
||||
RS->onContentDefinesLost(std::move(onContentDefinesLost));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +406,10 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
|
||||
|
||||
glm::quat quat =
|
||||
glm::angleAxis(PYR.x-deltaTime*PYR_Offset.x, glm::vec3(1.f, 0.f, 0.f))
|
||||
* glm::angleAxis(PYR.y-deltaTime*PYR_Offset.y, glm::vec3(0.f, -1.f, 0.f));
|
||||
*
|
||||
glm::angleAxis(PYR.y-deltaTime*PYR_Offset.y, glm::vec3(0.f, -1.f, 0.f));
|
||||
|
||||
quat = glm::normalize(quat);
|
||||
|
||||
if(RS)
|
||||
RS->setCameraPos(0, Pos, quat);
|
||||
@@ -360,7 +421,7 @@ void ServerSession::atFreeDrawTime(GlobalTime gTime, float dTime) {
|
||||
LastSendPYR_POS = gTime;
|
||||
Net::Packet packet;
|
||||
ToServer::PacketQuat q;
|
||||
q.fromQuat(quat);
|
||||
q.fromQuat(glm::inverse(quat));
|
||||
|
||||
packet << (uint8_t) ToServer::L1::System
|
||||
<< (uint8_t) ToServer::L2System::Test_CAM_PYR_POS
|
||||
@@ -452,7 +513,7 @@ coro<> ServerSession::rP_Resource(Net::AsyncSocket &sock) {
|
||||
|
||||
switch((ToClient::L2Resource) second) {
|
||||
case ToClient::L2Resource::Texture:
|
||||
|
||||
|
||||
co_return;
|
||||
case ToClient::L2Resource::FreeTexture:
|
||||
|
||||
@@ -470,13 +531,27 @@ coro<> ServerSession::rP_Resource(Net::AsyncSocket &sock) {
|
||||
|
||||
co_return;
|
||||
case ToClient::L2Resource::InitResSend:
|
||||
{
|
||||
uint32_t size = co_await sock.read<uint32_t>();
|
||||
Hash_t hash;
|
||||
co_await sock.read((std::byte*) hash.data(), hash.size());
|
||||
|
||||
uint32_t chunkSize = co_await sock.read<uint32_t>();
|
||||
std::u8string data(size, '\0');
|
||||
|
||||
co_await sock.read((std::byte*) data.data(), data.size());
|
||||
|
||||
PP_Resource_InitResSend *packet = new PP_Resource_InitResSend(
|
||||
hash,
|
||||
std::make_shared<std::u8string>(std::move(data))
|
||||
);
|
||||
|
||||
while(!NetInputPackets.push(packet));
|
||||
|
||||
co_return;
|
||||
}
|
||||
case ToClient::L2Resource::ChunkSend:
|
||||
|
||||
co_return;
|
||||
case ToClient::L2Resource::SendCanceled:
|
||||
|
||||
co_return;
|
||||
default:
|
||||
protocolError();
|
||||
@@ -508,11 +583,38 @@ coro<> ServerSession::rP_Definition(Net::AsyncSocket &sock) {
|
||||
co_return;
|
||||
}
|
||||
case ToClient::L2Definition::Node:
|
||||
{
|
||||
DefNodeId_t id;
|
||||
DefNode_t def;
|
||||
id = co_await sock.read<DefNodeId_t>();
|
||||
def.DrawType = (DefNode_t::EnumDrawType) co_await sock.read<uint8_t>();
|
||||
for(int iter = 0; iter < 6; iter++) {
|
||||
auto &pl = def.Texs[iter].Pipeline;
|
||||
pl.resize(co_await sock.read<uint16_t>());
|
||||
co_await sock.read((std::byte*) pl.data(), pl.size());
|
||||
}
|
||||
|
||||
PP_Definition_Node *packet = new PP_Definition_Node(
|
||||
id,
|
||||
def
|
||||
);
|
||||
|
||||
while(!NetInputPackets.push(packet));
|
||||
|
||||
co_return;
|
||||
}
|
||||
case ToClient::L2Definition::FreeNode:
|
||||
{
|
||||
DefNodeId_t id = co_await sock.read<DefNodeId_t>();
|
||||
|
||||
PP_Definition_FreeNode *packet = new PP_Definition_FreeNode(
|
||||
id
|
||||
);
|
||||
|
||||
while(!NetInputPackets.push(packet));
|
||||
|
||||
co_return;
|
||||
}
|
||||
case ToClient::L2Definition::Portal:
|
||||
|
||||
co_return;
|
||||
@@ -564,8 +666,6 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
|
||||
co_await sock.read((std::byte*) compressed.data(), compressedSize);
|
||||
|
||||
PP_Content_ChunkVoxels *packet = new PP_Content_ChunkVoxels(
|
||||
ToClient::L1::Content,
|
||||
(uint8_t) ToClient::L2Content::ChunkVoxels,
|
||||
wcId,
|
||||
pos,
|
||||
unCompressVoxels(compressed) // TODO: вынести в отдельный поток
|
||||
@@ -588,8 +688,6 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
|
||||
co_await sock.read((std::byte*) compressed.data(), compressedSize);
|
||||
|
||||
PP_Content_ChunkNodes *packet = new PP_Content_ChunkNodes(
|
||||
ToClient::L1::Content,
|
||||
(uint8_t) ToClient::L2Content::ChunkNodes,
|
||||
wcId,
|
||||
pos
|
||||
);
|
||||
@@ -609,8 +707,6 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
|
||||
pos.unpack(co_await sock.read<Pos::GlobalRegion::Pack>());
|
||||
|
||||
PP_Content_RegionRemove *packet = new PP_Content_RegionRemove(
|
||||
ToClient::L1::Content,
|
||||
(uint8_t) ToClient::L2Content::RemoveRegion,
|
||||
wcId,
|
||||
pos
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ struct VoxelVertexPoint {
|
||||
|
||||
struct NodeVertexStatic {
|
||||
uint32_t
|
||||
FX : 9, FY : 9, FZ : 9, // Позиция 15 -120 ~ 240 360 15 / 16
|
||||
FX : 9, FY : 9, FZ : 9, // Позиция -15 -120 ~ 240 360 +15 / 16
|
||||
N1 : 4, // Не занято
|
||||
LS : 1, // Масштаб карты освещения (1м/16 или 1м)
|
||||
Tex : 18, // Текстура
|
||||
|
||||
@@ -304,9 +304,9 @@ public:
|
||||
WritePos = 0;
|
||||
|
||||
while(!postponed.empty()) {
|
||||
Task& task = TasksWait.front();
|
||||
Task& task = postponed.front();
|
||||
pushData(std::move(task.Data), task.PoolId, task.BlockId);
|
||||
TasksWait.pop();
|
||||
postponed.pop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2695,7 +2695,7 @@ Buffer& Buffer::operator=(Buffer &&obj) {
|
||||
std::swap(Memory, obj.Memory);
|
||||
std::swap(Size, obj.Size);
|
||||
obj.Instance = nullptr;
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#include "VulkanRenderSession.hpp"
|
||||
#include "Client/Abstract.hpp"
|
||||
#include "Client/Vulkan/Abstract.hpp"
|
||||
#include "Client/Vulkan/Vulkan.hpp"
|
||||
#include "Common/Abstract.hpp"
|
||||
#include "TOSLib.hpp"
|
||||
#include "assets.hpp"
|
||||
#include "glm/ext/matrix_transform.hpp"
|
||||
#include "glm/ext/scalar_constants.hpp"
|
||||
#include "glm/matrix.hpp"
|
||||
#include "glm/trigonometric.hpp"
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
@@ -211,7 +213,8 @@ void VulkanRenderSession::init(Vulkan *instance) {
|
||||
"willow_wood.png",
|
||||
"tropical_rainforest_wood.png",
|
||||
"xnether_blue_wood.png",
|
||||
"xnether_purple_wood.png"
|
||||
"xnether_purple_wood.png",
|
||||
"frame.png"
|
||||
}) {
|
||||
ByteBuffer image = VK::loadPNG(getResource(std::string("textures/") + path)->makeStream().Stream, width, height, hasAlpha);
|
||||
uint16_t texId = VKCTX->MainTest.atlasAddTexture(width, height);
|
||||
@@ -229,35 +232,66 @@ void VulkanRenderSession::init(Vulkan *instance) {
|
||||
|
||||
{
|
||||
NodeVertexStatic *array = (NodeVertexStatic*) VKCTX->TestQuad.mapMemory();
|
||||
array[0] = {135, 135, 135-64, 0, 0, 0, 0, 0, 0};
|
||||
array[1] = {135+16, 135, 135-64, 0, 0, 0, 0, 65535, 0};
|
||||
array[2] = {135+16, 135+16, 135-64, 0, 0, 0, 0, 65535, 65535};
|
||||
array[3] = {135, 135, 135-64, 0, 0, 0, 0, 0, 0};
|
||||
array[4] = {135+16, 135+16, 135-64, 0, 0, 0, 0, 65535, 65535};
|
||||
array[5] = {135, 135+16, 135-64, 0, 0, 0, 0, 0, 65535};
|
||||
array[0] = {135, 135, 135, 0, 0, 0, 0, 65535, 0};
|
||||
array[1] = {135, 135+16, 135, 0, 0, 0, 0, 0, 65535};
|
||||
array[2] = {135+16, 135+16, 135, 0, 0, 0, 0, 0, 65535};
|
||||
array[3] = {135, 135, 135, 0, 0, 0, 0, 65535, 0};
|
||||
array[4] = {135+16, 135+16, 135, 0, 0, 0, 0, 0, 65535};
|
||||
array[5] = {135+16, 135, 135, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
array[6] = {135, 135, 135+16, 0, 0, 0, 0, 0, 0};
|
||||
array[7] = {135+16, 135, 135+16, 0, 0, 0, 0, 65535, 0};
|
||||
array[8] = {135+16, 135+16, 135+16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[9] = {135, 135, 135+16, 0, 0, 0, 0, 0, 0};
|
||||
array[10] = {135+16, 135+16, 135+16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[11] = {135, 135+16, 135+16, 0, 0, 0, 0, 0, 65535};
|
||||
|
||||
array[6] = {135, 135, 135-64-16, 0, 0, 0, 0, 0, 0};
|
||||
array[7] = {135, 135, 135-64, 0, 0, 0, 0, 65535, 0};
|
||||
array[8] = {135, 135+16, 135-64, 0, 0, 0, 0, 65535, 65535};
|
||||
array[9] = {135, 135, 135-64-16, 0, 0, 0, 0, 0, 0};
|
||||
array[10] = {135, 135+16, 135-64, 0, 0, 0, 0, 65535, 65535};
|
||||
array[11] = {135, 135+16, 135-64-16, 0, 0, 0, 0, 0, 65535};
|
||||
array[12] = {135, 135, 135, 0, 0, 0, 0, 0, 0};
|
||||
array[13] = {135, 135, 135+16, 0, 0, 0, 0, 65535, 0};
|
||||
array[14] = {135, 135+16, 135+16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[15] = {135, 135, 135, 0, 0, 0, 0, 0, 0};
|
||||
array[16] = {135, 135+16, 135+16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[17] = {135, 135+16, 135, 0, 0, 0, 0, 0, 65535};
|
||||
|
||||
array[18] = {135+16, 135, 135+16, 0, 0, 0, 0, 0, 0};
|
||||
array[19] = {135+16, 135, 135, 0, 0, 0, 0, 65535, 0};
|
||||
array[20] = {135+16, 135+16, 135, 0, 0, 0, 0, 65535, 65535};
|
||||
array[21] = {135+16, 135, 135+16, 0, 0, 0, 0, 0, 0};
|
||||
array[22] = {135+16, 135+16, 135, 0, 0, 0, 0, 65535, 65535};
|
||||
array[23] = {135+16, 135+16, 135+16, 0, 0, 0, 0, 0, 65535};
|
||||
|
||||
array[12] = {135, 135, 135-64, 0, 0, 0, 0, 0, 0};
|
||||
array[13] = {135+16, 135, 135-64, 0, 0, 0, 0, 65535, 0};
|
||||
array[14] = {135+16, 135, 135-64-16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[15] = {135, 135, 135-64, 0, 0, 0, 0, 0, 0};
|
||||
array[16] = {135+16, 135, 135-64-16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[17] = {135, 135, 135-64-16, 0, 0, 0, 0, 0, 65535};
|
||||
array[24] = {135, 135, 135, 0, 0, 0, 0, 0, 0};
|
||||
array[25] = {135+16, 135, 135, 0, 0, 0, 0, 65535, 0};
|
||||
array[26] = {135+16, 135, 135+16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[27] = {135, 135, 135, 0, 0, 0, 0, 0, 0};
|
||||
array[28] = {135+16, 135, 135+16, 0, 0, 0, 0, 65535, 65535};
|
||||
array[29] = {135, 135, 135+16, 0, 0, 0, 0, 0, 65535};
|
||||
|
||||
for(int iter = 0; iter < 18; iter++) {
|
||||
array[18+iter] = array[iter];
|
||||
array[18+iter].FZ -= 32;
|
||||
array[30] = {135, 135+16, 135+16, 0, 0, 0, 0, 0, 0};
|
||||
array[31] = {135+16, 135+16, 135+16, 0, 0, 0, 0, 65535, 0};
|
||||
array[32] = {135+16, 135+16, 135, 0, 0, 0, 0, 65535, 65535};
|
||||
array[33] = {135, 135+16, 135+16, 0, 0, 0, 0, 0, 0};
|
||||
array[34] = {135+16, 135+16, 135, 0, 0, 0, 0, 65535, 65535};
|
||||
array[35] = {135, 135+16, 135, 0, 0, 0, 0, 0, 65535};
|
||||
|
||||
for(int iter = 0; iter < 36; iter++) {
|
||||
array[iter].Tex = 6;
|
||||
if(array[iter].FX == 135)
|
||||
array[iter].FX--;
|
||||
else
|
||||
array[iter].FX++;
|
||||
|
||||
if(array[iter].FY == 135)
|
||||
array[iter].FY--;
|
||||
else
|
||||
array[iter].FY++;
|
||||
|
||||
if(array[iter].FZ == 135)
|
||||
array[iter].FZ--;
|
||||
else
|
||||
array[iter].FZ++;
|
||||
}
|
||||
|
||||
|
||||
VKCTX->TestQuad.unMapMemory();
|
||||
}
|
||||
|
||||
@@ -627,15 +661,11 @@ void VulkanRenderSession::init(Vulkan *instance) {
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanRenderSession::onBinaryResourceAdd(std::unordered_map<EnumBinResource, std::unordered_map<ResourceId_t, BinaryResource>>) {
|
||||
void VulkanRenderSession::onBinaryResourceAdd(std::vector<Hash_t>) {
|
||||
|
||||
}
|
||||
|
||||
void VulkanRenderSession::onBinaryResourceLost(std::unordered_map<EnumBinResource, std::vector<ResourceId_t>>) {
|
||||
|
||||
}
|
||||
|
||||
void VulkanRenderSession::onContentDefinesAdd(std::unordered_map<EnumDefContent, std::unordered_map<ResourceId_t, std::u8string>>) {
|
||||
void VulkanRenderSession::onContentDefinesAdd(std::unordered_map<EnumDefContent, std::vector<ResourceId_t>>) {
|
||||
|
||||
}
|
||||
|
||||
@@ -643,7 +673,6 @@ void VulkanRenderSession::onContentDefinesLost(std::unordered_map<EnumDefContent
|
||||
|
||||
}
|
||||
|
||||
int changed = 0;
|
||||
void VulkanRenderSession::onChunksChange(WorldId_t worldId, const std::unordered_set<Pos::GlobalChunk>& changeOrAddList, const std::unordered_set<Pos::GlobalRegion>& remove) {
|
||||
auto &table = External.ChunkVoxelMesh[worldId];
|
||||
|
||||
@@ -668,7 +697,6 @@ void VulkanRenderSession::onChunksChange(WorldId_t worldId, const std::unordered
|
||||
if(vertexs2.empty()) {
|
||||
VKCTX->VertexPool_Nodes.dropVertexs(std::get<1>(buffers));
|
||||
} else {
|
||||
changed++;
|
||||
auto &nodes = std::get<1>(buffers);
|
||||
VKCTX->VertexPool_Nodes.relocate(nodes, std::move(vertexs2));
|
||||
}
|
||||
@@ -678,8 +706,6 @@ void VulkanRenderSession::onChunksChange(WorldId_t worldId, const std::unordered
|
||||
if(iter != table.end())
|
||||
table.erase(iter);
|
||||
}
|
||||
|
||||
TOS::Logger("Vul").debug() << "Обработано " << changed;
|
||||
}
|
||||
|
||||
for(Pos::GlobalRegion pos : remove) {
|
||||
@@ -717,7 +743,7 @@ void VulkanRenderSession::beforeDraw() {
|
||||
void VulkanRenderSession::drawWorld(GlobalTime gTime, float dTime, VkCommandBuffer drawCmd) {
|
||||
{
|
||||
X64Offset = Pos & ~((1 << Pos::Object_t::BS_Bit << 4 << 2)-1);
|
||||
X64Offset_f = glm::vec3(X64Offset) / float(Pos::Object_t::BS);
|
||||
X64Offset_f = glm::vec3(X64Offset >> Pos::Object_t::BS_Bit);
|
||||
X64Delta = glm::vec3(Pos-X64Offset) / float(Pos::Object_t::BS);
|
||||
}
|
||||
|
||||
@@ -817,7 +843,21 @@ void VulkanRenderSession::drawWorld(GlobalTime gTime, float dTime, VkCommandBuff
|
||||
Delta += dTime;
|
||||
|
||||
PCO.Model = glm::mat4(1);
|
||||
PCO.Model = glm::translate(PCO.Model, -X64Offset_f);
|
||||
//PCO.Model = glm::translate(PCO.Model, -X64Offset_f);
|
||||
// glm::quat quat = glm::inverse(Quat);
|
||||
|
||||
{
|
||||
|
||||
// auto *srv = (class ServerSession*) ServerSession;
|
||||
|
||||
glm::vec4 v = glm::mat4(glm::inverse(Quat))*glm::vec4(0, 0, -6, 1);
|
||||
|
||||
Pos::GlobalNode pos = (Pos::GlobalNode) (glm::vec3) v;
|
||||
|
||||
pos += (Pos-X64Offset) >> Pos::Object_t::BS_Bit;
|
||||
PCO.Model = glm::translate(PCO.Model, glm::vec3(pos));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
glm::mat4 proj = glm::perspective<float>(glm::radians(75.f), float(VkInst->Screen.Width)/float(VkInst->Screen.Height), 0.5, std::pow(2, 17));
|
||||
@@ -832,7 +872,7 @@ void VulkanRenderSession::drawWorld(GlobalTime gTime, float dTime, VkCommandBuff
|
||||
// Смещаем мир относительно позиции игрока, чтобы игрок в пространстве рендера оказался в нулевых координатах
|
||||
view = glm::translate(view, -X64Delta);
|
||||
// Поворачиваем мир обратно взгляду игрока, чтобы его взгляд стал по направлению оси -z
|
||||
view = glm::mat4(-Quat)*view;
|
||||
view = glm::mat4(Quat)*view;
|
||||
|
||||
// Сначала применяется матрица вида, потом проекции
|
||||
PCO.ProjView = proj*view;
|
||||
|
||||
@@ -141,9 +141,8 @@ public:
|
||||
assert(serverSession);
|
||||
}
|
||||
|
||||
virtual void onBinaryResourceAdd(std::unordered_map<EnumBinResource, std::unordered_map<ResourceId_t, BinaryResource>>) override;
|
||||
virtual void onBinaryResourceLost(std::unordered_map<EnumBinResource, std::vector<ResourceId_t>>) override;
|
||||
virtual void onContentDefinesAdd(std::unordered_map<EnumDefContent, std::unordered_map<ResourceId_t, std::u8string>>) override;
|
||||
virtual void onBinaryResourceAdd(std::vector<Hash_t>) override;
|
||||
virtual void onContentDefinesAdd(std::unordered_map<EnumDefContent, std::vector<ResourceId_t>>) override;
|
||||
virtual void onContentDefinesLost(std::unordered_map<EnumDefContent, std::vector<ResourceId_t>>) override;
|
||||
virtual void onChunksChange(WorldId_t worldId, const std::unordered_set<Pos::GlobalChunk>& changeOrAddList, const std::unordered_set<Pos::GlobalRegion>& remove) override;
|
||||
virtual void setCameraPos(WorldId_t worldId, Pos::Object pos, glm::quat quat) override;
|
||||
|
||||
Reference in New Issue
Block a user