引擎接入反射功能

This commit is contained in:
ouczbs 2024-04-26 21:58:12 +08:00
parent faed6a2228
commit 9289182a1b
7 changed files with 154 additions and 137 deletions

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "svector.h" #include "svector.h"
#include <concepts> #include <concepts>
namespace refl {
template<typename T> template<typename T>
class sarray { class sarray {
protected: protected:
@ -71,4 +70,3 @@ namespace refl {
} }
}; };
}; };
}

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <array> #include <array>
#include <concepts> #include <concepts>
namespace refl {
template<typename T> template<typename T>
class svector { class svector {
protected: protected:
@ -70,4 +69,3 @@ namespace refl {
} }
}; };
}; };
}

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "zstd/parray.h" #include "zstd/parray.h"
#include "asset_render.h" #include "asset_render.h"
#include "../wrapper/vertex.h" #include "../meta/vertex.h"
namespace engineapi { namespace engineapi {
using zstd::parray; using zstd::parray;
class Texture; class Texture;

View File

@ -1,31 +1,49 @@
#pragma once #pragma once
#include "math/vector3.h" #include "math/vector3.h"
#include "math/vector2.h" #include "math/vector2.h"
#include "refl/refl.h"
// 顶点最多关联4个骨骼 // 顶点最多关联4个骨骼
#define MAX_NUM_BONES_PER_VERTEX 4 #define MAX_NUM_BONES_PER_VERTEX 4
namespace engineapi { namespace engineapi {
struct Vertex { struct Vertex {
//virtual Vector3& GetPosition() = 0;
}; };
struct PosVertex_Meta;
struct PosVertex : public Vertex{ struct PosVertex : public Vertex{
using MyMeta = PosVertex_Meta;
__cppast(Meta = {})
Vector3 Position = {}; Vector3 Position = {};
}; };
struct TexVertex_Meta;
struct TexVertex : public Vertex { struct TexVertex : public Vertex {
using MyMeta = TexVertex_Meta;
__cppast(Meta = {})
Vector3 Position = {}; Vector3 Position = {};
__cppast(Meta = {})
Vector3 Normal = {}; Vector3 Normal = {};
__cppast(Meta = {})
Vector2 TexCoords = {}; Vector2 TexCoords = {};
}; };
struct BoneVertex_Meta;
struct BoneVertex : public Vertex struct BoneVertex : public Vertex
{ {
using MyMeta = BoneVertex_Meta;
__cppast(Meta = {})
Vector3 Position = {}; Vector3 Position = {};
__cppast(Meta = {})
Vector2 TexCoords = {}; Vector2 TexCoords = {};
__cppast(Meta = {})
Vector3 Normal = {}; Vector3 Normal = {};
__cppast(Meta = {})
Vector3 Tangent = {}; Vector3 Tangent = {};
// 骨骼蒙皮数据 // 骨骼蒙皮数据
__cppast(Meta = {})
float Weights[MAX_NUM_BONES_PER_VERTEX] = {}; float Weights[MAX_NUM_BONES_PER_VERTEX] = {};
__cppast(Meta = {})
uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {}; uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {};
void AddBoneData(uint32_t boneID, float weight); void AddBoneData(uint32_t boneID, float weight);
}; };
}; };
#include "meta_vertex_gen.inl"

View File

@ -299,7 +299,7 @@ namespace vulkanapi {
pipelineInfo.pRasterizationState = &rasterizationInfo; pipelineInfo.pRasterizationState = &rasterizationInfo;
pipelineInfo.pMultisampleState = &multisampleInfo; pipelineInfo.pMultisampleState = &multisampleInfo;
pipelineInfo.pColorBlendState = &colorBlending; pipelineInfo.pColorBlendState = &colorBlending;
pipelineInfo.pDepthStencilState = nullptr; &depthStencilInfo; pipelineInfo.pDepthStencilState = nullptr; //&depthStencilInfo;
pipelineInfo.layout = pipelineLayout; pipelineInfo.layout = pipelineLayout;
pipelineInfo.renderPass = PassList[RENDER_FORWARD_RENDERING]->Ptr(); pipelineInfo.renderPass = PassList[RENDER_FORWARD_RENDERING]->Ptr();
pipelineInfo.subpass = 0; pipelineInfo.subpass = 0;

View File

@ -5,6 +5,9 @@ target("zengine")
set_kind("binary") set_kind("binary")
set_rundir(".") set_rundir(".")
add_rules("volk.env", "glsl.env") add_rules("volk.env", "glsl.env")
add_rules("c++.codegen",{
files = {"src/engine/render/meta/*.h"}
})
add_deps("zlib","zlog") add_deps("zlib","zlog")
add_defines("VULKAN_API") add_defines("VULKAN_API")
add_packages("vulkansdk","tinyobjloader","assimp","nlohmann_json") add_packages("vulkansdk","tinyobjloader","assimp","nlohmann_json")