diff --git a/engine/modules/engine/asset/impl/resource_system_impl.inl b/engine/modules/engine/asset/impl/resource_system_impl.inl index 84b100f..3084638 100644 --- a/engine/modules/engine/asset/impl/resource_system_impl.inl +++ b/engine/modules/engine/asset/impl/resource_system_impl.inl @@ -169,8 +169,6 @@ namespace api { mFileFlags = *res; } } - SetFileFlag(".hello", 1); - SaveFileFlags(); } void ResourceSystemImpl::SaveFileFlags() { diff --git a/engine/modules/engine/asset/include/asset/res/guid.h b/engine/modules/engine/asset/include/asset/res/guid.h index 0c1a31f..d126e2d 100644 --- a/engine/modules/engine/asset/include/asset/res/guid.h +++ b/engine/modules/engine/asset/include/asset/res/guid.h @@ -22,10 +22,13 @@ namespace api USING_OVERLOAD_CTOR(Guid, string_view) UFUNCTION({}, ref = USING_CTOR_NAME) - Guid(string_view str) noexcept + Guid(string_view str) noexcept : Guid{str.data()} {} + USING_OVERLOAD_CTOR(Guid, const char*) + UFUNCTION({}, ref = USING_CTOR_NAME) + Guid(const char* str) noexcept : Guid{} { - sscanf_s(str.data(), + sscanf_s(str, "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", &Data1, &Data2, &Data3, &Data4[0], &Data4[1], &Data4[2], &Data4[3], diff --git a/engine/modules/engine/core/include/archive/json.h b/engine/modules/engine/core/include/archive/json.h index 8aaf0de..291fc05 100644 --- a/engine/modules/engine/core/include/archive/json.h +++ b/engine/modules/engine/core/include/archive/json.h @@ -2,6 +2,17 @@ #include "meta/result.h" #include "json/serialize.inl" #include "json/serde.inl" +namespace gen { + template<> + inline bool JsonRead(yyjson_val* node, const refl::Any& t) { + if (!node) return false; + return api::JsonArchive::Deserialize(node, t); + } + template<> + inline yyjson_mut_val* JsonWrite(yyjson_mut_doc* doc, const refl::Any& t) { + return api::JsonArchive::Serialize(doc, t); + } +} namespace api { using meta::result; using std::string_view; diff --git a/engine/modules/engine/core/include/archive/json/serde.h b/engine/modules/engine/core/include/archive/json/serde.h index 6a9eafc..9602ed9 100644 --- a/engine/modules/engine/core/include/archive/json/serde.h +++ b/engine/modules/engine/core/include/archive/json/serde.h @@ -49,7 +49,12 @@ namespace gen { return yyjson_mut_real(doc, *(T*)(ptr)); } else if constexpr (is_string_v) { - return yyjson_mut_str(doc, ((T*)ptr)->data()); + if constexpr (requires(T * t) { t->data(); }) { + return yyjson_mut_str(doc, ((T*)ptr)->data()); + } + else { + return yyjson_mut_str(doc, std::string(*(T*)ptr).data()); + } } else { //static_assert(false, "unknown json write type"); diff --git a/engine/modules/engine/core/include/archive/json/serde.inl b/engine/modules/engine/core/include/archive/json/serde.inl index f901fed..26780e9 100644 --- a/engine/modules/engine/core/include/archive/json/serde.inl +++ b/engine/modules/engine/core/include/archive/json/serde.inl @@ -33,43 +33,40 @@ namespace gen { using value_type_t = typename T::value_type; T& docker = *(T*)ptr; size_t length = yyjson_arr_size(val); - char data[sizeof(value_type_t)]; + value_type_t it;//构造失败怎么办? for (size_t i = 0; i < length; ++i) { yyjson_val* obj_i = yyjson_arr_get(val, i); if constexpr (refl::is_map_v) { using key_type = refl::detail::is_pair::key_type; using value_type = refl::detail::is_pair::value_type; - key_type& key = *(key_type*)data; - value_type& value = *(value_type*)(data + sizeof(key_type)); - JsonRead(yyjson_obj_get(obj_i, "#k"), key); - JsonRead(yyjson_obj_get(obj_i, "#v"), value); - docker[key] = value; + JsonRead(yyjson_obj_get(obj_i, "#k"), it.first); + JsonRead(yyjson_obj_get(obj_i, "#v"), it.second); + docker[it.first] = it.second; } else { - value_type_t& obj = (value_type_t*)data; - JsonRead(obj_i, obj); - docker.push_back(obj); + JsonRead(obj_i, it); + docker.push_back(it); } } return true; } inline static yyjson_mut_val* Write(yyjson_mut_doc* doc, const void* ptr) { T& docker = *(T*)ptr; + yyjson_mut_val* arr = yyjson_mut_arr(doc); if constexpr (refl::is_map_v) { - yyjson_mut_val* obj = yyjson_mut_obj(doc); for (auto& it : docker) { + yyjson_mut_val* obj = yyjson_mut_obj(doc); yyjson_mut_obj_add_val(doc, obj, "#k", JsonWrite(doc, it.first)); yyjson_mut_obj_add_val(doc, obj, "#v", JsonWrite(doc, it.second)); + yyjson_mut_arr_add_val(arr, obj); } - return obj; } else { - yyjson_mut_val* arr = yyjson_mut_arr(doc); for (auto& it : docker) { - yyjson_mut_arr_add_val(doc, JsonWrite(doc, it)); + yyjson_mut_arr_add_val(arr, JsonWrite(doc, it)); } - return arr; } + return arr; } }; } diff --git a/engine/modules/engine/render/include/render/asset/vertex.h b/engine/modules/engine/render/include/render/asset/vertex.h index 00d4299..6b2193f 100644 --- a/engine/modules/engine/render/include/render/asset/vertex.h +++ b/engine/modules/engine/render/include/render/asset/vertex.h @@ -44,4 +44,5 @@ namespace api { UPROPERTY_vk() uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {}; }; -}; \ No newline at end of file +}; +#include ".render/vertex_gen.inl" \ No newline at end of file diff --git a/engine/modules/engine/render/xmake.lua b/engine/modules/engine/render/xmake.lua index 6c9ffaa..77fa9b8 100644 --- a/engine/modules/engine/render/xmake.lua +++ b/engine/modules/engine/render/xmake.lua @@ -1,4 +1,7 @@ static_component("render","engine") + add_rules("c++.codegen",{ + files = {"include/render/asset/*.h"} + }) add_includedirs("3rdparty", {public = true}) add_headerfiles("include/**.h", "include/**.inl") add_files("src/**.cpp") diff --git a/engine/modules/engine/zlib/include/pmr/name.h b/engine/modules/engine/zlib/include/pmr/name.h index b666818..045aa28 100644 --- a/engine/modules/engine/zlib/include/pmr/name.h +++ b/engine/modules/engine/zlib/include/pmr/name.h @@ -23,6 +23,7 @@ namespace pmr Name(std::string_view str)noexcept; auto operator<=>(const Name& other) const noexcept { return hash <=> other.hash; }; bool operator==(const Name& other) const {return hash == other.hash;} + bool operator==(size_t _hash) {return hash == _hash;} const char* data()const { return ToStringView().data(); } constexpr size_t Hash() const noexcept { return hash; } std::string ToString() const; diff --git a/engine/modules/engine/zlib/include/refl/detail/convert.inl b/engine/modules/engine/zlib/include/refl/detail/convert.inl index ac7c8b9..2b707e1 100644 --- a/engine/modules/engine/zlib/include/refl/detail/convert.inl +++ b/engine/modules/engine/zlib/include/refl/detail/convert.inl @@ -1,6 +1,6 @@ #include "convert.h" namespace refl { - ConvertMapWrap::ConvertMapWrap() : table(Convert::BuildConvertMap()){} + inline ConvertMapWrap::ConvertMapWrap() : table(Convert::BuildConvertMap()){} template inline bool refl::Convert::ConvertTo(Any& to, const Any& from) { diff --git a/engine/modules/engine/zlib/include/refl/detail/field.h b/engine/modules/engine/zlib/include/refl/detail/field.h index 01f57bd..bd0a684 100644 --- a/engine/modules/engine/zlib/include/refl/detail/field.h +++ b/engine/modules/engine/zlib/include/refl/detail/field.h @@ -43,7 +43,24 @@ namespace refl { const UClass* type{}; Data data{}; uint32_t flag{}; - + Offset GetOffset() const { + if (flag & FIELD_ATTRIBUTE_FLAG) { + return data.member.offset; + } + return 0; + } + Any GetValue()const { + if (flag & FIELD_ATTRIBUTE_FLAG) + return data.member.value; + return {}; + } + Any GetMeta()const { + if (flag & FIELD_ATTRIBUTE_FLAG) + return data.member.meta; + if (flag & FIELD_METHOD_FLAG) + return data.method.meta; + return {}; + } template auto Call(Func func, Args&&... args)const; template diff --git a/engine/modules/engine/zlib/include/refl/detail/meta.inl b/engine/modules/engine/zlib/include/refl/detail/meta.inl index b6adb46..a1d9710 100644 --- a/engine/modules/engine/zlib/include/refl/detail/meta.inl +++ b/engine/modules/engine/zlib/include/refl/detail/meta.inl @@ -1,7 +1,7 @@ #include "meta.h" #include "uclass.h" namespace refl { - span MakeAnyArgs(span args, span params, pmr::memory_resource* alloc = MetaGlobalPool()) { + inline span MakeAnyArgs(span args, span params, pmr::memory_resource* alloc = MetaGlobalPool()) { size_t clsIndex = params.size() - args.size(); assert(clsIndex > 0); span subParams = params.subspan(clsIndex); diff --git a/engine/modules/engine/zlib/include/refl/detail/uclass.h b/engine/modules/engine/zlib/include/refl/detail/uclass.h index 6dabaa8..23c58ff 100644 --- a/engine/modules/engine/zlib/include/refl/detail/uclass.h +++ b/engine/modules/engine/zlib/include/refl/detail/uclass.h @@ -145,6 +145,13 @@ namespace refl { } return {}; } + const UClass* GetMeta(Name name)const { + auto func = vtable.GetMeta(); + if (func) { + return func(name); + } + return {}; + } bool IsChildOf(const UClass* cls, bool bthis = false) const { const UClass* _parent = bthis ? this : parent; while (_parent != nullptr) { diff --git a/engine/modules/engine/zlib/include/refl/detail/uclass.inl b/engine/modules/engine/zlib/include/refl/detail/uclass.inl index b850650..7f86ce8 100644 --- a/engine/modules/engine/zlib/include/refl/detail/uclass.inl +++ b/engine/modules/engine/zlib/include/refl/detail/uclass.inl @@ -26,6 +26,9 @@ namespace refl { else { vtable.AddConstruct(&UClass::Construct); vtable.AddDestruct(&UClass::Destruct); + if constexpr (is_metas_v) { + vtable.AddGetMeta(&Meta::GetMeta); + } } } }; @@ -170,6 +173,9 @@ namespace refl { if constexpr (has_parent_v) { parent = meta_info>(); } + if constexpr (is_metas_v) { + vtable.AddGetMeta(&Meta::GetMeta); + } vtable.AddGetFields(&UClass_Meta::GetFields); vtable.AddConstruct(&UClass::Construct); } diff --git a/engine/modules/engine/zlib/xmake.lua b/engine/modules/engine/zlib/xmake.lua index 28e61e5..c0134a7 100644 --- a/engine/modules/engine/zlib/xmake.lua +++ b/engine/modules/engine/zlib/xmake.lua @@ -4,4 +4,5 @@ header_component("zlib","engine") if is_mode("debug") then add_defines("API_DEBUG", {public = true}) end + add_syslinks("kernel32") set_pcheader("include/refl/pch.h") \ No newline at end of file diff --git a/engine/modules/render/vulkan/src/vulkan_api.cpp b/engine/modules/render/vulkan/src/vulkan_api.cpp index 5570582..1fa042c 100644 --- a/engine/modules/render/vulkan/src/vulkan_api.cpp +++ b/engine/modules/render/vulkan/src/vulkan_api.cpp @@ -5,6 +5,7 @@ #include "vkn/wrapper/device.h" #include "vkn/thread/buffer_worker.h" #include "vkn/thread/command_worker.h" +#include "vkn/loader/vulkan_glsl_loader.h" #include "render/asset/mesh.h" #include "meta/enum.h" #include "tinyimageformat/tinyimageformat_apis.h" @@ -77,6 +78,167 @@ namespace vkn { } void VulkanAPI::LoadShader(Shader& shader) { + pmr::vector shaderStages; + std::map shaderModules; + auto& device = backend.GetDevice(); + auto vertModule = shader.GetVertHandle()->Ptr(); + shaderModules.insert(std::make_pair(VK_SHADER_STAGE_VERTEX_BIT, vertModule)); + auto fragModule = shader.GetFragHandle()->Ptr(); + shaderModules.insert(std::make_pair(VK_SHADER_STAGE_FRAGMENT_BIT, fragModule)); + for (auto& shaderModule : shaderModules) + { + VkPipelineShaderStageCreateInfo shaderStageInfo = {}; + shaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + shaderStageInfo.stage = shaderModule.first; + shaderStageInfo.module = shaderModule.second; + shaderStageInfo.pName = "main"; + shaderStages.push_back(shaderStageInfo); + } + auto it = refl::find_info(shader.Name()); + auto meta = it->GetMeta("vkMeta"); + // 设置顶点输入格式 + VkPipelineVertexInputStateCreateInfo vertexInputInfo = {}; + VkVertexInputBindingDescription bindingDescription = {}; + bindingDescription.binding = 0; + bindingDescription.stride = meta->size; + bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + //这里顶点属性不能大余16 + std::array attributeDescriptions = { }; + { + uint32_t count = 0; + for (auto& field : meta->GetFields(refl::FIND_ALL_MEMBER, Name(""))) { + auto& attr = attributeDescriptions[count]; + attr.binding = 0; + attr.location = count++; + attr.format = field.GetMeta() ? (VkFormat)field.GetMeta().CastTo() : VK_FORMAT_R32G32B32_SFLOAT; + attr.offset = field.GetOffset(); + } + vertexInputInfo.vertexAttributeDescriptionCount = count; + } + vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; + vertexInputInfo.pVertexBindingDescriptions = &bindingDescription; + vertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions.data(); + vertexInputInfo.vertexBindingDescriptionCount = 1; + + // 设置图元 + VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo = {}; + inputAssemblyInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; + inputAssemblyInfo.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + inputAssemblyInfo.primitiveRestartEnable = VK_FALSE; + + // ViewPort信息,这里不直接设置,下面弄成动态的 + VkPipelineViewportStateCreateInfo viewportStateInfo = {}; + viewportStateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; + viewportStateInfo.viewportCount = 1; + viewportStateInfo.scissorCount = 1; + + // View Port和Scissor设置为动态,每帧绘制时决定 + pmr::vector dynamicStates = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; + VkPipelineDynamicStateCreateInfo dynamicStateInfo = {}; + dynamicStateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; + dynamicStateInfo.pDynamicStates = dynamicStates.data(); + dynamicStateInfo.dynamicStateCount = static_cast(dynamicStates.size()); + + // 设置光栅化阶段 + VkPipelineRasterizationStateCreateInfo rasterizationInfo = {}; + rasterizationInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; + // 如果depthClampEnable设置为VK_TRUE,超过远近裁剪面的片元会进行收敛,而不是丢弃它们 + rasterizationInfo.depthClampEnable = VK_FALSE; + // 如果rasterizerDiscardEnable设置为VK_TRUE,那么几何图元永远不会传递到光栅化阶段 + // 这是禁止任何数据输出到framebuffer的方法 + rasterizationInfo.rasterizerDiscardEnable = VK_FALSE; + // 设置片元如何从几何模型中产生,如果不是FILL,需要开启GPU feature + // VK_POLYGON_MODE_FILL: 多边形区域填充 + // VK_POLYGON_MODE_LINE: 多边形边缘线框绘制 + // VK_POLYGON_MODE_POINT : 多边形顶点作为描点绘制 + rasterizationInfo.polygonMode = VK_POLYGON_MODE_FILL; + rasterizationInfo.lineWidth = 1.0f; + rasterizationInfo.cullMode = VK_CULL_MODE_FRONT_BIT; + rasterizationInfo.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; + // 渲染阴影的偏移配置 + rasterizationInfo.depthBiasEnable = VK_FALSE; + rasterizationInfo.depthBiasConstantFactor = 0.0f; + rasterizationInfo.depthBiasClamp = 0.0f; + rasterizationInfo.depthBiasSlopeFactor = 0.0f; + + // 设置Shader采样纹理的MSAA(不是输出到屏幕上的MSAA),需要创建逻辑设备的时候开启VkPhysicalDeviceFeatures里的sampleRateShading才能生效,暂时关闭 + VkPipelineMultisampleStateCreateInfo multisampleInfo = {}; + multisampleInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; + multisampleInfo.sampleShadingEnable = (VK_SAMPLE_COUNT_1_BIT & VK_SAMPLE_COUNT_1_BIT ? VK_FALSE : VK_TRUE); + multisampleInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + // 这个是调整sampleShading效果的,越接近1效果越平滑,越接近0性能越好 + multisampleInfo.minSampleShading = 1.0f; + multisampleInfo.pSampleMask = VK_NULL_HANDLE; + multisampleInfo.alphaToCoverageEnable = VK_FALSE; + multisampleInfo.alphaToOneEnable = VK_FALSE; + + // Color Blend + VkPipelineColorBlendAttachmentState colorBlendAttachment{}; + colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; + colorBlendAttachment.blendEnable = VK_TRUE; + colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; + colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; + colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD; + VkPipelineColorBlendStateCreateInfo colorBlending{}; + colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; + colorBlending.logicOpEnable = VK_FALSE; + colorBlending.logicOp = VK_LOGIC_OP_COPY; + colorBlending.pAttachments = &colorBlendAttachment; + colorBlending.attachmentCount = 1; + + // 深度和模板配置 + VkPipelineDepthStencilStateCreateInfo depthStencilInfo = {}; + depthStencilInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + // Depth + depthStencilInfo.depthWriteEnable = VK_FALSE; + depthStencilInfo.depthTestEnable = VK_TRUE; + depthStencilInfo.depthCompareOp = VK_COMPARE_OP_LESS; + depthStencilInfo.depthBoundsTestEnable = VK_FALSE; + depthStencilInfo.minDepthBounds = 0.0f; + depthStencilInfo.maxDepthBounds = 1.0f; + // Stencil + depthStencilInfo.stencilTestEnable = VK_FALSE; + depthStencilInfo.front = {}; + depthStencilInfo.back = {}; + /* + auto descriptorSetLayout = VulkanContext::CreateDescriptorSetLayout(shader.GetInfo()); + auto pipelineLayout = VulkanContext::CreatePipelineLayout({ descriptorSetLayout }, {}); + + VkGraphicsPipelineCreateInfo pipelineInfo{}; + pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + pipelineInfo.pStages = shaderStages.data(); + pipelineInfo.stageCount = (uint32_t)shaderStages.size(); + pipelineInfo.pVertexInputState = &vertexInputInfo; + pipelineInfo.pInputAssemblyState = &inputAssemblyInfo; + pipelineInfo.pViewportState = &viewportStateInfo; + pipelineInfo.pDynamicState = &dynamicStateInfo; + pipelineInfo.pRasterizationState = &rasterizationInfo; + pipelineInfo.pMultisampleState = &multisampleInfo; + pipelineInfo.pColorBlendState = &colorBlending; + pipelineInfo.pDepthStencilState = nullptr; //&depthStencilInfo; + pipelineInfo.layout = pipelineLayout; + pipelineInfo.renderPass = PassList[RENDER_FORWARD_RENDERING]->Ptr(); + pipelineInfo.subpass = 0; + pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; + pipelineInfo.basePipelineIndex = -1; + + VkPipeline pipeLine; + if (vkCreateGraphicsPipelines(device.Ptr(), VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeLine) != VK_SUCCESS) + throw std::runtime_error("failed to create graphics pipeline!"); + + for (auto& shaderModule : shaderModules) + vkDestroyShaderModule(device.Ptr(), shaderModule.second, nullptr); + + VulkanPipeline& vulkan_pipeline = PipelineTable[shader.GetGuid()]; + vulkan_pipeline.name = shader.Name(); + vulkan_pipeline.pipeline = pipeLine; + vulkan_pipeline.inUse = true; + vulkan_pipeline.pipelineLayout = pipelineLayout; + vulkan_pipeline.descriptorSetLayout = descriptorSetLayout; + vulkan_pipeline.descriptorSet = backend.GetPool().Allocate(descriptorSetLayout);*/ } ImagePtr VulkanAPI::CreateTexture(TextureDesc desc) { diff --git a/engine/modules/render/vulkan/src/vulkan_window.cpp b/engine/modules/render/vulkan/src/vulkan_window.cpp index 31f62fb..2d7ce2a 100644 --- a/engine/modules/render/vulkan/src/vulkan_window.cpp +++ b/engine/modules/render/vulkan/src/vulkan_window.cpp @@ -96,6 +96,7 @@ namespace vkn { throw std::runtime_error("Failed to wait for fence!"); vkAcquireNextImageKHR(mDevice.Ptr(), mPtr, UINT64_MAX, surfaceSemaphore, VK_NULL_HANDLE, &ctx.presentFrame); vkResetFences(mDevice.Ptr(), 1, &surfaceFence); + ctx.presentFrame = ctx.presentFrame % mFrames; } void VulkanSwapchain::Present(VulkanContext& ctx) { @@ -134,4 +135,5 @@ namespace vkn { .maxFrameInFlightCount = 2 }; } -} \ No newline at end of file +} +#include ".render/vertex_gen.inl" \ No newline at end of file diff --git a/game/zworld/editor/test_refl.h b/game/zworld/editor/test_refl.h index bf0aaff..db791ec 100644 --- a/game/zworld/editor/test_refl.h +++ b/game/zworld/editor/test_refl.h @@ -1,7 +1,5 @@ #include "refl/pch.h" #include -using namespace refl; -using namespace std; namespace api { struct Guid { UPROPERTY() @@ -9,11 +7,11 @@ namespace api { UPROPERTY() float b; UPROPERTY() - string view; + std::string view; USING_OVERLOAD_CTOR(Guid, int , float) UFUNCTION({}, ref = USING_CTOR_NAME) Guid(int aa, float bb) :a(aa), b(bb), view("default") { - cout << view << endl; + std::cout << view << std::endl; } UFUNCTION({}) int Multy(int c)const { diff --git a/game/zworld/editor/zworld_editor.cpp b/game/zworld/editor/zworld_editor.cpp index 66d8193..357e2cb 100644 --- a/game/zworld/editor/zworld_editor.cpp +++ b/game/zworld/editor/zworld_editor.cpp @@ -4,17 +4,19 @@ #define CORE_API_VAL #include "archive/json.h" #include "test_refl.h" -#include using namespace api; +using namespace std; +using namespace refl; int main() { - table t1, t2; - t1[1] = "hello"; - t1[2] = "world"; + using TestContainer = vector; + TestContainer t1, t2; + t1.push_back("hello"); + t1.push_back("world"); + //t1[1] = "hello"; + //t1[2] = "world"; + auto text = JsonSerialize(t1); - FileHandle handle("test.txt"); - handle.Open(FILE_OP::WRITE, false); - handle.Write(text); - auto res = JsonDeserialize>(text); + auto res = JsonDeserialize(text); if (res) { t2 = *res; }