zengine-old/engine/3rdparty/zlib/test/refl/vertex.h
2024-04-16 16:17:13 +08:00

64 lines
1.7 KiB
C++

#include <iostream>
#include "refl/refl.h"
using namespace std;
using namespace refl;
struct vec3_parent {
virtual int norm(int x1, int& x2) {
x2 = x1 * x2;
return x2;
//cout << x2 << "vec3_parent::norm" << endl;
}
};
struct vec3 : public vec3_parent {
float x = 1;
float y = 2;
float z = 3;
string name{ "hellohellohellohellohellohello" };
int norm(int x1, int& x2)override {
int tmp = x1 * 2 + 1;
x1 = x2;
x2 = tmp;
return x2;
//cout << x2 << "vec3::norm" << endl;
}
virtual float norm1(int& x1) {
x1 = x1 * x * y * z;
//x = x1;
//y = x1 - 1;
//z = x1 - 10;
//cout << x1 << "::norm1" << endl;
return x1;
}
static void norm2(int x1 = 10) {
cout << x1 << "::norm2" << endl;
}
static void norm3(int x1 = 10) {
x1 = x1 * 10;
cout << x1 << "::norm3" << endl;
}
using MyUClass = UClass_Meta<vec3, vec3_parent>;
//这里好像不需要
consteval static auto __StaticFields() {
return std::make_tuple(&vec3::x, &vec3::y, &vec3::z, &vec3::norm, &vec3::norm1, &vec3::norm2);
};
consteval static auto __MakeStaticFields() {
return std::array{
MakeStaticField(&vec3::x, "x"),
MakeStaticField(&vec3::y, "y"),
MakeStaticField(&vec3::z, "z"),
MakeStaticField(&vec3::norm, "norm", { 10,9 }),
MakeStaticField(&vec3::norm1, "norm1", { 10 }),
MakeStaticField(&vec3::norm2, "norm2", { 10 }),
};
}
static auto __MakeFields() {
return std::array{
Field<vec3>::MakeField(&vec3::x, "x"),
Field<vec3>::MakeField(&vec3::y, "y"),
Field<vec3>::MakeField(&vec3::z, "z"),
Field<vec3>::MakeField(&vec3::norm, "norm", {10,9}),
Field<vec3>::MakeField(&vec3::norm1, "norm1", {10}),
Field<vec3>::MakeField(&vec3::norm2, "norm2", {10}),
};
};
};