引擎接入反射功能
This commit is contained in:
parent
faed6a2228
commit
9289182a1b
132
engine/3rdparty/zlib/include/refl/std/sarray.h
vendored
132
engine/3rdparty/zlib/include/refl/std/sarray.h
vendored
@ -1,74 +1,72 @@
|
||||
#pragma once
|
||||
#include "svector.h"
|
||||
#include <concepts>
|
||||
namespace refl {
|
||||
template<typename T>
|
||||
class sarray {
|
||||
protected:
|
||||
const T* m_ptr;
|
||||
int m_count;
|
||||
public:
|
||||
constexpr sarray(const T* ptr, int count) : m_ptr(ptr), m_count(count) {}
|
||||
constexpr sarray(const svector<T>& vec) : m_ptr(vec.front()), m_count(vec.size()) {}
|
||||
constexpr sarray() :m_ptr(nullptr), m_count(0) {}
|
||||
constexpr sarray(std::initializer_list<T> list) : m_ptr(list.begin()), m_count(list.size()) {}
|
||||
constexpr const T* front() const noexcept {
|
||||
return m_ptr;
|
||||
template<typename T>
|
||||
class sarray {
|
||||
protected:
|
||||
const T* m_ptr;
|
||||
int m_count;
|
||||
public:
|
||||
constexpr sarray(const T* ptr, int count) : m_ptr(ptr), m_count(count) {}
|
||||
constexpr sarray(const svector<T>& vec) : m_ptr(vec.front()), m_count(vec.size()) {}
|
||||
constexpr sarray() :m_ptr(nullptr), m_count(0) {}
|
||||
constexpr sarray(std::initializer_list<T> list) : m_ptr(list.begin()), m_count(list.size()) {}
|
||||
constexpr const T* front() const noexcept {
|
||||
return m_ptr;
|
||||
}
|
||||
constexpr const T* back()const noexcept {
|
||||
return m_ptr + m_count;
|
||||
}
|
||||
constexpr const T* at(int i) const noexcept {
|
||||
if (i < m_count) {
|
||||
return m_ptr + i;
|
||||
}
|
||||
constexpr const T* back()const noexcept {
|
||||
return m_ptr + m_count;
|
||||
}
|
||||
constexpr const T* at(int i) const noexcept {
|
||||
if (i < m_count) {
|
||||
return m_ptr + i;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
constexpr bool IsValid() const noexcept {
|
||||
return m_count > 0;
|
||||
}
|
||||
constexpr bool empty() const noexcept {
|
||||
return m_count == 0;
|
||||
}
|
||||
constexpr int size() const noexcept {
|
||||
return m_count;
|
||||
}
|
||||
constexpr auto begin()const noexcept {
|
||||
return iterator{ m_ptr };
|
||||
}
|
||||
constexpr auto end() const noexcept {
|
||||
return iterator{ m_ptr + m_count};
|
||||
}
|
||||
// Iterator class
|
||||
class iterator {
|
||||
private:
|
||||
const T* ptr;
|
||||
return nullptr;
|
||||
}
|
||||
constexpr bool IsValid() const noexcept {
|
||||
return m_count > 0;
|
||||
}
|
||||
constexpr bool empty() const noexcept {
|
||||
return m_count == 0;
|
||||
}
|
||||
constexpr int size() const noexcept {
|
||||
return m_count;
|
||||
}
|
||||
constexpr auto begin()const noexcept {
|
||||
return iterator{ m_ptr };
|
||||
}
|
||||
constexpr auto end() const noexcept {
|
||||
return iterator{ m_ptr + m_count};
|
||||
}
|
||||
// Iterator class
|
||||
class iterator {
|
||||
private:
|
||||
const T* ptr;
|
||||
|
||||
public:
|
||||
constexpr iterator(const T* p) : ptr(p) {}
|
||||
public:
|
||||
constexpr iterator(const T* p) : ptr(p) {}
|
||||
|
||||
// Overload ++ to move to next element
|
||||
constexpr iterator& operator++() noexcept{
|
||||
++ptr;
|
||||
return *this;
|
||||
}
|
||||
//这里其实是--it,而不是it--
|
||||
constexpr iterator& operator--(int) noexcept {
|
||||
--ptr;
|
||||
return *this;
|
||||
}
|
||||
constexpr const T* operator->() const noexcept {
|
||||
return ptr;
|
||||
}
|
||||
// Overload * to dereference iterator
|
||||
constexpr const T& operator*() const noexcept {
|
||||
return *ptr;
|
||||
}
|
||||
// Overload ++ to move to next element
|
||||
constexpr iterator& operator++() noexcept{
|
||||
++ptr;
|
||||
return *this;
|
||||
}
|
||||
//这里其实是--it,而不是it--
|
||||
constexpr iterator& operator--(int) noexcept {
|
||||
--ptr;
|
||||
return *this;
|
||||
}
|
||||
constexpr const T* operator->() const noexcept {
|
||||
return ptr;
|
||||
}
|
||||
// Overload * to dereference iterator
|
||||
constexpr const T& operator*() const noexcept {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
// Overload != to compare iterators
|
||||
constexpr bool operator!=(const iterator& other) const noexcept {
|
||||
return ptr != other.ptr;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
// Overload != to compare iterators
|
||||
constexpr bool operator!=(const iterator& other) const noexcept {
|
||||
return ptr != other.ptr;
|
||||
}
|
||||
};
|
||||
};
|
||||
130
engine/3rdparty/zlib/include/refl/std/svector.h
vendored
130
engine/3rdparty/zlib/include/refl/std/svector.h
vendored
@ -1,73 +1,71 @@
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <concepts>
|
||||
namespace refl {
|
||||
template<typename T>
|
||||
class svector {
|
||||
protected:
|
||||
T* m_ptr;
|
||||
int m_count;
|
||||
int m_capicty;
|
||||
public:
|
||||
constexpr svector() :m_ptr(nullptr), m_count(0), m_capicty(0){}
|
||||
constexpr svector(T* ptr, int size, int count) : m_ptr(ptr), m_capicty(size), m_count(count){}
|
||||
constexpr T* front()const noexcept {
|
||||
return m_ptr;
|
||||
template<typename T>
|
||||
class svector {
|
||||
protected:
|
||||
T* m_ptr;
|
||||
int m_count;
|
||||
int m_capicty;
|
||||
public:
|
||||
constexpr svector() :m_ptr(nullptr), m_count(0), m_capicty(0){}
|
||||
constexpr svector(T* ptr, int size, int count) : m_ptr(ptr), m_capicty(size), m_count(count){}
|
||||
constexpr T* front()const noexcept {
|
||||
return m_ptr;
|
||||
}
|
||||
constexpr T* back()const noexcept {
|
||||
return m_ptr + m_count;
|
||||
}
|
||||
constexpr void push_back(const T& t) {
|
||||
if (m_count < m_capicty) {
|
||||
*(m_ptr + m_count) = t;
|
||||
m_count++;
|
||||
}
|
||||
constexpr T* back()const noexcept {
|
||||
return m_ptr + m_count;
|
||||
}
|
||||
constexpr void push_back(const T& t) {
|
||||
if (m_count < m_capicty) {
|
||||
*(m_ptr + m_count) = t;
|
||||
m_count++;
|
||||
}
|
||||
}
|
||||
constexpr bool IsValid() const noexcept {
|
||||
return m_count > 0;
|
||||
}
|
||||
constexpr bool empty() const noexcept {
|
||||
return m_count == 0;
|
||||
}
|
||||
constexpr int size() const noexcept {
|
||||
return m_count;
|
||||
}
|
||||
constexpr auto begin()const noexcept {
|
||||
return iterator{ m_ptr };
|
||||
}
|
||||
constexpr auto end() const noexcept {
|
||||
return iterator{ m_ptr + m_count };
|
||||
}
|
||||
// Iterator class
|
||||
class iterator {
|
||||
private:
|
||||
const T* ptr;
|
||||
}
|
||||
constexpr bool IsValid() const noexcept {
|
||||
return m_count > 0;
|
||||
}
|
||||
constexpr bool empty() const noexcept {
|
||||
return m_count == 0;
|
||||
}
|
||||
constexpr int size() const noexcept {
|
||||
return m_count;
|
||||
}
|
||||
constexpr auto begin()const noexcept {
|
||||
return iterator{ m_ptr };
|
||||
}
|
||||
constexpr auto end() const noexcept {
|
||||
return iterator{ m_ptr + m_count };
|
||||
}
|
||||
// Iterator class
|
||||
class iterator {
|
||||
private:
|
||||
const T* ptr;
|
||||
|
||||
public:
|
||||
constexpr iterator(const T* p) : ptr(p) {}
|
||||
public:
|
||||
constexpr iterator(const T* p) : ptr(p) {}
|
||||
|
||||
// Overload ++ to move to next element
|
||||
constexpr iterator& operator++() noexcept {
|
||||
++ptr;
|
||||
return *this;
|
||||
}
|
||||
//这里其实是--it,而不是it--
|
||||
constexpr iterator& operator--(int) noexcept {
|
||||
--ptr;
|
||||
return *this;
|
||||
}
|
||||
constexpr const T* operator->() const noexcept {
|
||||
return ptr;
|
||||
}
|
||||
// Overload * to dereference iterator
|
||||
constexpr const T& operator*() const noexcept {
|
||||
return *ptr;
|
||||
}
|
||||
// Overload ++ to move to next element
|
||||
constexpr iterator& operator++() noexcept {
|
||||
++ptr;
|
||||
return *this;
|
||||
}
|
||||
//这里其实是--it,而不是it--
|
||||
constexpr iterator& operator--(int) noexcept {
|
||||
--ptr;
|
||||
return *this;
|
||||
}
|
||||
constexpr const T* operator->() const noexcept {
|
||||
return ptr;
|
||||
}
|
||||
// Overload * to dereference iterator
|
||||
constexpr const T& operator*() const noexcept {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
// Overload != to compare iterators
|
||||
constexpr bool operator!=(const iterator& other) const noexcept {
|
||||
return ptr != other.ptr;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
// Overload != to compare iterators
|
||||
constexpr bool operator!=(const iterator& other) const noexcept {
|
||||
return ptr != other.ptr;
|
||||
}
|
||||
};
|
||||
};
|
||||
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "zstd/parray.h"
|
||||
#include "asset_render.h"
|
||||
#include "../wrapper/vertex.h"
|
||||
#include "../meta/vertex.h"
|
||||
namespace engineapi {
|
||||
using zstd::parray;
|
||||
class Texture;
|
||||
|
||||
@ -1,31 +1,49 @@
|
||||
#pragma once
|
||||
#include "math/vector3.h"
|
||||
#include "math/vector2.h"
|
||||
#include "refl/refl.h"
|
||||
// 顶点最多关联4个骨骼
|
||||
#define MAX_NUM_BONES_PER_VERTEX 4
|
||||
|
||||
namespace engineapi {
|
||||
struct Vertex {
|
||||
//virtual Vector3& GetPosition() = 0;
|
||||
|
||||
};
|
||||
struct PosVertex_Meta;
|
||||
struct PosVertex : public Vertex{
|
||||
using MyMeta = PosVertex_Meta;
|
||||
__cppast(Meta = {})
|
||||
Vector3 Position = {};
|
||||
};
|
||||
struct TexVertex_Meta;
|
||||
struct TexVertex : public Vertex {
|
||||
using MyMeta = TexVertex_Meta;
|
||||
__cppast(Meta = {})
|
||||
Vector3 Position = {};
|
||||
__cppast(Meta = {})
|
||||
Vector3 Normal = {};
|
||||
__cppast(Meta = {})
|
||||
Vector2 TexCoords = {};
|
||||
};
|
||||
struct BoneVertex_Meta;
|
||||
struct BoneVertex : public Vertex
|
||||
{
|
||||
using MyMeta = BoneVertex_Meta;
|
||||
__cppast(Meta = {})
|
||||
Vector3 Position = {};
|
||||
__cppast(Meta = {})
|
||||
Vector2 TexCoords = {};
|
||||
__cppast(Meta = {})
|
||||
Vector3 Normal = {};
|
||||
__cppast(Meta = {})
|
||||
Vector3 Tangent = {};
|
||||
// 骨骼蒙皮数据
|
||||
__cppast(Meta = {})
|
||||
float Weights[MAX_NUM_BONES_PER_VERTEX] = {};
|
||||
__cppast(Meta = {})
|
||||
uint32_t BoneIDs[MAX_NUM_BONES_PER_VERTEX] = {};
|
||||
|
||||
void AddBoneData(uint32_t boneID, float weight);
|
||||
};
|
||||
};
|
||||
};
|
||||
#include "meta_vertex_gen.inl"
|
||||
@ -299,7 +299,7 @@ namespace vulkanapi {
|
||||
pipelineInfo.pRasterizationState = &rasterizationInfo;
|
||||
pipelineInfo.pMultisampleState = &multisampleInfo;
|
||||
pipelineInfo.pColorBlendState = &colorBlending;
|
||||
pipelineInfo.pDepthStencilState = nullptr; &depthStencilInfo;
|
||||
pipelineInfo.pDepthStencilState = nullptr; //&depthStencilInfo;
|
||||
pipelineInfo.layout = pipelineLayout;
|
||||
pipelineInfo.renderPass = PassList[RENDER_FORWARD_RENDERING]->Ptr();
|
||||
pipelineInfo.subpass = 0;
|
||||
|
||||
@ -5,6 +5,9 @@ target("zengine")
|
||||
set_kind("binary")
|
||||
set_rundir(".")
|
||||
add_rules("volk.env", "glsl.env")
|
||||
add_rules("c++.codegen",{
|
||||
files = {"src/engine/render/meta/*.h"}
|
||||
})
|
||||
add_deps("zlib","zlog")
|
||||
add_defines("VULKAN_API")
|
||||
add_packages("vulkansdk","tinyobjloader","assimp","nlohmann_json")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user